How to get metadata of images in Mac OSX

question-mark

Today, one of our clients was having an issue with images on iOS devices, so, the first thing they asked us, was about if the images were in the right format, for answering that, we had to obtain the metadata of every single image and see if the extension matched with the real information. So, let me show you two options for getting this information, probably some day you will find them useful:

An great tool

I really recommend ExifTool because give us interesting information about the images, and also can write this metadata.

ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files.

Taken from: http://www.sno.phy.queensu.ca/~phil/exiftool/

1) Get a copy (tar.gz) of the command line version: http://www.sno.phy.queensu.ca/~phil/exiftool/

2) Run following command:

./exiftool /path/to/your/image/image_name.png

For example:

./exiftool ../alex-arriaga.png

Example of output:

ExifTool Version Number         : 9.72
File Name                       : alex-arriaga.png
Directory                       : ..
File Size                       : 8.1 kB
File Modification Date/Time     : 2014:10:02 14:37:07-05:00
File Access Date/Time           : 2014:10:02 14:41:21-05:00
File Inode Change Date/Time     : 2014:10:02 14:37:09-05:00
File Permissions                : rw-r-----
File Type                       : JPEG
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : inches
X Resolution                    : 72
Y Resolution                    : 72
Image Width                     : 200
Image Height                    : 180
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:4:4 (1 1)
Image Size                      : 200x180

The interesting part of this output is even if I change the extension, the metadata says “Hey! You are a JPEG image, but your name is with  PNG extension”.

Another option (bad option)

We also have mdls but the disadvantage of this tool is that if we change the extension, the tool will give us wrong information, let’s see an example:

mdls alex-arriaga.png

Example of result (wrong):

kMDItemBitsPerSample           = 32
kMDItemColorSpace              = "RGB"
kMDItemContentCreationDate     = 2014-10-02 19:37:07 +0000
kMDItemContentModificationDate = 2014-10-02 19:37:07 +0000
kMDItemContentType             = "public.png"
kMDItemContentTypeTree         = (
    "public.png",
    "public.image",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemDateAdded               = 2014-10-02 19:38:37 +0000
kMDItemDisplayName             = "alex-arriaga.png"
kMDItemFSContentChangeDate     = 2014-10-02 19:37:07 +0000
kMDItemFSCreationDate          = 2014-10-02 19:37:07 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = (null)
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = (null)
kMDItemFSLabel                 = 0
kMDItemFSName                  = "alex-arriaga.png"
kMDItemFSNodeCount             = (null)
kMDItemFSOwnerGroupID          = 20
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 8305
kMDItemFSTypeCode              = ""
kMDItemHasAlphaChannel         = 0
kMDItemKind                    = "Portable Network Graphics image"
kMDItemLogicalSize             = 8305
kMDItemOrientation             = 0
kMDItemPhysicalSize            = 12288
kMDItemPixelCount              = 36000
kMDItemPixelHeight             = 180
kMDItemPixelWidth              = 200
kMDItemResolutionHeightDPI     = 72
kMDItemResolutionWidthDPI      = 72
kMDItemWhereFroms              = (
    "http://www.alex-arriaga.com/wp-content/themes/fenix/img/alex-arriaga.jpg",
    ""
)

That’s it for today, see you next time!

Leave a Reply

Your email address will not be published. Required fields are marked *