Bad jpg image quality

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
coldplug

Bad jpg image quality

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Bad jpg image quality

Post 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.
coldplug

Re: Bad jpg image quality

Post 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!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Bad jpg image quality

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
coldplug

Re: Bad jpg image quality

Post by coldplug »

OK, thanks, I will try to avoid .jpg format for intermediate steps.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Bad jpg image quality

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply