Page 1 of 1

Not able to resize images to <150KB file-size

Posted: 2012-12-05T01:55:51-07:00
by slahoti
Hi,
I am using imagemagick in windows 7. I need to resize and then save a bunch of images such that the resulting file size is <150KB.
I am using a batch script to do the same. Here is my code -

@for %%f in (*.jpg) do (
convert %%f -resize 1000 %%~nf-1000.jpg
convert %%~nf-1000.jpg -define jpeg:extent=150kb %%~nf-150.jpg
)

Basically, I am taking every .jpg file and resizing to width=1000. Then I am using '-define jpeg:extent=150kb' to compress the image to filesize <150Kb.

The original images are of 4-6MB file size.
Using the above commands, results in an image that is 2-3MB in size. Basically the second command above is not having any effect.
Can anyone help me in figuring out the mistake??

TIA

Re: Not able to resize images to <150KB file-size

Posted: 2012-12-05T05:38:30-07:00
by snibgo
It works quite well for me, IM 6.7.9-Q16 on Windows 7. What version of IM are you running?

"%IMG%convert" AGA_0960.jpg -resize 1000 z.jpg
"%IMG%convert" z.jpg -define jpeg:extent=150kb y.jpg

Sizes:
AGA_0960.jpg 16022 kb
z.jpg 635 kb
y.jpg 161 kb


Converting to jpg twice will lose quality, so it's better as a single command:

"%IMG%convert" AGA_0960.jpg -resize 1000 -write z.jpg -define jpeg:extent=150kb y.jpg