Convert image with imagemagick command line convert tool
Solution 1
The command
convert Image.png -resize 620x797 -quality 1 Image.jpg
meets your claims. However PNG is lossless compression and JPG is lossy, so you can compress as much as you want, but the result may not meet your needs.
How to figure it out:
450 dot per inch means 450 pixel per 25.4 mm
to get the width: 450*35/25.4 = 620
to get the height: 450*45/25.4 = 797
Solution 2
Just convert DPI to metric: 450 DPI equals 17.71 dots per mm.
This gives you 17.71 * 35 = 621 pixels (you have to round up) or more for the width and 17.71 * 45 = 798 pixels or more for the height.
With that use normal convert resize:
convert Image.png -resize 621x798 Image.jpg
to get the size right.
Related videos on Youtube
Loom
Updated on September 18, 2022Comments
-
Loom over 1 year
I have an image
Image.png
. How do I use the ImageMagick commandconvert
to make this file into aImage.jpg
file with the following requirements:- File size is 200~500 kb.
- Resolution in not less than 450 dpi
- Image size 35 x 45 mm
Edit: These are the exact requirements for making some documents through electronic government. IT isn't a problem that the quality will deteriorate, because the image is needed just for the process of making the document (not for the document itself).
I'm not entirely clear in understanding what these requirements mean with respect to a file. I figured out how to get
.jpg
from.png
:$ convert Image.png Image.jpg
Also, I found out how to set some specific DPI:
$ convert -units PixelsPerInch Image.png -density 450 Image.jpg
However, I'm not sure about millimeters, and how it's determined in an image file.
-
verdammelt over 10 yearsPlease add details to your question about which arguments to hte imagemagick command you have tried and how they didn't work.
-
Loom over 10 years@verdammelt - Thank you. I added some details now.
-
slm over 10 yearsI'm going to guess that these are for passport photos of some sort? Am I right? persofoto.com/lexicon/passport-photo/size
-
Loom over 10 years@slm - Thank you for corrections. This photo that I want to convert will for internal use of government office only. Passport photo itself they will make when I visit the office.
-
pauljeba over 3 yearsPassport photos can be made through makepassportphoto.com/en/p/photo-for-united-states-passport