Find Image With Specific Dimension Using Command Line


Question:

Find JPEG images with size 1080x1920 using Linux command line tool.

Answer:

Install ImageMagick:

$ sudo apt-get install imagemagick

Use the following command to find all *.jpg files with size 1080x1920: [1]

$ find . -iname "*.jpg" -type f -exec identify -format '%i %wx%h\n' '{}' \; | grep '1080x1920'

To move the 1080x1920 *.jpg files to another directory, run: [2]

$ find . -iname "*.jpg" -type f -exec identify -format '%i %wx%h\n' '{}' \; | grep '1080x1920' | sed -e "s/ 1080x1920$//" | xargs -I {} mv {} /path/to/destination/directory/

References:

[1]How to find all images with a certain pixel size using command line? - Ask Ubuntu
[2]Remove a fixed prefix/suffix from a string in Bash - Stack Overflow