Page 1 of 1

jpeg converted image get bigger than the original jpeg?

Posted: 2013-11-27T14:03:56-07:00
by buncee
I'm new to ImageMagick so pardon me if this is a really stupid question.

I ran the command :
convert -format %w,%h, input.jpg -resize MxM> -identify output.jpg

where M is the longest dimension of the image, say the input is 1024x768, then M=1024, so I'm assuming the dimension of output image will be the same (and it is). However the image size get larger after converted. Say the input is 845941 bytes, the converted image using this command is 901649 bytes. Why is this?

I'm using ImageMagick 6.8.2 and the test input images are Windows sample pictures (the JPEGs that come with the Windows system).

Another question, I've heard that when ImageMagick do convert, it removes the header of the image. Is this true?

Thanks.

Re: jpeg converted image get bigger than the original jpeg?

Posted: 2013-11-27T14:13:19-07:00
by snibgo
IM reads the jpeg and decompresses it, does any processing, then re-compresses and writes it. You can adjust the amount of compression (and hence the quality) with "-quality".

However, jpeg is a lossy compression method. Everytime you read and write in jpeg, you always lose quality.
Another question, I've heard that when ImageMagick do convert, it removes the header of the image. Is this true?
I don't even know what it means.

IM is wonderful at processing images but doesn't bother much about metadata. See the recent thread viewtopic.php?f=1&t=24537

Re: jpeg converted image get bigger than the original jpeg?

Posted: 2013-11-27T15:15:53-07:00
by Bonzo
Another question, I've heard that when ImageMagick do convert, it removes the header of the image. Is this true?
What happened when you tried it?

If you -resize no data is stripped unless you specify -strip and then the EXIF data etc. is removed ( I can not remember if the colour profile is stripped ). If you use -thumbnail it is the same as using -resize and -strip.