Page 1 of 1

Process File only if Dimension Change

Posted: 2016-10-17T11:06:05-07:00
by PoOoOoZ
Hello, i have found the command i need, but i need an option more.

for file in *.jpg; do convert $file -resize 1000x1000\> $file; done

I want it not process with file who is not resized, with this command it process with it even if the dimension don't change (but file size change)...

If i do this everyday in the same folder, the file who will not be redimensionned will lost quality day after day...

Thank you very much.

Re: Process File only if Dimension Change

Posted: 2016-10-17T14:01:22-07:00
by snibgo
PoOoOoZ wrote:Hello, i have found the command i need, but i need an option more.
Do that option in the script, outside the convert, and probably outside the "for" loop.

For example, don't do this every day in the same folder. Organise your process so you do the resize only once per file.

Re: Process File only if Dimension Change

Posted: 2016-10-18T03:57:19-07:00
by PoOoOoZ
I was looking for a thing like this :

for files in *.jpg
do
echo $files
filesizecurrent=$(wc -c <"$files")
echo $filesizecurrent
if [ $filesizecurrent -ge 100000 ]
then
echo "BIG FILE"
convert $file -resize 1000x1000\> $file
continue
fi
echo "LITTLE FILE"
done

Re: Process File only if Dimension Change

Posted: 2016-10-18T11:07:41-07:00
by GeeMack
PoOoOoZ wrote:I was looking for a thing like this :
You can use ImageMagick to obtain the dimensions of an image with a command like this...

Code: Select all

convert -ping image.jpg -format "%[w]x%[h]" info:
Use something like that inside a "for" loop, maybe once to get the "%[w]" width and another time to get the "%[h]" height, to set the value of some variables. Then calculate the area using those variables, and do the "-resize" if the area exceeds a certain threshold.

To get any more detailed help you need to let us know what version of ImageMagick you're using, and what platform or shell, you're running this from.