Topic on Project:Support desk

Jump to: navigation, search

[RESOLVED] Error creating thumbnail: Unable to save thumbnail to destination

15
Summary by Razool

I found a sollution. Permission issue

193.219.83.135 (talkcontribs)

Hello, I'm running Mediawiki 1.19.0 on IIS7 (win server 2008, php 5.4.3 and mysql 5.5.24) and it doesn't generate any thumbnail. I tried ImageMagick 6.6.7 and also GD version ($wgThumbnailScriptPath = "{$wgScriptPath}/thumb.php";) but I'm still getting this error. Full image works, but not thumbnail. There is granted all permissions to "images" folder (as uploading files works). Thank you.

Woozle (talkcontribs)

I'm having the same problem with MW 1.19.0 on Apache/MySQL/Ubuntu -- I just upgraded from 1.18.x. What's more annoying is that sometimes the thumbnails are actually there until I refresh the File page...

Woozle (talkcontribs)

I dove into the code and figured it out. The exact problem may be different from server to server, but in my case the problem was occurring at this line in /includes/filerepo/backend/TempFSFile.php:

$newFileHandle = fopen( $path, 'x' );

The value of $path is partly based on the global wfTempDir() function, defined in /includes/GlobalFunctions.php. This function does several checks to find a good temp folder for creating images; on my system, it failed to find anything in the environment and was falling back to sys_get_temp_dir(), which told it to use "/tmp".

This should have been valid, because that folder is world-writable and there are in fact temp files there... but when I told fopen() to use a different path, it started working.

What I did was to explicly set, in LocalSettings.php, one of the environment variables to point to a temp directory I had created in my account space:

putenv('TMPDIR=/path/to/my/temp/folder');

After that, everything was happy again.

213.125.5.74 (talkcontribs)

/includes/filerepo/backend/TempFSFile.php seems to have moved, there is no /backend folder in /filerepo

C.C. Principalis (talkcontribs)

Looks like it's moved to /includes/filebackend/TempFSFile.php.

Also, Woozle's solution appears to have worked for me, as well.

Woozle (talkcontribs)

It would be nice if MW would report an error when it can't write to the folder it is using for temporary files. Should I file this as a bug report?

195.7.78.165 (talkcontribs)

I had a similar problem. Turned out that C:\Windows\Temp was not in open_basedir (set in php.ini). Found the problem by checking php-errors.log

62.198.242.174 (talkcontribs)

Put the absolute path to your tmp folder. Works like a charm

$wgTmpDirectory = "/home/username/mysitename.com/wiki/images/temp";

69.55.64.37 (talkcontribs)

I just ran across this problem as well while upgrading to 1.20.5. But I had this set in LocalSettings.php:

$wgTmpDirectory = "{$wgUploadDirectory}/tmp";

I solved it by commenting this line out completely. I assume I was trying to get around some prior bug. But now mediawiki finds the tmp directory without a problem. So my solution was to remove this (old) setting.

194.254.225.35 (talkcontribs)

Thanks !

223.205.216.166 (talkcontribs)

For me this settings in LocalSettings.php worked:

$wgEnableUploads = true;

$wgUseImageMagick = false;

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

$wgTmpDirectory = "$IP/images/temp";

and create "temp" folder in /images

Seb35 (talkcontribs)

I also encountered this issue and removed the old setting. Thanks!

92.31.153.47 (talkcontribs)

No matter what I tried in LocalSettings.php, the temp directory which was being used was "$IP/images/tmp" (even when $wgTempDirectory was set to something else). I solved the problem by creating this directory and making it writable.

Razool (talkcontribs)

My issue was a little different.

After switching hosting services, I could see the images thumbnails uploaded from old server but not those uploaded on the new one

On those not displayed was getting the error Unable to save thumbnail to destination

After I tried everything I could find on google

  • Setting in LocalSettings.php:
    • $wgTmpDirectory = "$IP/images/temp";
    • putenv('TMPDIR=/var/www/www.example.com/image');
    • $wgShellLocale = "en_US.UTF-8";
    • $wgUseImageMagick = false;
  • Issue with GD on CentOS: yum install gd gd-devel php-gd
  • Permissions chmod 777 on image folder

I fixed the issue by editing the affected pages wihtout doing any changes and saving

Even if it seems dumb... I think the permissions had something to do with this also