-3

How to cut from the bottom 20% recursively in Bash? if the image size is less than 200px?

Tried the method, but erroneously

find -name "*.jpg" -crop 20%height -quality 100 {} \;
gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104

1 Answers1

2

How to cut from the bottom 20% recursively in Bash? if the image size is less than 200px?

I don't know what you mean by if the image size less than 200px.

  1. is that width, height or square?
  2. what has image size actually got to do with it?
  3. should it only cut 20% off if the picture is 200 px in width or less? or are you just worried whether it will work or not for 200x200px or less?

Or do you actually mean this?

How to find all my pictures recursively, chop 20% off from the bottom of each picture and save them losslessly (quality 100% so no .jpeg) to a new filename?

If that is the case then install imagemagick and run the following script:

#!/bin/bash

shopt -s globstar nullglob

for image in **/*.jpg
do
    convert "$image" -gravity North -crop 100x80%+0+0 +repage "${image%.jpg}.png"
done
gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104
thom
  • 2,294
  • 12
  • 9