Topic on Project:Support desk/Flow

Error creating thumbnail Error code: -1

13
Summary by Seb35

Various resolutions by tuning different parameters: $wgMaxShellMemory, $wgMaxShellFileSize, $wgGenerateThumbnailOnParse = true, $wgUseImageMagick = false.

Dlwnsgud0819 (talkcontribs)

Error creating thumbnail Error code: -1

Some images say Error creating thumbnail Error code: -1. Not display that error in all images, but some display that error or is too late to create thumbnail.

Version is like this:

MediaWiki : 1.24.2

PHP : 5.4.39 (apache)

MySQL : 5.0.45-log

ImageMagick : 6.9.1-1

Ciencia Al Poder (talkcontribs)

If that happens with some images, it may be that they're large or complex enough which makes the thumbnail to fail. It may be that it requires more memory than the available memory of the server, or the allowed memory to use by PHP. See Manual:$wgMaxShellMemory and Manual:$wgMaxShellFileSize, and try using higher values.

Dlwnsgud0819 (talkcontribs)

I already set that paramiter($wgMaxShellFileSize = 307200; $wgMaxShellMemory = 409600;), but It doesn't work. Also php limit is already 128M (I checked by memory_limit in phpinfo.)

Ciencia Al Poder (talkcontribs)

Best you can do then is follow Manual:How to debug to set up a debug log, that will print the exact command used to create the thumbnail, and execute that same command from the shell to see if it gives any error message.

Dlwnsgud0819 (talkcontribs)

This is the log which shows error:
wfShellExec: /bin/bash '/home/xxxwiki/user/w/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/local/bin/convert'\'' '\''-background'\'' '\''white'\'' '\''/home/xxxwiki/user/w/images/2/2d/gggg.gif'\'' '\''-thumbnail'\'' '\''418x600!'\'' '\''-set'\'' '\''comment'\'' '\''File source: http://xxxwiki.xxx/w/index.php/gggg.gif'\'' '\''-depth'\'' '\''8'\'' '\''-rotate'\'' '\''-0'\'' '\''/tmp/transform_e203a7abc952-1.gif'\''' 'MW_INCLUDE_STDERR=1;MW_CPU_LIMIT=0; MW_CGROUP='\'''\''; MW_MEM_LIMIT=409600; MW_FILE_SIZE_LIMIT=307200; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'

[thumbnail] thumbnail failed on xxxwiki.xxx: error -1 "" from "'/usr/local/bin/convert' '-background' 'white' '/home/xxxwiki/user/w/images/2/2d/gggg.gif' '-thumbnail' '418x600!' '-set' 'comment' 'File source: http://xxxwiki.xxx/w/index.php/gggg.gif' '-depth' '8' '-rotate' '-0' '/tmp/transform_e203a7abc952-1.gif'"

[thumbnail] Removing bad 95389-byte thumbnail "/tmp/transform_e203a7abc952-1.gif". unlink() succeeded

Ciencia Al Poder (talkcontribs)

Do you have shell access? You should try to paste that command on the shell and see if it gives an error message. The strange thing is that apparently it succeeds in creating the file, because it says it was removing a bad thumbnail from the temp directory, which is the same it was trying to create.

Gus38000 (talkcontribs)

I have the same problem

The logs with the error :

File::transform: Doing stat for mwstore://local-backend/local-thumb/4/4b/IMAGE.png/400px-IMAGE.png

FileBackendStore::getFileStat: File mwstore://local-backend/local-thumb/4/4b/IMAGE.png/400px-IMAGE.png does not exist.

TransformationalImageHandler::doTransform: creating 400x381 thumbnail at /home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png using scaler im

TransformationalImageHandler::doTransform: called wfMkdirParents(/home/HOST/www/wiki/images/temp)

BitmapHandler::transformImageMagick: running ImageMagick: '/usr/bin/convert' '-quality' '95' '-background' 'white' '/home/HOST/www/wiki/images/4/4b/IMAGE.png' '-thumbnail' '400x381!' '-set' 'comment' 'File source: http://wiki.igcbox.fr/index.php?title=Fichier:IMAGE.png' '-depth' '8' '-rotate' '-0' '/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png'

