O
O
Oleg2018-07-13 11:03:20
bash
Oleg, 2018-07-13 11:03:20

How to optimize thousands of images with a condition?

Good afternoon.
It is necessary to optimize a lot of images (500 thousand). I do it as a team

find . -type f \( -name "*.jpeg" -or -name "*.jpg" \) -exec mogrify x-quality 80 {} \; -exec jpegoptim -o --strip-all {} \;

And using the -resize x100 option, you can reduce them to 100x100
Question: How to make a command with the condition that if the image size is higher than 900 (for example, in width or height), then we reduce it PROPORTIONALLY to 900. So is it really possible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2018-07-13
@saboteur_kiev

Add conditions like this

if ; then INSERT_RESIZE_COMMAND; fi
if ; then INSERT_RESIZE_COMMAND; fi

But in general, instead of a one-liner, it's better to write a script, even with a function.

V
Viktor Taran, 2020-07-27
@shambler81

I didn’t work very well with ImageMagick, but on the Internet they say that such crap is enough for themselves. \>
Something like this

find * -iname '*.jpg' -print0 | xargs -0 mogrify -resize 800x800\> -monitor -format jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question