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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Posts: 3
Joined: 2012-10-04T06:37:27-07:00
Authentication code: 67789

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

Post by slahoti »

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??


Posts: 12863
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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

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:

Post Reply