Page 1 of 1
Unsharp not working on Linux Host
Posted: 2009-11-09T17:11:33-07:00
by cycletourist
Using Php scripts, I create thumbnails for uploaded images with the following command:
convert -size 250x250 "IMG_5244.jpg" -resize 125x125 -strip -unsharp 0.2x0.6+1.0 -quality 87 "IMG_5244_th.jpg"
When I run this on my local machine (Windows XP SP2 - ImageMagick 6.2.9 09/27/06 Q16), the unsharp mask works beautifully to give me a crisp looking thumbnail
When I run it on my remote host (Linux - Kernel version 2.6.9-67.0.15.plus.c4hugemem - ImageMagick 6.0.7 07/25/08 Q16), the unsharp mask has no effect.
I know these are older version of ImageMagick, but I hesitate to update because the last time I did it broke a lot of my Php scripts that use ImageMagick (using strip instead of profile is one difference I remember). I've asked my host to upgrade, but they are reluctant to do so, as they encounter problems when doing so (and my scripts might, too).
Has anyone any idea why unsharp works on my Windows machine, but no on the Linux machine?
Chuck
Re: Unsharp not working on Linux Host
Posted: 2009-11-09T17:56:39-07:00
by anthony
The use of -size as a hint to the JPG library has changed.
This was because the normal usage of -size for image creation operators like xc: and label: was confusing others when thay also then read in a JPG image.
The JPEG read size hint is now provided as -define jpeg:size=250x250
However that really should not effect your command very much.
Your -unsharp operator however is not defined properly.
The first argument 0.2 should be an integer, not a float. It represents the square neighbourhood limits of the operator. That is '1' would mean the centeral pixel plus its immediate neighbour pixels.
It would be rounded up automatically by IM.
Better still using '0' automaticaly definates a neighbour hood based on the effects of the 'guassian' blur function that unsharp uses to 'sharpen' each pixel. But it also defines a minimal neighbour hood of 5 pixels around each pixel.
As such -unsharp 2x0.6+1.0 would be better.
As for the actual problem BOTH windows and linux should produce exactly the same results.
Can you provide some small example images (crop part of a larger image, don't give us a huge image) with both input and results under windows and linux versions. That way we can test out and see what is happening, comparing them to your results.
Pointing out exactly what you expect may also be of help.
Please provide a smaller cropped image os some detail (such as face and eyes, or other detail), and give them as PNG not JPG so we can avoid any 'lossy JPG' artefacts that may interfere with result.
Nothing can be done unless we can see what is going on.
Re: Unsharp not working on Linux Host
Posted: 2009-11-09T23:20:58-07:00
by cycletourist
Thanks for the detailed reply. Not sure what got me to use a float for the the first part (the radius?). I have changed it to use 2 (2x0.6+1.0), as you suggested. I still get the same result.
What's the best way to provide the examples? Can I email them somewhere, attach them here, or do you want me to put them on a web page?
Re: Unsharp not working on Linux Host
Posted: 2009-11-10T10:58:12-07:00
by fmw42
best way is to post them to your own web site or public image web site and then put a link here to the images.
Re: Unsharp not working on Linux Host
Posted: 2009-11-10T21:22:51-07:00
by anthony
Make sure you post a smaller cropped version of some area of detail. no need to give us the whole large image. and save it as PNG in your test examples so as to avoid any JPG lossy problems.
We had a simper recent discussion problem almost exactly like what you describe which ended up to be caused by the change from -size to -define for the JPEG size hinting.
Re: Unsharp not working on Linux Host
Posted: 2009-11-11T19:32:36-07:00
by cycletourist
Okay ... thank you for your patience.
I'm not sure if this will suffice, but it will certainly do for starters:
http://cycletourist.com/temp/
Note: I use this generic temp page so I don't end up with 404's later when I remove this ... you'll see. And I hope you don't mind the flipped image on the index page. I couldn't help myself. ô¿Ô¬ The linked page has the source image and the untouched thumbnails (saved as pngs) as they were saved by ImageMagick.
Note that I already changed the convert options to use "-define jpeg:size=..."
I did not do any cropping, but did not think it necessary as the source image is not large and the resultant images are small thumbnails.
If this does not do, let me know what you need.
Chuck
Re: Unsharp not working on Linux Host
Posted: 2009-11-11T20:33:46-07:00
by anthony
I downloaded the image, and ran your command under linux
Version: ImageMagick 6.5.7-5 2009-11-05 Q16
http://www.imagemagick.org
I then
flicker compared my result with your windows version and it came out visually identical. I could see no difference between the PNG images, and flicker compares often pick up things you would otherwise miss.
Doing a compare using PAE (peak absolute error)
Code: Select all
compare -metric PAE my_result.png IMG_5249_th_windows.png null:
retruned 0.042008 with a MAE (mean absolute error) of 0.000967643
Very very close match.
Comparing your windows image with the linux noe you generated returned
PAE of 0.285786 and MAE of 0.0158917 whcih is a very substantial difference.
Your version number for linux is 6.0.7 which is very very very old. Thier have been an enormous number of changes since then, including in the resize code. As such I think you really need to upgrade.
ASIDE: I also did a flicker compare between a image generate without the JPEG size hint and had exactly the same result.
I though that was weird so I checked the returned image size for your 800x600 input image with a 350x350 size hint. The result was the whole image with not size reduction. That was understandable. I am sure however that it would make a difference for larger original digital camera images (reducing memory requirements with minimal quality loss).
Re: Unsharp not working on Linux Host
Posted: 2009-11-11T20:50:18-07:00
by cycletourist
Thank you for the thorough analysis.
I'll do two things. I *will* ask my web host to upgrade (not sure why they say it is problematic, as I recall it merely overwrites the old version and should then simply work). Hopefully this will solve my problem (although, I think unsharp *was* working before their last upgrade ... ?). I'll post back if that does not solve my problem.
And I should probably upgrade, too. Perhaps a bit off topic here, but do you know off-hand if upgrading from ImageMagick 6.2.9 to ImageMagick-6.5.7-7 will necessitate changes to my existing convert command options? I hate having to fix broken code.
Chuck
Re: Unsharp not working on Linux Host
Posted: 2009-11-11T20:55:59-07:00
by anthony
Should not be a lot.
The -size to -define change was in IM version v6.5.6-0 so both your current versions did not need that change. The resize filter recoding was in version IM v6.3.7-1 but there were others between
your linux v6.0.7 to your windows v6.2.9
IM is pretty good in general backward compatibilty over version 6.
Re: Unsharp not working on Linux Host
Posted: 2009-12-16T19:58:21-07:00
by cycletourist
So .... here we are one month later.
My unsharp problem has been solved. My host finally compiled and installed the latest version of ImageMagick (ImageMagick 6.5.8-5 2009-12-12 Q16) and that did the trick. I have no idea what the previous problem was (prior versions to the last one they had did work). Oh well .... water under the bridge.
Thanks for all your help.
Chuck