1

Context

iPhone photos of both: portrait & landscape to be time-stamped with EXIF data, via ImageMagick 7.0.10-62 Q16 x86_64 2021-02-07 + Catalina MacOs. ImageMagick installed via:brew install ImageMagick

LANDSCAPE images follow gravity map:

The -gravity option specifies a frame of reference for annotating images. Annotated Landscape-Orientation photos follow the convention.

enter image description here enter image description here

Issue: PORTRAIT Image Annotations are rotated

Annotated Portrait-orientation photos result in a rotated frame of reference:

enter image description here enter image description here

Relevant code:

rm time*.jpeg
tic=$(date)
for img in IMG*jpeg; do convert "$img" -gravity Center -resize 35% -pointsize 65 \
   -fill red  -annotate +30+30  %[exif:DateTimeOriginal] "time_""$img";
   echo "watermarked $img successfully" 
done
toc=$(date)
echo $tic 
echo $toc

Questions

Although an algorithm could be applied to rotate the text if a portrait image is detected, I would think that there is a simpler method or that the above code is somehow incorrect resulting in the +90 rotated frame of reference. Landscape photos do not suffer this issue.

  1. Why is the gravity frame of reference rotated 90 degrees for portrait-orientation images and not landscape images? (feature or flaw?)
  2. How does one employ a consistent / singular gravity frame of reference?
    • preferably the non-rotated frame of reference
2
  • This is difficult to reproduce without the originals. Please add two source images, portrait and landscape including Exif data to the question. Also add the results and the expected results (6 images in total).
    – Freddy
    Feb 12, 2021 at 15:14
  • @Freddy Thanks for engaging. Photos uploaded to Google Drive drive.google.com/file/d/1obRBGwb-gA6Ij8emITjul6TzFOD_0_ug/…
    – gatorback
    Feb 12, 2021 at 16:02

1 Answer 1

1

The portrait image is rotated via the Exif Orientation tag. So the added timestamp is correct if we rotate the image.

portait image (rotated via Exif):

$ identify -verbose IMG_6361.jpeg | grep Orientation
  Orientation: RightTop
    exif:Orientation: 6
$ exiftool IMG_6361.jpeg | grep 'Orient\|Width\|Height'
Orientation                     : Rotate 90 CW
Exif Image Width                : 4032
Exif Image Height               : 3024
Image Width                     : 4032
Image Height                    : 3024

landscape image (not rotated):

$ identify -verbose IMG_1690.jpeg | grep Orientation
  Orientation: TopLeft
    exif:Orientation: 1
$ exiftool IMG_1690.jpeg | grep 'Orient\|Width\|Height'
Orientation                     : Horizontal (normal)
Exif Image Width                : 4032
Exif Image Height               : 3024
Image Width                     : 4032
Image Height                    : 3024

To change the orientation to "top-left", you can use ImageMagick's -auto-orient option, e.g.

$ convert -auto-orient IMG_6361.jpeg IMG_6361_auto_orient.jpeg
$ exiftool IMG_6361_auto_orient.jpeg | grep 'Orient\|Width\|Height'
Orientation                     : Horizontal (normal)
Exif Image Width                : 4032
Exif Image Height               : 3024
Image Width                     : 3024
Image Height                    : 4032

Include -auto-orient in your command to:

for img in IMG*jpeg; do convert "$img" -auto-orient -gravity Center -resize 35% -pointsize 65 \
   -fill red  -annotate +30+30  %[exif:DateTimeOriginal] "time_""$img";
   echo "watermarked $img successfully" 
done

Result:

enter image description here

1
  • Thank you for the detailed explanation: it is an excellent example of how to explain an abstract problem and its solution.
    – gatorback
    Feb 13, 2021 at 3:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .