Page 1 of 1

Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T14:17:05-07:00
by helloworld
Hello All,

We are upgrading our system from GM to IM and i installed IM latest version 6.8.8-2 (for more info you check below),

Version: ImageMagick 6.8.8-2 Q16 x86_64 2014-01-24 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff x xml zlib

Basically, what we want to do is, whenever a person uploads a original image we need to resize that image to a fixed pixels size like 1200x12000 and then reduce the Resolution to 72 DPI and last step is reduce the quality to 75. I wanted to do the whole process by executing in a single command. SO for that i am using a command like below, Can you look and let me know if that is correct or not?

convert image -resize 1200x1200 -density 72 -quality 75 resultimage

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T15:00:05-07:00
by snibgo
"-resize 1200x12000" will reduce images taller than 1200 or wider than 12000 so they fit in a box 1200x12000. It won't enlarge.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T15:15:17-07:00
by helloworld
Sorry its 1200x1200 not 1200x12000

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T16:58:14-07:00
by fmw42
convert image -resize 1200x1200 -density 72 -quality 75 resultimage
That should work fine and is about as compact as you can get. If you do not need any meta data, you can reduce the file size by adding -strip

You do not say what file format. PNG does not support dpi only dpc. So you may want to add the appropriate units. For png output the density and units will then be converted to dpc from dpi.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T22:06:19-07:00
by helloworld
Cool Thanks Fred.

Most probably we use jpg and jpeg formats. I think for these two formats all the commands (-resize, -density -quality) should work fine right?

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T22:07:06-07:00
by helloworld
In the old system we are using a command like below,

convert image -verbose -resize 1200x1200 -quality 75 +profile * +comment resultimage

i am not sure what is +profile and +comment. Can you please explain what is +profile and +comment and why we use use this?

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-28T22:22:23-07:00
by fmw42
+profile is used to remove any profile data. But I think you need to express it as +profile "*". See http://www.imagemagick.org/script/comma ... hp#profile

I am unaware of +comment. see http://www.imagemagick.org/script/comma ... hp#comment. I do not know any way to remove comments explicitly. I tried several variations. You can use -set comment "" to empty the field, but it still shows an empty comment filed.


You can also use -strip to remove any meta data, including profiles and comments.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-29T11:44:21-07:00
by helloworld
I am trying to execute a command like below to change the DPI, Resize, Quality and removing profile and comment

convert input.jpg/jpeg/tiff/png/tif -density 72 -verbose -resize 1200x1200 -quality 75 +profile "*" +comment output.jpg

My first question is, The command which i am using is correct or not and
Second question is, On what order the command is executed, what i mean is, first it will reduce the DPI to 72 then resize it to 1200x1200 and then change the quality or is it follow any different order the reason why i am asking is if we follow different order then there is change of changing the pixels size.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-29T12:41:42-07:00
by fmw42
helloworld wrote:I am trying to execute a command like below to change the DPI, Resize, Quality and removing profile and comment

convert input.jpg/jpeg/tiff/png/tif -density 72 -verbose -resize 1200x1200 -quality 75 +profile "*" +comment output.jpg

My first question is, The command which i am using is correct or not and
Second question is, On what order the command is executed, what i mean is, first it will reduce the DPI to 72 then resize it to 1200x1200 and then change the quality or is it follow any different order the reason why i am asking is if we follow different order then there is change of changing the pixels size.

The command is not proper. There is no +comment. You should remove all meta data that you want before resizing (for efficiency), then set the density and quality.

I would just do

convert input.jpg/jpeg/tiff/png/tif -verbose -strip -resize 1200x1200 -quality 75 -density 72x72 -units pixelsperinch output.jpg


Density does not apply until the end as does -quality (after the resize), but the placement should not matter. However, I try to do things in linear, logical order as appropriate to proper syntax. The density will not affect the resize and waits to be set until the image is written out.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-29T13:31:24-07:00
by helloworld
Thanks a lot fred for explaining me very clearly.

convert input.jpg/jpeg/tiff/png/tif -verbose -strip -resize 1200x1200 -quality 75 -density 72x72 -units pixelsperinch output.jpg

May i know why you used -strip and why you removed +profile "*" in the command above.

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-29T14:13:58-07:00
by fmw42
-strip removes all meta data, including profiles and comments. So there is no need to include +profile.

see
http://www.imagemagick.org/script/comma ... .php#strip

Re: Resizing, Resolution and Quality in a single command

Posted: 2014-01-29T15:37:03-07:00
by helloworld
Perfect. The command which you gave me works extra ordinary.