Is there a way to list image dimensions for .png files?

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
rickgut2016
Posts: 3
Joined: 2016-03-31T16:43:20-07:00
Authentication code: 1151

Is there a way to list image dimensions for .png files?

Post by rickgut2016 »

Is there a way to list image dimensions for .png files? I'm using this code, and I'm only getting the file dimensions of .jpg, and .gif files.

identify.exe -format "%f %w %y" *.*

I'm getting this error for .png files:
identify.exe: improper image header `ccp-pd-080-90.png' @ error/png.c/ReadPNGImage/3921.

Any help would be greatly appreciated! Thanks ya'll!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there a way to list image dimensions for .png files?

Post by fmw42 »

What is your IM version and version of libpng?

You can get them from

Code: Select all

convert -version

Code: Select all

convert -list format
See http://www.imagemagick.org/script/escape.php

"%y" is not the height, but the resolution (dpi) in the vertical dimension. If you want the height, use "%h"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is there a way to list image dimensions for .png files?

Post by snibgo »

rickgut2016 wrote:improper image header `ccp-pd-080-90.png'
It sounds like a problem with that file. Please upload to somewhere like dropbox.com and paste the URL here.
snibgo's IM pages: im.snibgo.com
rickgut2016
Posts: 3
Joined: 2016-03-31T16:43:20-07:00
Authentication code: 1151

Re: Is there a way to list image dimensions for .png files?

Post by rickgut2016 »

Here is my version info:

Version: ImageMagick 6.9.3-7 Q16 x64 2016-03-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

and

PNG* PNG rw- Portable Network Graphics (libpng 1.6.20)

I will use %h, thank you! Please let me know if I need a different version of anything. Thanks so much! This is a work project, so it would be sweet if I can get it working. Basically I need to list the dimensions (width, height) of 28 thousand files.. Looks like the files are .jpg, .gif, and .png.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there a way to list image dimensions for .png files?

Post by fmw42 »

See snibgo's comment above about providing your png input file.
rickgut2016
Posts: 3
Joined: 2016-03-31T16:43:20-07:00
Authentication code: 1151

Re: Is there a way to list image dimensions for .png files?

Post by rickgut2016 »

Update: It looks like those .png files are corrupt. I should have checked that fist.. Thanks for the help all. I learned a few things :D
Post Reply