Using ImageMagick to make sharp web-sized photographs
1–10 of 64 posts
Re: Using ImageMagick to make sharp web-sized photographs
#2The biggest problem of scaling down an image is to find right settings for resampling and sharpening. After many expreiments, I found it impossible to achieve good results by simply running convert with a line of arguments. So I came up with this script, which basically does the following:
* configures -interpolate bicubic -filter Lagrange; * resizes source image 80%; * applies -unsharp 0.44x0.44+0.44+0.008; * repeats steps 2 & 3 until target size is reached.
Re: Using ImageMagick to make sharp web-sized photographs
#3Re: Using ImageMagick to make sharp web-sized photographs
#4The advantages of having correctly sized imagery are immense, but in short.. something like 70% smaller total byte payload for mobile, huge reduction in image decode & resize cost, better scroll performance, and faster relayouts when orientation changes or browser window changes.
(And I do think browsers themselves should resample scaled images like this to achieve equal quality, but your users will benefit way more if assets are delivered well to begin with.)
Re: Using ImageMagick to make sharp web-sized photographs
#5for image in *.jpg ; do gm convert $image -resize "900x" -unsharp 2x0.5+0.5+0 -quality 98 `basename $image .jpg`_s.jpg ; done
Re: Using ImageMagick to make sharp web-sized photographs
#6There are many more good essays on image rescaling here: http://entropymine.com/imageworsener/
Re: Using ImageMagick to make sharp web-sized photographs
#7Re: Using ImageMagick to make sharp web-sized photographs
#8Just for the record, the "unsharp mask" filter doesn't really sharpen but it increases edge contrast, which makes it seem sharper. It is something that you should only apply to the final version of an image, after all resizing has been done, however.
Unsharp masking is mostly aesthetic. For an image like the example, a mountainside, it gives you a feeling of crisp details, but there isn't any more data there. It looks great on a landscape, but it can be disastrous on a portrait of a person (pores and stubble will be highlighted, usually in an unpleasant way).
(EDIT: incorrect assertion about unsharp masking before or after scaling removed)
Sometimes it's better to unsharp-mask it to a degree that looks slightly oversharpened at a large size, but looks great when reduced - especially for very small images, like avatars or other icons.
Re: Using ImageMagick to make sharp web-sized photographs
#9Re: Using ImageMagick to make sharp web-sized photographs
#10I think the script to apply it to a folder could be clear with: for image in *.jpg ; do gm convert $image -resize "900x" -unsharp 2x0.5+0.5+0 -quality 98 `basename $image .jpg`_s.jpg ; done
Neither of them deal with filenames with \n in them, eg 'pretty
sunset.jpg'
For that, you'll want to run find:
find . -name '*.jpg' -exec convert '{}' -resize "900x" -unsharp 2x0.5+0.5+0 -quality 98 `basename '{}' .jpg`_s.jpg \;