Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I have many photos. How to search files by its dimensions? For example, i want to search images with exact dimensions 500 x 500 pixels. Is there any utility for this task?

share|improve this question

marked as duplicate by Stéphane Chazelas, jasonwryan, Mat, slm, Renan May 4 '13 at 23:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 3 down vote accepted

You can use the identify command that's part of ImageMagick to do this:

$ identify rose.jpg
rose.jpg JPEG 640x480 sRGB 87kb 0.050u 0:01

The 640x480 is the dimensions of the image, rose.jpg.

Using the find command you could do something like this:

$ find somedir -iname '*.jpg' -exec identify {} \;

So for your example:

$ find somedir -iname '*.jpg' -exec "identify {} awk '{print $1, $3}' \
       | grep '500x500'" \;

References

share|improve this answer
3  
This is suitable only for files without whitespace characters in their name. Better use -format option: identify -format '%P %f\n' *.{jpg,png,gif} | grep '^500x500 '. –  manatwork May 4 '13 at 14:16
    
@manatwork, that technique didn't work too well for me, running it in a directory where there aren't any png, jpg, or gif files yields this error: "identify: unable to open image `*.jpg': @ error/blob.c/OpenBlob/2517." –  slm May 4 '13 at 16:25
    
Being a comment, I kept it simple. Feel free to combine it with your original find based code. –  manatwork May 4 '13 at 16:37
    
I like your thinking on the approach, just was putting a comment to it in case others encountered it too 8-). –  slm May 4 '13 at 16:41

With exiftool:

exiftool -q -r -if '$ImageHeight == 500 && 
  $ImageWidth == 500' -p '$Directory/$FileName' /some/dir
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.