Page 1 of 1

Changing Image resolution

Posted: 2020-05-19T09:51:02-07:00
by aamir4774@gmail.com
Hi Community,

I trying to change the resolution of the image by using -density command and using that I'm able to do so. But when I add the "-strip" attribute to the command, the density command doesn't seem to work. (For e.g. if I specify density as 144 then the resolution gets changed to 72 which is perhaps incorrect). Well the reason for using the -strip is because along with other file formats I have TIFFs to change resolution and I need to remove the tagged metadata with the image.

Here's an example command I tried with 300dpi i/p image:

Code: Select all

magick "IP" -density 0144 -strip "OP"
The above command gives the o/p resolution as 72 which is somewhat incorrect. Is -strip command restricting the conversion or something? Can you please help.

Re: Changing Image resolution

Posted: 2020-05-19T10:19:04-07:00
by fmw42
Put the -strip before the -density

Re: Changing Image resolution

Posted: 2020-05-19T10:58:43-07:00
by aamir4774@gmail.com
Yes, that works for the o/p format same as that of input format but for different ones it falls back to 72

Re: Changing Image resolution

Posted: 2020-05-19T11:32:56-07:00
by snibgo
What version of IM, on what platform?

What are your input and output formats?

You might also include "-units".

Re: Changing Image resolution

Posted: 2020-05-19T13:31:56-07:00
by aamir4774@gmail.com
I'm on Windows 7.0.8-62 Q16 x64 version. The input will mostly be jpegs and outputs can differ like jpegs, png, tiff, bmp or psd's.
To my extent -units should be used when resolution is in dots per centimeter format I believe.

Re: Changing Image resolution

Posted: 2020-05-19T14:20:46-07:00
by snibgo
It seems to work fine for me, v7.0.8-64 on Windows 8.1:

Code: Select all

%IMG7%magick rose: -density 300 -units Pixelsperinch x.jpg
%IMG7%magick rose: -density 300 -units Pixelsperinch x.png
%IMG7%magick rose: -density 300 -units Pixelsperinch x.tiff
%IMG7%magick rose: -density 300 -units Pixelsperinch x.bmp
%IMG7%magick rose: -density 300 -units Pixelsperinch x.psd

%IMG7%magick identify -format "%%f %%x %%y %%U\n" x.jpg
%IMG7%magick identify -format "%%f %%x %%y %%U\n" x.png
%IMG7%magick identify -format "%%f %%x %%y %%U\n" x.tiff
%IMG7%magick identify -format "%%f %%x %%y %%U\n" x.bmp
%IMG7%magick identify -format "%%f %%x %%y %%U\n" x.psd

Code: Select all

x.jpg 300 300 PixelsPerInch
x.png 118.11 118.11 PixelsPerCentimeter
x.tiff 300 300 PixelsPerInch
x.bmp 118.11 118.11 PixelsPerCentimeter
x.psd 300 300 PixelsPerInch
x.psd 300 300 PixelsPerInch
If it goes wrong for you, please show an example.

Re: Changing Image resolution

Posted: 2020-05-19T22:00:01-07:00
by aamir4774@gmail.com
Yes it works, but my query here is the density command along with -strip doesn't generate the op image with the specified dpi.

Re: Changing Image resolution

Posted: 2020-05-19T22:22:26-07:00
by fmw42
For what output type? If PNG, it is automatically converted to the equivalent dots per centimeter, since PNG does not support dots per inch.