admin管理员组

文章数量:1305151

I am somewhat new to linux. I am trying to find any jpg file in a directory structure over 10 MB. I would like to resize them from 6000x4000 to 3000x2000 which should make it less than 10MB. I would like to have the new file ".jpeg" so I can easily find them later. I can run the find command and get what I am looking for, but I cannot seem to figure out how to pipe it correctly into the magick command. Any help would be greatly appreciated.

I am somewhat new to linux. I am trying to find any jpg file in a directory structure over 10 MB. I would like to resize them from 6000x4000 to 3000x2000 which should make it less than 10MB. I would like to have the new file ".jpeg" so I can easily find them later. I can run the find command and get what I am looking for, but I cannot seem to figure out how to pipe it correctly into the magick command. Any help would be greatly appreciated.

Share Improve this question edited Feb 4 at 2:39 Gilles Quénot 186k43 gold badges231 silver badges229 bronze badges asked Feb 4 at 1:16 user3613820user3613820 211 bronze badge 2
  • The 32MP Jpegs from my camera, saved at Q98 and half-chroma, are about 13MB average (so that would make your pictures under 10MB). You'll lose much less data by reencoding your images at a lesser but still good quality (90-95, half-chroma) than by scaling them down. There are convert options for this. Then, storage is cheap... – xenoid Commented Feb 4 at 10:45
  • You would retain the maximum quality and resolution by using -define jpeg:extent like this stackoverflow/a/64411598/2836621 – Mark Setchell Commented Feb 8 at 8:58
Add a comment  | 

1 Answer 1

Reset to default 2

Like this:

find . -size +10M -name '*.jpg' -exec bash -c '
    for img; do convert -resize 3000x2000 "$img" "${img%.jpg}.jpeg"; done
' -- {} +

本文标签: findResizing Photos in DirStack Overflow