wfShellExec: /bin/bash '/home/HOST/www/wiki/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/bin/convert'\'' '\''-quality'\'' '\''95'\'' '\''-background'\'' '\''white'\'' '\''/home/HOST/www/wiki/images/4/4b/IMAGE.png'\'' '\''-thumbnail'\'' '\''400x381!'\'' '\''-set'\'' '\''comment'\'' '\''File source: http://wiki.igcbox.fr/index.php?title=Fichier:IMAGE.png'\'' '\''-depth'\'' '\''8'\'' '\''-rotate'\'' '\''-0'\'' '\''/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png'\''' 'MW_INCLUDE_STDERR=1;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'

[thumbnail] thumbnail failed on webmx.y.ha.ovh.net: error -1 "" from "'/usr/bin/convert' '-quality' '95' '-background' 'white' '/home/HOST/www/wiki/images/4/4b/IMAGE.png' '-thumbnail' '400x381!' '-set' 'comment' 'File source: http://wiki.igcbox.fr/index.php?title=Fichier:IMAGE.png' '-depth' '8' '-rotate' '-0' '/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png'"

[thumbnail] Removing bad 97208-byte thumbnail "/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png". unlink() succeeded

I've tried the command on shell :
$ /bin/bash '/home/HOST/www/wiki/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/bin/convert'\'' '\''-quality'\'' '\''95'\'' '\''-background'\'' '\''white'\'' '\''/home/HOST/www/wiki/images/4/4b/IMAGE.png'\'' '\''-thumbnail'\'' '\''400x381!'\'' '\''-set'\'' '\''comment'\'' '\''File source: http://wiki.igcbox.fr/index.php?title=Fichier:IMAGE.png'\'' '\''-depth'\'' '\''8'\'' '\''-rotate'\'' '\''-0'\'' '\''/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png'\''' 'MW_INCLUDE_STDERR=1;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'
$ echo $?
0

And only the convert command :
$ '/usr/bin/convert' '-quality' '95' '-background' 'white' '/home/HOST/www/wiki/images/4/4b/IMAGE.png' '-thumbnail' '400x381!' '-set' 'comment' 'File source: http://wiki.igcbox.fr/index.php?title=Fichier:IMAGE.png' '-depth' '8' '-rotate' '-0' '/home/HOST/www/wiki/images/temp/transform_56e28eca10ad-1.png'
$ echo $?
0

In the 2 case the thumbnail is created in temporary folder.
As you can see the exit code is ok (0)

My configuration :
MediaWiki 1.24.2
PHP 5.5.22 (fpm-fcgi)
$ convert --version
Version: ImageMagick 6.6.0-4 2014-11-22 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Akn87 (talkcontribs)

I've got the same error and already tried to increase $wgMaxShellFileSize, $wgMaxShellMemory and memory_limit in php.ini

@Dlwnsgud0819 , @Gus38000 maybe your problem was solved in the mean time and you can tell me what your solution was?

My system configuration:

MediaWiki : 1.23.11

PHP : 5.6.5 (Apache)

MySQL : 5.6

ImageMagick : 6.7.8-2

Ciencia Al Poder (talkcontribs)

To get a solution, the problem must be diagnosed properly.

Set up a debug log as I explained in one of the messages to see the exact command that's being executed. Look at it, and see if the paths it uses make sense, wiki has permissions to write to the resulting file, etc. Also, try executing the command yourself on the server.

Stefahn (talkcontribs)

Hi all, Hi Cienca,

I ran into the same issue: "Error creating thumbnail Error code: -1"

My setup: MediaWiki 1.27.0, PHP 5.6.18 (cgi-fcgi), MySQL 5.6.29, ImageMagick 6.9.2-0 Q16 i686

Here's what my debug file says:

