imagemagick Montage:
I can only create a montage if all the exif data is cleared.
As a new user on Lemmy, going through the learning curve, I had issues uploading images.
Simple, I turned to imagemagick to reduce the size of the images and create a montage, rather than uploading 20 images for a simple bread recipe.
========================================
I transfered my recipe images from my phone to my laptop and set about using Montage.
The images on the phone, and in the directory on my laptop, were clearly orientated in Portrait and not landscape.
========================================
Problem:
I ran montage to create a simple 4 image montage:
montage 1.jpg 2.jpg 3.jpg 4.jpg -geometry +2+2 1-montage-image.jpg
I checked the output file, the images were in the right order but had changed from portrait to Landscape. They looked terrible
I then tried some different images.
These came out as expected, in portrait and in order
=======================================
I compared the images,
identify -verbose 1.jpg
the ones I transfered from my phone still had all the exif data intact and the other ones had no exif data
========================================
So I cleared the exif data for the files.
exiftool worked perfectly:
exiftool -all= *.jpg
created an “original-images” directory, then moved the originals to “original-images” directory
mv *.jpg_original original-images
when I cleared the exif data all the images in the directory reverted to landscape
========================================
so I set them back to portrait:
One liner to change orientation by 90 degrees
find . -maxdepth 1 -type f -name “*.jpg” -exec convert {} -rotate 90 {} ;
or mogrify:
mogrify -rotate -90 *.jpg
or
mogrify -rotate +90 *.jpg
========================================
created the montage image:
montage 1.jpg 2.jpg 3.jpg 4.jpg -geometry +2+2 1-montage.jpg
========================================
Now I reduced the size so I could upload them
create an “images” directory if you do not want mogrify to overwrite the originals.
mogrify -resize 50% -quality 80 -path “/path/to/reduced/images/” *.jpg
or
mogrify -resize 50% -quality 80 -path “images” *.jpg
job done
========================================
A lot of messing about to upload an image
-auto-orient
– auto-orient will read from EXIF-strip
– strip will remove all metadata- WARNING: if you’ve already used
-strip
, then-auto-orient
will do nothing
In case you (or someone else) wants an explanation.
Modern cameras and phones save the image orientation in the exif data while keeping the orientation of the real pixels like they were originally.
But by default imagemagick doesn’t use the exif data but the real pixel orientation. That’s why the orientation in the montage and after removing exif data was wrong.
I think there are options to let imagemagick read the exif data. I’m too lazy to look it up.
Two of my favourites, Linux and Bread. We need a Bread centric distro.