Created
April 22, 2024 03:33
-
-
Save arpagon/04793301811c4a1127e8a189eafba7de to your computer and use it in GitHub Desktop.
Print Photos in A4 pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1: Unzip the downloaded photo archive | |
unzip your_photos.zip -d extracted_photos | |
# Step 2: Prepare the images | |
# Create a directory for resized images | |
mkdir resized | |
# Navigate to the directory containing extracted images | |
cd extracted_photos | |
# Resize images to fit A4 size and rename sequentially for ease of use | |
i=1 | |
for img in *.jpg; do | |
convert "$img" -resize 1240x1754\> "../resized/$i.jpg" | |
i=$((i + 1)) | |
done | |
# Step 3: Create the Photo Book PDF | |
# Navigate to the resized directory | |
cd ../resized | |
# Use ImageMagick's montage to create a PDF from the resized images | |
montage -geometry +0+0 \ # Sets the geometry to not add any extra space between images | |
*.jpg \ # Takes all JPEG images in the directory | |
+compress \ # Applies compression to reduce file size | |
-resize 1240x1754 \ # Resizes images to fit A4 size before montage | |
-tile 2x3 \ # Arranges images in a 2 columns by 3 rows format per page | |
-page a4 \ # Sets the output page size to A4 | |
photobook.pdf # Outputs the result into a PDF file named 'photobook.pdf' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment