how to maintain quality of Source image after conversion

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
pranay.samarth
Posts: 1
Joined: 2011-08-07T23:59:01-07:00
Authentication code: 8675308

how to maintain quality of Source image after conversion

Post by pranay.samarth »

Hi,

In my application (java based), I have to convert given image (.jpg only) from user to below 4 sizes and need to maintain the quality of the converted image same as originally supplied by user.

I am using below command -
convert -geometry 470x580 -unsharp 1.0x1.0+1.0+0.10 -quality 90 -map /sourceDirectory/colortable.gif /sourceDirectory /abc.jpg /targetDirectory/abc_size1.jpg

Issue – is there any way I can identify optimum size for the source image (user can share in aay size) so that I can apply above command for size changes and maintain the same quality.

Size 1 -
imageconversion.SMALLIMAGEHEIGHT=60
imageconversion.SMALLIMAGEWIDTH=40

Size2 -
imageconversion.NORAMLIMAGEHEIGHT=160
imageconversion.NORAMLIMAGEWIDTH=106

Size 3-
imageconversion.LARGEIMAGEHEIGHT=580
imageconversion.LARGEIMAGEWIDTH=470

Size 4 -
imageconversion.BANNERIMAGEHEIGHT=110
imageconversion.BANNERIMAGEWIDTH=100

Regards,
Pranay
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to maintain quality of Source image after conversion

Post by fmw42 »

Any time you go from jpg to jpg you will lose quality as it needs to be decompressed and then recompressed and the quality may change due to different compression algorithms and quality settings between the input and output.

Also your syntax is old. Put your input image right after convert.

see http://www.imagemagick.org/Usage/basics/#why

also see http://www.imagemagick.org/script/comma ... hp#quality about default quality in jpgs

also your -geometry is doing nothing. Do you mean -resize? or -crop?

also I don't know that -map works on jpegs as it has too many colors, but I am not sure of that. I thought it was for use with gifs that have only 256 colors max.

Perhaps you can explain your command; that is what you are trying to do function by function.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how to maintain quality of Source image after conversion

Post by anthony »

-map works with any image. However JPEG will not store the exact colors that you mapped your image to! As such it is not generally useful with JPEG output.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply