Page 1 of 1

Generic gamma-corrected thumbnailing

Posted: 2014-07-18T08:25:19-07:00
by jharrison
Hi,

I operate a site which has on the order of 600,000 user-contributed images. We use ImageMagick for thumbnailing purposes.

We've been running

Code: Select all

convert oldimg.jpg -resize 150x150 newimg.jpg
and similar for thumbnailing which has worked okay, but we've noticed issues on some images where gamma is being affected. This is most noticeable on grayscale images (images are washed out).

In all my investigation of this I've found lots of guides on how to correctly convert to RGB and then back to sRGB after resizing and so on, or using -distort Resize in concert with that, but I have yet to find a way to correct gamma/colorspace generically. This being user-generated content there's a smorgasbord of different source colorspaces and formats and bit depths etc.

Is there a way to signal to convert that gamma, colorspace etc should be preserved when resizing, or a way to generically convert from colorspaces to a consistent output colorspace, without needing to first look at the source image and pick from a list of recipes to correctly resize without issue?

I'm using Wheezy's packages (6.7.7-10 2014-03-08 Q16/OpenMP). The issue of grayscale stuff not being corrected when resized does seem to be a regression from my Precise test box, which works fine with 6.6.9-7 2014-03-06 Q16/OpenMP, and may be a bug, but I wouldn't know how to confirm this/report it as such).

Re: Generic gamma-corrected thumbnailing

Posted: 2014-07-18T09:14:08-07:00
by snibgo
You are running very old versions. I suggest you upgrade to current IM.

If you can't upgrade, then it may help to know that in some old versions, around the date of yours, IM would convert gray images to linear RGB rather than non-linear sRGB. You may find that ...

Code: Select all

convert oldimg.jpg -resize 150x150 -set colorspace RGB newimg.jpg
... does the trick.

Re: Generic gamma-corrected thumbnailing

Posted: 2014-07-18T09:55:06-07:00
by fmw42
snibgo is referring to the information at viewtopic.php?f=4&t=21269