3

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?

0

2 Answers 2

5

With exiftool:

exiftool -q -r -if '$ImageHeight == 500 && 
  $ImageWidth == 500' -p '$Directory/$FileName' /some/dir
3

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

4
  • 4
    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 '. Commented May 4, 2013 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." Commented May 4, 2013 at 16:25
  • Being a comment, I kept it simple. Feel free to combine it with your original find based code. Commented May 4, 2013 at 16:37
  • I like your thinking on the approach, just was putting a comment to it in case others encountered it too 8-). Commented May 4, 2013 at 16:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.