Page 1 of 1

Bad jpg image quality

Posted: 2007-10-08T14:59:20-07:00
by coldplug
Hi!

I wrote a bash script that draw borders around images. But, after executing set of commands, image quality get much worse. Script is:

Code: Select all

#! /bin/bash

mkdir bordered
cp *.jpg ./bordered
cd bordered
mogrify -border 1x1 -bordercolor "rgb(0,0,0)" *.jpg
mogrify -border 8x8 -bordercolor "rgb(255,255,255)" *.jpg
mogrify -border 2x2 -bordercolor "rgb(0,0,0)" *.jpg
mogrify -border 2x2 -bordercolor "rgb(255,255,255)" *.jpg
mogrify -border 2x2 -bordercolor "rgb(0,0,0)" *.jpg
mogrify -border 8x8 -bordercolor "rgb(255,255,255)" *.jpg
mogrify -border 1x1 -bordercolor "rgb(0,0,0)" *.jpg
Results:

Original:
http://img128.imageshack.us/img128/812/ ... t01ig5.jpg

Result (much worse, look for example at red colored parts of image)
http://img505.imageshack.us/img505/171/ ... t01hy0.jpg

Can I do something here to retain image quality and get borders like that one?

Thanks in advance,
Ivan

Re: Bad jpg image quality

Posted: 2007-10-09T00:08:28-07:00
by Bonzo
I would say your problem is jpg compression. You can set the quality to 100 ? as the standard for jpg is 85 ?

Also try either reading your image in once and do all the modifications or save the tempory files to png format.

I think Anthony has some custom border examples on his site that may work http://www.imagemagick.org/Usage/crop/ but you will have to find them.

Re: Bad jpg image quality

Posted: 2007-10-09T05:27:43-07:00
by coldplug
Although it also looks to me like high jpeg compression, I think, jpg -quality setting is not an issue, because, original and bordered photos are set to -quality 98 (I read that in GIMP). Also, resulting photo is bigger than original in kbytes.

I tried to make all borders in one line, and result is unfortunately same like before :(

Still I'm not sure why would I use png format? Isn't it very limited in number of colors? Do you meant tif instead of png?


Thanks for help!

Re: Bad jpg image quality

Posted: 2007-10-09T21:53:20-07:00
by anthony
It does just look like JPG image compression, it is JPEG image compession.

For other non-loossy image formats you would have no problem.

Setting a -quality to 100% helps but does not solve this problem.

The only solution is. Never use JPEG for intermediate processing of images!
Best format is MIFF, though if you like a more normal intermediate format PNG can also be used.

Re: Bad jpg image quality

Posted: 2007-10-10T10:37:47-07:00
by coldplug
OK, thanks, I will try to avoid .jpg format for intermediate steps.

Re: Bad jpg image quality

Posted: 2007-10-10T19:48:12-07:00
by anthony
I would also preserve the original image, as a starting point for future image modifications. Or better still start with (and preserve) the most original versions of those images you have.