Generic gamma-corrected thumbnailing

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jharrison
Posts: 1
Joined: 2014-07-18T08:16:30-07:00
Authentication code: 6789

Generic gamma-corrected thumbnailing

Post 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).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Generic gamma-corrected thumbnailing

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Generic gamma-corrected thumbnailing

Post by fmw42 »

snibgo is referring to the information at viewtopic.php?f=4&t=21269
Post Reply