I want to change DPI with Imagemagick without changing the actual byte-size of the image data
Posted
by
user1694803
on Super User
See other posts from Super User
or by user1694803
Published on 2012-09-24T15:35:33Z
Indexed on
2012/09/25
3:41 UTC
Read the original article
Hit count: 555
I feel so horribly sorry that I have to ask this question here, but after hours of researching how to do an actually very simple task I'm still failing...
In Gimp there is a very simple way to do what I want. I only have the German dialog installed but I'll try to translate it. I'm talking about going to "Picture->PrintingSize" and then adjusting the Values "X-Resolution" and "Y-Resolution" which are known to me as so called DPI values. You can also choose the format which by default is "Pixel/Inch". (In German the dialog is "Bild->Druckgröße" and there "X-Auflösung" and "Y-Auflösung")
Ok, the values there are often "72" by default. When I change them to e.g. "300" this has the effect that the image stays the same on the computer, but if I print it, it will be smaller if you look at it, but all the details are still there, just smaller -> it has a higher resolution on the printed paper (but smaller size... which is fine for me).
I am often doing that when I am working with LaTeX, or to be exact with the command "pdflatex" on a recent Ubuntu-Machine. When I'm doing the above process with Gimp manually everything works just fine. The images will appear smaller in the resulting PDF but with high printing quality.
What I am trying to do is to automate the process of going into Gimp and adjusting the DPI values. Since Imagemagick is known to be superb and I used it for many other tasks I tried to achieve my goal with this tool. But it does just not do what I want.
After trying a lot of things I think this actually is be the command that should be my friend:
convert input.png -density 300 output.png
This should set the DPI to 300, as I can read everywhere in the web. It seems to work. When I check the file it stays the same.
file input.png output.png
input.png: PNG image data, 611 x 453, 8-bit grayscale, non-interlaced
output.png: PNG image data, 611 x 453, 8-bit grayscale, non-interlaced
When I use this command, it seems like it did what I wanted:
identify -verbose output.png | grep 300
Resolution: 300x300
PNG:pHYs : x_res=300, y_res=300, units=0
(Funny enough, the same output comes for input.png which confuses me... so this might be the wrong parameters to watch?)
But when I now render my TeX with "pdflatex" the image is still big and blurry. Also when I open the image with Gimp again the DPI values are set to "72" instead of "300". So there actually was no effect at all.
Now what is the problem here. Am I getting something completely wrong? I can't be that wrong since everything works just fine with Gimp...
Thanks for any help in this. I am also open to other automated solutions which are easily done on a Linux system...
© Super User or respective owner