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.
![6 Things You Didn’t Know About Firefox OS]()
Firefox OS is all over the tech news and for good reason: Mozilla's finally given web developers the platform that they need to create apps the way they've been creating them for years -- with CSS, HTML, and JavaScript. Firefox OS has been rapidly improving...
![Responsive and Infinitely Scalable JS Animations]()
Back in late 2012 it was not easy to find open source projects using requestAnimationFrame()
- this is the hook that allows Javascript code to synchronize with a web browser's native paint loop. Animations using this method can run at 60 fps and deliver fantastic...
![Create a CSS Flipping Animation]()
CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's...
![Digg-Style Dynamic Share Widget Using the Dojo Toolkit]()
I've always seen Digg as a very progressive website. Digg uses experimental, ajaxified methods for comments and mission-critical functions. One nice touch Digg has added to their website is their hover share widget. Here's how to implement that functionality on your site...
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: