You can use identify from imagemagick, and you can use the following command:
find . -iname "*.jpg" -type f -exec identify -format '%w %h %i' '{}' \; | awk '$1<300 || $2<300'
the use of -exec <command> '{}' \; makes sure that your filename can have spaces in them, alternatively you can use
find . -iname "*.jpg" -type f | xargs -I{} identify -format '%w %h %i' {} | awk '$1<300 || $2<300'
where the -I{} takes care of the same thing.
What I like about identify is that you can specify the output format; in this case '%w %h %i' which gives the width, height and full pathname of the image. Then the awk expression only keeps those lines for which the image is smaller than the desired size.
Example of the output:
64 64 ./thumbsup.jpg
100 150 ./photomin.jpg
Edit: If you want the filenames only (for piping to rm for instance), simply change $line in the awk statement to $3, then it will only print the third column.
| awk '$1<300||$2<300'or| awk '$1<300||$2<300{print $3}'(when only the 3rd column is needed). – alephreish Oct 06 '14 at 18:21'%w %h %i\n') to get it to work for me. – qwr Jul 24 '17 at 21:15| xargs -I {} mv {} /destination/directory/– Gerhard Burger Jan 02 '20 at 16:071663 2495 ./0001.jpg2495 1663 ./0072.jpg1663... and so on, so when I add| xargs -I {} mv {} /destination/directory/I get the errormv: cannot stat './0001.jpg2495': No such file or directory. How can I output the file names in a correct way? – GhostOrder Jan 02 '20 at 21:52