Get Image Dimensions from Command Line
The command line is a gold mine if you come from the perspective of a UI lover. Getting information from the shell instead of opening an app, finding a file or directory, etc...what a novel concept. Opening different image files opens up different apps on my Mac and, as the kids say, "ffs" -- I just want to know the image dimensions.
Using ImageMagick you can find the dimensions of an image from command line:
# Get the size of a JPG
convert photo.jpg -print "Size: %wx%h\n" /dev/null
# Size: 600x872
# Get the size of a PSD
convert website-design.psd -print "Size: %wx%h\n" /dev/null
# Size: 990x1200
You can get the image dimensions of any image type from PNG to JPG to GIF to even PSDs. And the resulting text is as plain as it could be. Dimensions...here you are.
![Write Simple, Elegant and Maintainable Media Queries with Sass]()
I spent a few months experimenting with different approaches for writing simple, elegant and maintainable media queries with Sass. Each solution had something that I really liked, but I couldn't find one that covered everything I needed to do, so I ventured into creating my...
![Create Namespaced Classes with MooTools]()
MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does. Many developers create their classes as globals which is generally frowned up. I mostly disagree with that stance, but each to their own. In any event...
![MooTools OpenLinks Class – Updated]()
A long time back I coded a MooTools class called OpenLinks. The class is quite useful but the code...sucks. I've gotten much better with MooTools over the past years so I thought I'd go back and update the class to be better, faster...
![QuickBoxes for Dojo]()
Adding to my mental portfolio is important to me. First came MooTools, then jQuery, and now Dojo. I speak often with Peter Higgins of Dojo fame and decided it was time to step into his world. I chose a simple but useful plugin...
I like to use ImageMagick’s identify command. Easy to remember and gives the size along with some other helpful info:
but that means having ImageMagick installed.
on a mac you have the native
sips
command that returns info and modifies image files.ex. to get all sorts of info on an image just do:
more info on sips available at:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html
Wow, thanks for the heads up! I didn’t know about
sips
!Wow! I always wonder why the command
file
is so unknown on the Mac?No need to install anything! Use
man file
for more information. Works for every kind of files, not just images: