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
Not able to resize images to <150KB file-size
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Not able to resize images to <150KB file-size
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
"%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
snibgo's IM pages: im.snibgo.com