octfx / mediawiki-extension-WebP

Convert image files on upload to WebP
https://mediawiki.org/wiki/Extension:WebP
GNU General Public License v2.0
6 stars 4 forks source link

ImageMagik on server + WebP extension installed but getting 500 #17

Open Vetpetmon opened 1 year ago

Vetpetmon commented 1 year ago

Adding ImageMagick lines to LocalSettings.php introduces no errors, outside of initial compression load times.

However, adding WebP Extension through the installation methods in the README.md results in the server having an internal error.

My server is running PHP 7.4 with Mediawiki 1.39.0. Here is the stacktrace:

Original exception: [Y6ZVU1gf16ZhEg64NuOAXQAA4RE] /snazpedia/index.php/Main_Page ImagickException: Unable to set image format
Backtrace:
from /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/WebPTransformer.php(295)
#0 /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/WebPTransformer.php(295): Imagick->setimageformat(string)
#1 /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/WebPTransformer.php(223): MediaWiki\Extension\WebP\WebPTransformer->transformImagick(string, integer)
#2 /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/WebPTransformer.php(109): MediaWiki\Extension\WebP\WebPTransformer->transformImage(string, integer)
#3 /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/WebPMediaHandler.php(50): MediaWiki\Extension\WebP\WebPTransformer->transformLikeThumb(MediaWiki\Extension\WebP\FakeMediaTransformOutput)
#4 /home2/vetpetmon/public_html/snazpedia/includes/media/TransformationalImageHandler.php(253): MediaWiki\Extension\WebP\WebPMediaHandler->transformImageMagick(MediaWiki\Extension\WebP\Repo\LocalWebPFile, array)
#5 /home2/vetpetmon/public_html/snazpedia/includes/filerepo/file/File.php(1317): TransformationalImageHandler->doTransform(MediaWiki\Extension\WebP\Repo\LocalWebPFile, string, string, array)
#6 /home2/vetpetmon/public_html/snazpedia/includes/filerepo/file/File.php(1264): File->generateAndSaveThumb(TempFSFile, array, integer)
#7 /home2/vetpetmon/public_html/snazpedia/extensions/WebP/includes/Repo/LocalWebPFile.php(97): File->transform(array, integer)
#8 /home2/vetpetmon/public_html/snazpedia/includes/Linker.php(444): MediaWiki\Extension\WebP\Repo\LocalWebPFile->transform(array)
#9 /home2/vetpetmon/public_html/snazpedia/includes/parser/Parser.php(5557): Linker::makeImageLink(Parser, Title, MediaWiki\Extension\WebP\Repo\LocalWebPFile, array, array, boolean, boolean, integer)
#10 /home2/vetpetmon/public_html/snazpedia/includes/parser/Parser.php(2714): Parser->makeImage(Title, array, LinkHolderArray)
#11 /home2/vetpetmon/public_html/snazpedia/includes/parser/Parser.php(2457): Parser->handleInternalLinks2(string)
#12 /home2/vetpetmon/public_html/snazpedia/includes/parser/Parser.php(1638): Parser->handleInternalLinks(string)
#13 /home2/vetpetmon/public_html/snazpedia/includes/parser/Parser.php(723): Parser->internalParse(string)
#14 /home2/vetpetmon/public_html/snazpedia/includes/content/WikitextContentHandler.php(301): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
#15 /home2/vetpetmon/public_html/snazpedia/includes/content/ContentHandler.php(1721): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, ParserOutput)
#16 /home2/vetpetmon/public_html/snazpedia/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)
#17 /home2/vetpetmon/public_html/snazpedia/includes/Revision/RenderedRevision.php(266): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, Title, integer, ParserOptions, boolean)
#18 /home2/vetpetmon/public_html/snazpedia/includes/Revision/RenderedRevision.php(237): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean)
#19 /home2/vetpetmon/public_html/snazpedia/includes/Revision/RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array)
#20 /home2/vetpetmon/public_html/snazpedia/includes/Revision/RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)
#21 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#22 /home2/vetpetmon/public_html/snazpedia/includes/Revision/RenderedRevision.php(199): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)
#23 /home2/vetpetmon/public_html/snazpedia/includes/poolcounter/PoolWorkArticleView.php(91): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#24 /home2/vetpetmon/public_html/snazpedia/includes/poolcounter/PoolWorkArticleViewCurrent.php(97): PoolWorkArticleView->renderRevision()
#25 /home2/vetpetmon/public_html/snazpedia/includes/poolcounter/PoolCounterWork.php(162): PoolWorkArticleViewCurrent->doWork()
#26 /home2/vetpetmon/public_html/snazpedia/includes/page/ParserOutputAccess.php(299): PoolCounterWork->execute()
#27 /home2/vetpetmon/public_html/snazpedia/includes/page/Article.php(714): MediaWiki\Page\ParserOutputAccess->getParserOutput(WikiPage, ParserOptions, MediaWiki\Revision\RevisionStoreRecord, integer)
#28 /home2/vetpetmon/public_html/snazpedia/includes/page/Article.php(528): Article->generateContentOutput(User, ParserOptions, integer, OutputPage, array)
#29 /home2/vetpetmon/public_html/snazpedia/includes/actions/ViewAction.php(78): Article->view()
#30 /home2/vetpetmon/public_html/snazpedia/includes/MediaWiki.php(542): ViewAction->show()
#31 /home2/vetpetmon/public_html/snazpedia/includes/MediaWiki.php(322): MediaWiki->performAction(Article, Title)
#32 /home2/vetpetmon/public_html/snazpedia/includes/MediaWiki.php(904): MediaWiki->performRequest()
#33 /home2/vetpetmon/public_html/snazpedia/includes/MediaWiki.php(562): MediaWiki->main()
#34 /home2/vetpetmon/public_html/snazpedia/index.php(50): MediaWiki->run()
#35 /home2/vetpetmon/public_html/snazpedia/index.php(46): wfIndexMain()
#36 {main}

