OSX vs Ubuntu - Command format difference

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

OSX vs Ubuntu - Command format difference

Post by saurabheights » 2016-10-14T18:39:22-07:00

There is an inconsistency while using IM between Ubuntu and OSX.

The below command works on Ubuntu:
identify -format '%[EXIF:Orientation]' <inputfile>

However, on OSX(installed using brew), we have to use:
identify -format "%[orientation]" <inputfile>

This creates problem in writing platform-independent code. Is it possible to provide same format for all OS's?

User avatar
fmw42
Posts: 23627
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: OSX vs Ubuntu - Command format difference

Post by fmw42 » 2016-10-14T19:40:42-07:00

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images,

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/


It works fine for me with IM 6.9.6.1 Q16 Mac OSX.

Code: Select all

identify -format '%[EXIF:Orientation]' DSC_0025.JPG
6

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

Re: OSX vs Ubuntu - Command format difference

Post by snibgo » 2016-10-14T19:58:04-07:00

saurabheights wrote:There is an inconsistency while using IM between Ubuntu and OSX.
Any inconsistency here is almost certainly not because of the different platforms, but either different versions of IM, or using two different input files with different metadata.
snibgo's IM pages: im.snibgo.com

saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

Re: OSX vs Ubuntu - Command format difference

Post by saurabheights » 2016-10-14T20:44:08-07:00

@snibgo, @fmw42: That was really unprofessional of me. My apologies for not only not providing proper information but also raising a incorrect question.

Both these commands do work in both OSX and Mac.

Code: Select all

identify -format '%[orientation]' photo.jpg
identify -format '%[EXIF:orientation]' photo.jpg
The issue was the misleading output when trying to read EXIF:orientation tag in an image which didn't had the Exif metadata for the orientation tag.

Image which contains orientation metadata:-

Code: Select all

$> identify -format '%[EXIF:orientation]' photo.jpg 
1
$> identify -format '%[orientation]' photo.jpg 
TopLeft
If I strip the image and run the same commands:-

Code: Select all

$> convert -strip photo.jpg photoStripped.jpg
$> identify -format '%[orientation]' photoStripped.jpg 
Undefined
$> identify -format '%[EXIF:orientation]' photoStripped.jpg 
identify: unknown image property "%[EXIF:orientation]" @ warning/property.c/InterpretImageProperties/3785.

The part "unknown image property" was misleading. My immediate thought was that IM does not know this property. Suggestion: IMHO, this message can be made very clear. For example:-
identify: image property "%[EXIF:orientation]" not found. @ warning/property.c/InterpretImageProperties/3785.

Although maybe irrevelant now, the OSX and Ubuntu version:
OSX: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-13
Ubuntu: ImageMagick 7.0.3-0 Q16 x86_64 2016-09-09

Sample Image:- http://imgur.com/a/cgyue

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

Re: OSX vs Ubuntu - Command format difference

Post by snibgo » 2016-10-14T21:11:09-07:00

No problem. Glad you've solved it.
identify: unknown image property "%[EXIF:orientation]"
In the context of "-format", IM doesn't know anything about EXIF properties or what they mean. A requested EXIF property is either present or absent.
snibgo's IM pages: im.snibgo.com

saurabheights
Posts: 8
Joined: 2016-09-24T05:16:10-07:00
Authentication code: 1151

Re: OSX vs Ubuntu - Command format difference

Post by saurabheights » 2016-10-14T21:31:42-07:00

@snibgo: Should I raise a new request for change of output format to "image property "%[EXIF:orientation]" not found." or will this(current) post suffice?

This is not a problem faced just by me, but all(2 as of now) of my colleagues. So, I can say it's not just my personal view. It will also help novice users in future. It is also not a big code change, as long as any software/library dependent on IM is not exactly checking for hardcoded value "Unknown image property".

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

Re: OSX vs Ubuntu - Command format difference

Post by snibgo » 2016-10-14T21:58:34-07:00

This thread is in the Developers forum, so I expect they will read it.

The message you got, "unknown image property", comes from InterpretImageProperties when it has tried to translate the string with a number of methods, and they have all failed. You get the same message if your string is "%[nonesuch]" or "%[EXIF:nonesuch]" or even "%[XXX:nonesuch]".

I don't think IM maintains a list of EXIF tags, so it can't distinguish between "valid EXIF tag but not present" and "not a valid EXIF tag".
... as long as any software/library dependent on IM is not exactly checking for hardcoded value "Unknown image property".
Yes, indeed, "as long as".
snibgo's IM pages: im.snibgo.com

Post Reply