0

This question already has an answer here:

I have a folder with JPG images, some of which have a height dimension larger than 1900 pixels. I need a command that will ignore the images with a height dimension lower than 1900 pixels, while resizing only images with a greater height.

This command does the resizing job, but in the process it still opens and re-saves the images it doesn't resize, which eats up HD and CPU bandwidth:

mogrify -resize 'x1900>' *.jpg

Is there a better command, that will ignore the images that fall below the pixel threshold?

The question is different from the question here: Use mogrify to resize large files while ignoring small ones

I want the command to determine which JPGs are larger than a certain height, taking the width out of the equation.

marked as duplicate by don_crissti, mattdm, Gilles, roaima, jasonwryan Apr 26 '15 at 23:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    @don_crissti This question isn't an exact duplicate, as I only want to determine which images have a larger height, taking the width out the equation. – user8547 Apr 26 '15 at 23:22
  • Your problem is actually the same: "this command does the resizing job, but in the process it still opens and re-saves the images it doesn't resize, which eats up HD and CPU bandwidth" – don_crissti Apr 26 '15 at 23:26
  • @don_crissti The answers on that other thread answer that, but the solutions they provide use both width and height. I only want the height of the images to be determined. Can I open a new question asking how to modify one of the answers on the other thread to determine only height? – user8547 Apr 26 '15 at 23:30
1

With zsh

higher() {
  local h
  h=$(identify -format %h - < $REPLY) &&
    ((h > $1))
}

mogrify -resize 'x1900>' ./*.jpg(.e:higher 1900:)

Not the answer you're looking for? Browse other questions tagged or ask your own question.