Extracting image orientation from a JPEG

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
Desch
Posts: 2
Joined: 2017-12-13T07:28:24-07:00
Authentication code: 1152

Extracting image orientation from a JPEG

Post by Desch »

Hi,
I'm a Windows 10 user and I want to determine the resolution or orientation (portrait or landscape) of my image files. When I use the following command-line, everything works fine:

magick identify -format "%i:%W:%H\r\n" *.jpg

RESULTS (filename:width:height) :
1.jpg:1920:1080
2.jpg:1920:1080

When I try the same thing in the following batch file (image.cmd):

@echo off
cd "%userprofile%\Pictures"
erase /F image_list
magick identify -format "%i:%W:%H\r\n" *.jpg >> image_list

I get the following RESULTS:
W:H
W:H

WHY ? Can anyone help me or is there a simplier way to do that ?

Thanks!

Desch
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting image orientation from a JPEG

Post by snibgo »

In Windows BAT files, percent % has a special meaning. When you don't want that special meaning, you need to double it:

Code: Select all

magick identify -format "%%i:%%W:%%H\r\n" *.jpg >> image_list
snibgo's IM pages: im.snibgo.com
Desch
Posts: 2
Joined: 2017-12-13T07:28:24-07:00
Authentication code: 1152

Re: Extracting image orientation from a JPEG

Post by Desch »

Hi snibgo,

I forgot that little detail, it seems to work now, thanks!

Desch
Post Reply