I have a bunch of png´s in a folder, which I want to print out. Each of them is 640x960 pixels big and should be 6.7x10cm when printed out. I used to put every picture in Word, specify the size and then print them out.
Because I have to do that task repeatedly I want to automate it. I found ImageMagick and installed it on my Mac. However I don't seem to get the dimensions quite right.
I tried:
montage -geometry 1181x792+50+50 -page 2480x3508 -density 300 -adjoin *.png output.pdf
But the pictures don't have the right dimensions if printed out. A nice Bonus would be to find an optimal way to mimize white space on the A4 Page. I can fit one more pic in Word if I rotate it.
A python solution would also be fine if anyone has ideas! thank you!
I'm not sure why you are writing a PDF when an image will be simpler, nor am I sure what you really want. I find these things easier to lay out a different way - using spacers and +append
to append side-by-side and -append
to append below.
Here is what I think you want. I have coloured all the parts differently so you can see what is causing what. The first line of the script makes a light-grey spacer and keeps a copy in a "Magick Persistent Register", i.e. in memory. That spacer then makes the light grey spacer in the top row of the image. The next line is made of "1.png" resized followed by a spacer and "2.png" resized. The next line is a centralised spacer. The next line is "3.png" resized followed by a spacer and "4.png" resized. Then the next line is a spacer. And the final line is "5.png" resized and rotated. Then all 6 lines are appended below one another. And finally the image we have created is centred on a piece of dark grey canvas that is 2480x3508:
#!/bin/bash
# Define some variables
PAD=50
SIZE="792x1181"
magick -gravity north -background yellow -size ${PAD}x${PAD} xc:gray90 -write MPR:spacer \
\( \( 1.png -resize $SIZE \) MPR:spacer \( 2.png -resize $SIZE \) +append \) \
MPR:spacer \
\( \( 3.png -resize $SIZE \) MPR:spacer \( 4.png -resize $SIZE \) +append \) \
MPR:spacer \
\( 5.png -resize $SIZE -rotate 90 \) \
-append \
-gravity center -background gray30 -extent 2480x3508 result.png
If we remove all the colours I have used to explain what I am doing, and replace them with "none" (i.e. transparent) we get:
#!/bin/bash
# Define some variables
PAD=50
SIZE="792x1181"
magick -gravity north -background none -size ${PAD}x${PAD} xc:none -write MPR:spacer \
\( \( 1.png -resize $SIZE \) MPR:spacer \( 2.png -resize $SIZE \) +append \) \
MPR:spacer \
\( \( 3.png -resize $SIZE \) MPR:spacer \( 4.png -resize $SIZE \) +append \) \
MPR:spacer \
\( 5.png -resize $SIZE -rotate 90 \) \
-append \
-gravity center -background none -extent 2480x3508 result.png