And here are my settings:

$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

wfLoadExtension( 'WebP' );
$wgWebPCompressionQuality = 50;
$wgWebPFilterStrength = 50;
$wgWebPAutoFilter = true;
$wgWebPConvertInJobQueue = true;
$wgWebPEnableConvertOnUpload = true;
$wgWebPEnableConvertOnTransform = true;

Is there any way to fix this?

Edit: phpinfo returns this for GD: image This is returned for Imagick: image

Vetpetmon commented 1 year ago

I have currently commented out all lines in LocalSettings.php in order to make the site usable again, which means this extension is responsible.

Vetpetmon commented 1 year ago

WebP does NOT support GD as a fallback, which appears to be the issue. I'll see about getting WebP support into Imagick ASAP. If that fixes issues, I'll close this issue with instructions on how to resolve the issue.

octfx commented 1 year ago

Thanks for the report!

It seems like the installed imagick version does not support webp (as it is not listed in the supported formats).
You need to have libwebp6 installed, and an imagick version supporting WebP (as a reference my local version is on 3.7.0).

I'll look into it adding support for GD.

Vetpetmon commented 1 year ago

Yeah, web server hosts won't let me update Imagick, so having GD support is nice. I'll test it on my server, and see if GD + WebP loads pages faster than just Imagick.

Vetpetmon commented 1 year ago

Results returned: image Images silently fail to convert to WebP. Only images that work are SVG files.

WebP with GD causes CPU load times of 3-4 seconds, while Imagick has CPU times of a tenth a second. Further testing with bugfixes needed.

octfx commented 1 year ago

Are you using thumb.php?

I'll investigating the long gd times in the following days.

Vetpetmon commented 1 year ago

I am not using thumb.php as far as I know, where can I find the file? I sadly do not have shell access, so options are limited.

I can easily work my way through the Linux command line, but provider said "no" to access, which is why I am looking forwards to fixing GD support now.

octfx commented 1 year ago

thumb.php refers to MediaWiki's Thumb Handler.
Enabling the handler stops creating all thumbnails of a page on page display (which slows down displaying the site to the user), but rather generates them in the background, which should let the page load faster. (plus it allows to utilize the Job Queue is setup)

As for gd I have not found the time yet, but this is still on my todo