Last modified: 2010-09-30 00:54:49 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26857, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24857 - New thumbnails are not sharp
New thumbnails are not sharp
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Tim Starling
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-18 17:32 UTC by Ryan Kaldari
Modified: 2010-09-30 00:54 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ryan Kaldari 2010-08-18 17:32:06 UTC
Previously, whenever thumbnails were generated by ImageMagick, the sharpen option was used. This was especially helpful for small thumbnails of detailed images. It appears that this option may have recently been turned off judging by the softness of newly generated thumbnails.

New thumbnail (soft):
http://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Russian_Empire-Full_coat_of_arms.3.jpg/219px-Russian_Empire-Full_coat_of_arms.3.jpg

Cached old thumbnail (sharp):
http://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Russian_Empire-Full_coat_of_arms.3.jpg/220px-Russian_Empire-Full_coat_of_arms.3.jpg

This seems to have changed around the time of the recent ImageMagick update.
Comment 1 Derk-Jan Hartman 2010-08-19 15:11:12 UTC
Perhaps syntax change in imagemagick commandline ?
Comment 2 Ryan Kaldari 2010-08-19 17:57:33 UTC
The correct current syntax is using the -unsharp option after the -thumbnail option. I think previously we were using a radius of 0.8 or something like that, so:
convert original.jpg -thumbnail 250x90 -unsharp 0.8 thumbnail.jpg

I have no idea if this is different than older syntaxes or what syntax we're using currently.
Comment 3 Ryan Kaldari 2010-08-19 18:25:05 UTC
Ah, looks like the old syntax was -sharpen (which is a much more logical name). Apparently they're using an unsharp masking algorithm to do the sharpening now, so they decided they had to change the option name while they were at it!

I've fixed it in r71304.
Comment 4 Ryan Kaldari 2010-08-19 18:43:22 UTC
Nevermind, we should be able to use -sharpen or -unsharp and they both should accept the parameter we're using (0x0.4). Hmm, back to the drawing board.
Comment 5 Ryan Kaldari 2010-08-19 18:45:42 UTC
reverted self in r71309.
Comment 6 Ryan Kaldari 2010-08-19 19:08:28 UTC
Maybe someone with command line access to our ImageMagick could do some tests and find out what's going on with it, i.e. test using 'convert -thumbnail' with -sharpen on and off, and then test it with -unsharp on and off, and see if there are any differences in the output files.
Comment 7 Tim Starling 2010-08-20 08:06:05 UTC
The issue is an arbitrary change in SharpenImageChannel() made some time between ImageMagick 6.4.9 and 6.5.1. The relevant code changed from this:

      alpha=exp(-((double) u*u+v*v)/(2.0*MagickSigma*MagickSigma));
      kernel[i]=(double) (-alpha/(2.0*MagickPI*MagickSigma*MagickSigma));
      if ((width < 3) || (u != 0) || (v != 0))
        normalize+=kernel[i];

To this:

      alpha=exp(-((double) u*u+v*v)/(2.0*MagickSigma*MagickSigma));
      kernel[i]=(double) (-alpha/(2.0*MagickPI*MagickSigma*MagickSigma));
      normalize+=kernel[i];

The result is that for a given sigma, images look more blurry in the new convert. Based on brief testing, to reproduce a result similar to the old 0x0.4 requires a sharpen parameter of approximately 0x0.8 in the new ImageMagick. 

Both -unsharp and -sharpen exist in both versions, and have completely different implementations. Unsharp does not appear to have changed significantly, so it might be a candidate for version-independent operation in the next MediaWiki release. But for now I will just change our configuration to use 0x0.8 instead of 0x0.4.
Comment 8 Ryan Kaldari 2010-08-21 00:47:34 UTC
Nice sleuthing!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links