Page 1 of 1

output file with specified filesize + original geometry?

Posted: 2012-03-19T08:04:56-07:00
by cybersd
I have pictures between 3 and 30 MB. All this pictures must be convert to the same output filesize 2MB but with the original geometry size.
I try this with -quality, resize etc., but I get different output filesizes or samler geometry.

I need help.....

Re: output file with specified filesize + original geometry?

Posted: 2012-03-19T11:10:55-07:00
by fmw42
What format are your output images? What platform are you using?

Basically, other than your playing with -quality, there is no way to keep the image dimensions the same and get a specific file size as far a I know in IM.

Re: output file with specified filesize + original geometry?

Posted: 2012-03-19T13:59:52-07:00
by cybersd
The Source image file is jpg and the Output file jpg, too.
I use an Linux System (debian, Suse).
I also make Tests with -quality, but the output size e.g. from a 8 MB file is sometimes 2,3 MB and sometimes 5 MB, with the Same quality Percent size.

Re: output file with specified filesize + original geometry?

Posted: 2012-03-19T14:10:31-07:00
by fmw42
As I said you have to use trial an error to get the specified file size by changing -quality as the compression will be image dependent. There is no simple recipe to get a specified file size via -quality in IM.

I am not sure how PS does jpg compression to a given file size for web output.

The only way I know to do it is to iterate on the -quality until you get what you want for the filesize.

Re: output file with specified filesize + original geometry?

Posted: 2012-03-19T19:23:02-07:00
by anthony
ImageMagick JPG coder can do that 'trial and error' for you.

See IM Examples, Common image file Formats, JPEG, Writing options
and specifically the -define jpeg:extent={size} option
http://www.imagemagick.org/Usage/formats/#jpg_write

Re: output file with specified filesize + original geometry?

Posted: 2012-03-19T19:41:20-07:00
by fmw42
I stand corrected. Neat. I learned something new today.

Re: output file with specified filesize + original geometry?

Posted: 2012-03-20T02:45:50-07:00
by cybersd
Thank you! It works fine!