File::transform: Doing stat for mwstore://local-backend/local-thumb/0/05/260.jpg/70px-260.jpg
FileBackendStore::getFileStat: File mwstore://local-backend/local-thumb/0/05/260.jpg/70px-260.jpg does not exist.
TransformationalImageHandler::doTransform: creating 70x70 thumbnail at /tmp/transform_4c3f03fe95f1.jpg using scaler im
TransformationalImageHandler::doTransform: called wfMkdirParents(/tmp)
TransformationalImageHandler::{closure}: Running convert -version
wfShellExec: /bin/bash '/html/domain.org/mediawiki/includes/limit.sh' ''\''/usr/local/bin/convert'\'' -version' 'MW_INCLUDE_STDERR=;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'
BitmapHandler::transformImageMagick: running ImageMagick: '/usr/local/bin/convert' '-quality' '80' '-background' 'white' '-define' 'jpeg:size=70x70' '/html/domain.org/mediawiki/images/0/05/260.jpg' '-thumbnail' '70x70!' '-set' 'comment' 'File source: http://domain.org/wiki/Datei:260.jpg' '+set' 'Thumb::URI' '-depth' '8' '-sharpen' '0x0.4' '-rotate' '-0' '-sampling-factor' '2x2,1x1,1x1' '/tmp/transform_4c3f03fe95f1.jpg'
wfShellExec: /bin/bash '/html/domain.org/mediawiki/includes/limit.sh' 'OMP_NUM_THREADS='\''1'\'' '\''/usr/local/bin/convert'\'' '\''-quality'\'' '\''80'\'' '\''-background'\'' '\''white'\'' '\''-define'\'' '\''jpeg:size=70x70'\'' '\''/html/domain.org/mediawiki/images/0/05/260.jpg'\'' '\''-thumbnail'\'' '\''70x70!'\'' '\''-set'\'' '\''comment'\'' '\''File source: http://domain.org/wiki/Datei:260.jpg'\'' '\''+set'\'' '\''Thumb::URI'\'' '\''-depth'\'' '\''8'\'' '\''-sharpen'\'' '\''0x0.4'\'' '\''-rotate'\'' '\''-0'\'' '\''-sampling-factor'\'' '\''2x2,1x1,1x1'\'' '\''/tmp/transform_4c3f03fe95f1.jpg'\''' 'MW_INCLUDE_STDERR=1;MW_CPU_LIMIT=180; MW_CGROUP='\'''\''; MW_MEM_LIMIT=307200; MW_FILE_SIZE_LIMIT=102400; MW_WALL_CLOCK_LIMIT=180; MW_USE_LOG_PIPE=yes'
[thumbnail] thumbnail failed on domain.org: error -1 "" from "'/usr/local/bin/convert' '-quality' '80' '-background' 'white' '-define' 'jpeg:size=70x70' '/html/domain.org/mediawiki/images/0/05/260.jpg' '-thumbnail' '70x70!' '-set' 'comment' 'File source: http://domain.org/wiki/Datei:260.jpg' '+set' 'Thumb::URI' '-depth' '8' '-sharpen' '0x0.4' '-rotate' '-0' '-sampling-factor' '2x2,1x1,1x1' '/tmp/transform_4c3f03fe95f1.jpg'"
[thumbnail] Removing bad 1499-byte thumbnail "/tmp/transform_4c3f03fe95f1.jpg". unlink() succeeded

I also tried the 3 commands on Putty. After the second one (the command after BitmapHandler::transformImageMagick: running ImageMagick:) the file "transform_4c3f03fe95f1.jpg" is successfully generated.

So I guess it must be something wrong with the third command. However I didn't get any error message on Putty...

I hope you can help...

PS: If I set $wgUseImageMagick = false; thumbnailing works fine.

Ciencia Al Poder (talkcontribs)

That's strange, because the thumb seems to be created anyway, since at the end it says bad 1499-byte thumbnail "/tmp/transform_4c3f03fe95f1.jpg"

I'm not sure what does the -1 error means. If you can, another thing you can try is to execute that same command but with sudo, as the apache user (or the user executing PHP on the server), to see if it makes any difference. Also check if SELinux or similar may be interfering with that.

Rodrigogodoysi (talkcontribs)

For me, works fine later add the command in LocalSettings.php:

$wgGenerateThumbnailOnParse = true;

NavidBoyWiki (talkcontribs)

Hello Everyone!

I reopen this topic to talk about this possible fix to the problem everyone is facing here. It seems that the Original Poster (OP) might be using a shared hosting service here. Thing is, it appears that ImageMagick is limited in these kind of configurations and that disabling it all together seems to be working (at least for me and some other people). By adding $wgUseImageMagick = false (Like Stefahn said) to your localSettings.php, it will force Mediawiki to use another Thumbnail generation solution (by default GD). And that seems to work well. The reason might be that shared hosting services may limit the methods used by IM and lead to this error.