Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to resize a bunch (450+) of images through imagemagick, they all start at 500x500 and I've written a script to resize them to about 5 different sizes.

Now I've converted them I notice that the colour quality takes a noticeable hit. Is there anything I can change in my command to increase quality a little?

Command: convert input.jpg[0] -background black -density 72 -resize 440x440 -quality 100 -strip output.jpg

I can't upload the actual file but here is a cropped version (with padding)

enter image description here

enter image description here

share|improve this question
try using xnview instead – Sickest Feb 10 '14 at 9:39
Can you please provide an original jpg file? I cannot reproduce the color change with the png file in your question. – mpy Feb 10 '14 at 9:47
Which operating system? You could try GraphicsMagick, an improved fork of ImageMagick. – harrymc Feb 10 '14 at 9:51
@mpy I've updated the question with actual jpgs, sorry about the white space! – Jamie Taylor Feb 10 '14 at 9:56
You use the -strip option, which removes the color profile which is present in the original jpeg. If I omit this strip, the resulting file has the same vivid colors -- given the image viewer uses the color profile. What is the purpose of -strip here? And, is your question more like: How to display the image w/o color profile as close to the original as possible? (However, I couldn't answer that one...) – mpy Feb 10 '14 at 10:25
up vote 3 down vote accepted

You use the -strip option, which tells convert to

strip the image of any profiles or comments.

This includes the color profile. Hence, in image viewers that do use the embedded color profile output.jpg will look differently as input.jpg when using

convert input.jpg -background black -density 72 -resize 440x440 -quality 100 -strip output.jpg 

So, omitting the -strip option is the easiest way to get the same colors in output.jpg:

convert input.jpg -background black -density 72 -resize 440x440 -quality 100 output.jpg 

Another possibility is the following -- if you want to get rid of any comments, but preserve the colors:

  1. Extract the color profile.
  2. Strip all metadata with jpegtran from the debian package libjpeg-progs (lossless operation).
  3. Resize the image and incorporate the color profile again.

    convert input.jpg colorprofile.icc
    jpegtran -copy none input.jpg > input_stripped.jpg
    convert input_stripped.jpg -profile colorprofile.icc -background black -density 72 -resize 440x440 -quality 100 output.jpg 
share|improve this answer
Thanks, I'll award the bounty as soon as the option becomes available! – Jamie Taylor Feb 10 '14 at 11:14
@JamieTaylor : Thanks, but take your time... perhaps someone has a better option for you, nobody of us thinking about at the moment. – mpy Feb 10 '14 at 11:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .