Auto rotated based on EXIF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply

Would you like to see such utility implented?

YES
4
100%
NO
0
No votes
Don't want to comment
0
No votes
 
Total votes: 4

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2005-11-30T20:40:02-07:00

I do that as part of a photo indexing script...

Code: Select all

rotation=''
rotation=`identify -format "%[EXIF:Orientation]" "$f"`

rot=""
case "$rotation" in
  ""|"unknown") : no rotation supplied in image ;;
  1)  : normal camera rotation ;;
  6) rot="-rotate 90"  ;;
  8) rot="-rotate -90" ;;
  *) echo >&2 "Unknown rotation for  $f \"$rotation\"  -- Continuing" ;;
 esac
Now I include $rot in my IM command when generating a smaller 'web' version of the photo for generally viewing, and of course for its thumbnail.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2005-11-30T21:41:38-07:00

The script is a personal one, not appropriate for public consumption.

However once I get $rot (and extract comments from images) I use...

Code: Select all

    echo >&2 "Generating Smaller Image..."
    convert "$f" $rot -thumbnail ${nsize}x${nsize} -quality $nqual "$n"
where $f is the origina and $n is the new 'web' image
$nsize is set to 790 pixels.

The thumbnail image is basically as per the IM thumbnail examples...

Code: Select all

      angle=`perl -e 'srand();  print rand() * 20 - 10'`
      size=`convert "$n" -thumbnail ${tsize}x${tsize} \
          -bordercolor white  -border 6 \
          -bordercolor grey60 -border 1 \
          -background  none   -rotate $angle \
          -background  black  \( +clone -shadow 60x4+4+4 \) +swap \
          -background  none   -flatten \
          -depth 8 -colors 256 -quality 95 \
          -write "$t" -format "WIDTH=%w HEIGHT=%h" info:-`
thumbnail size is 100 pixels, and outputs a PNG image
If I want a simpler plain thumbnail (non-fancy) a GIF is used.
The images are only re-built if the source is newer, or a FORCE option is used.

The script then writes up the index.html with image comments, date, and generated thumbanil and so on.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick » 2006-05-17T20:27:08-07:00

Post a URL to 3-5 images that contain orientation information in the EXIF profile and we will look into supporting automatic rotation to the correct orientation.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-05-21T18:42:36-07:00

You forgot the orientation for upsidedown, camera looking straight up
and camera looking straight down :-)

I see these in my own camera when I take photos of documents (a quick way of scanning :-) or of kites and planes when I'm directly underneath. these situations do produce their own 'orentation' in many cameras.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-06-28T23:04:56-07:00

Yes the -auto-orient option as added due to your artical!

I thought you knew :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply