0

I would like to loop through some directories with pictures and copy (and after reviewing remove) them to another directory based on image dimensions, let's say smaller than 800x600.

I've tried a query like

find . -iname "*.jpg" -type f -exec identify -format '%w %h %i' '{}' \; | awk '$1<800 || $2<600

but I get no results, but I'm certain that there are smaller pictures.

Can anyone give me a hint? Thanks!

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
wtrdk
  • 1
  • 1
  • https://superuser.com/q/1513618/432690 – Kamil Maciorowski Mar 10 '20 at 12:28
  • Possibly related [shell command to get pixel size of an image](https://unix.stackexchange.com/questions/75635/shell-command-to-get-pixel-size-of-an-image) – Paulo Tomé Mar 10 '20 at 12:35
  • What happens if you change the format string to `'%w %h %i\n'`? I think your entire output may get concatenated to one single line at the moment because the format doesn't specify that a new-line is to be printed at end-of-record, and if the very first picture found doesn't happen to be smaller than 800x600, the entire output will be discarded by `awk`. – AdminBee Mar 10 '20 at 13:00
  • Also, shouldn't it be `awk '$1<800 && $2<600'`? – AdminBee Mar 10 '20 at 13:02
  • 1
    Does this answer your question? [Use mogrify to resize large files while ignoring small ones](https://unix.stackexchange.com/questions/38943/use-mogrify-to-resize-large-files-while-ignoring-small-ones) – don_crissti Mar 10 '20 at 18:09

0 Answers0