Live data from Hacker News

Using ImageMagick to make sharp web-sized photographs

even.li

41–50 of 64 posts

Re: Using ImageMagick to make sharp web-sized photographs

#41

It'd be great if you put two in this post so we can see the difference without having to run all of the commands first.

Apparently if you mouse over the image, the sharpened image overlays the original (no I didn't pick that up either, it was mentioned on another comment :)

Re: Using ImageMagick to make sharp web-sized photographs

#42
post #6

Part of the reason rescaled images look dim and blurry is because rescaling software usually assumes gamma 1.0 instead of 2.2: http://www.4p8.com/eric.brasseur/gamma.html There are many more good essays on image rescaling here: http://entropymine.com/imageworsener/

It's because downscaling is technically a digital filter, so it can smooth the signal and cause ringing artifacts.

Re: Using ImageMagick to make sharp web-sized photographs

#44
post #39

Has anyone played / tested this with regard to the responsive image hack/trick by the filament group : http://filamentgroup.com/lab/rwd_img_compression/

I've actually started using this method, and it seems to work pretty well. It reduces file sizes significantly and yet the quality is fairly good. If you pay attention, you can see some quality loss/artifacts, though it's not bad.

An example:

http://www.andrewmunsell.com/blog/

Scroll down to the "Now is the Future" blog post. The cover image of the Seattle skyline is 1700x666 and ~65kb (though, it's been recompressed into WebP by mod_pagespeed if your browser supports it). The JPG (before WebP conversion) is ~88kb.

To see it without the recompression and turn mod_pagespeed off, you can look at the image on the page:

http://www.andrewmunsell.com/blog/?ModPagespeed=off

Re: Using ImageMagick to make sharp web-sized photographs

#45
In my experience, scaling down an image makes it look sharper. A blurry image will often look perfectly fine when sufficiently scaled down; which is not surprising, because a blur with a five-pixel radius at camera size can easily become a fraction of a pixel at web size. Similarly, scaling down counteracts camera noise, because each output pixel averages out the noise between several different sensor pixels.

Of course, you can always make them even sharper with filters if you want.

Re: Using ImageMagick to make sharp web-sized photographs

#46
post #6

Part of the reason rescaled images look dim and blurry is because rescaling software usually assumes gamma 1.0 instead of 2.2: http://www.4p8.com/eric.brasseur/gamma.html There are many more good essays on image rescaling here: http://entropymine.com/imageworsener/

Preview.app in OS X scales the picture correctly. I think any program that uses Cocoa/CoreImage/CoreGraphics etc. to scale images on OS X should get the right result.

However, Safari ignores gamma and produces a flat gray rectangle when scaling down the Dalai Lama image, like Firefox does. I seem to remember that Safari used to do proper gamme correction in earlier versions, but they were pressured to abandon it because it was more important to give the result expected by websites.

Re: Using ImageMagick to make sharp web-sized photographs

#47
post #32
post #23

Earlier quoted context omitted.

I agree: that jumped out at me enough that I came here to make the same comment. I can hardly think of a case where I'd want to use a 98 quality setting on a JPEG. Maybe it would be a good choice if I wanted to preserve an almost-pristine copy of an original, but I'd compare the resulting file size to a lossless PNG first. Every quality step from 100 down to 95 gives a huge benefit in file size, and going from 95 to…

This also jumped out at me. My company ( http://www.firebox.com ) is built on having amazing looking images for products. No one could see any difference between the quality of images between 87 and 95, but it saved us roughly 50% in file size. Also for what it's worth, we spent a lot of time a/b testing 87 vs 95 with our users, but there was no conclusive difference

We use GraphicsMagick at 92, as dipping into the 80s has an annoying tendancy to introduce visible noise on something like 1:50 images. It's very annoying to ship that extra bandwidth.

Interestingly, we've done WebP support, and while the files are smaller across the board, visual quality deteriorates really quickly once you start dropping that quality value, even in small increments.

Re: Using ImageMagick to make sharp web-sized photographs

#48
Dissecting a bad oneliner:

    ls *.jpg|while read i;do gm convert $i -resize "900x" -unsharp 2x0.5+0.5+0 -quality 98 `basename $i .jpg`_s.jpg;done
The part I take issue with is the unnecessary invocation of `ls`. The shell does the glob expansion. A `for` loop is better suited for this. Also, if using bash,* we can get rid of basename.

    for file in *.jpg; do gm convert $file -resize "900x" -unsharp 2x0.5+0.5+0 -quality 98 ${file%.jpg}_s.jpg; done
* zsh fans, I'm sure it works there too.

Re: Using ImageMagick to make sharp web-sized photographs

#49
post #17

My solution: https://github.com/vladstudio/Vladstudio-smart-resize-Bash-s... The 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;…

This is fine if you have a limited set of images that you handpick and optimize. Do you have any suggestions when there are thousands of images and all this needs to be automated?

Use GNU parallel: https://www.gnu.org/software/parallel/

It can distribute the work across the available CPU cores, and it can even distribute the work across different machines using SSH: https://www.gnu.org/software/parallel/man.html#example__dist...

Post reply on HN