Collecting Image Dimensions and Aspect Ratios

The supporting files submitted by a client for an ongoing project included 8,000 images.

To figure out what sort of dimensions we were dealing with, and whether the images were primarily horizontal, vertical or square, I put together this little script.

This is a Windows batch file that outputs the dimensions and aspect ratio of all the images in a directory as a CSV file. It uses ImageMagick’s identify tool.

@ECHO OFF
ECHO file, w, h, aspect > aspects.txt
FOR /f %%a IN ('dir /b *.jpg') DO ( 
  identify -format "%%f, %%w, %%h, %%[fx:w/h]" %%a >> aspects.txt & ECHO %%a 
)