Reduce image to a particular file size

Ideas for improvements and requests for new features in XnView Classic

Moderators: XnTriq, xnview

Post Reply
User avatar
SeaMaiden
Posts: 63
Joined: Tue Aug 17, 2004 8:36 am
Location: Central California
Contact:

Reduce image to a particular file size

Post by SeaMaiden » Tue Feb 07, 2006 6:01 am

Currently, the only way I know to get an image at or below a certain file size is by trial and error. I'd like a feature where you can tell XnView to reduce the image to X file size and X file type.

Example 1:

A PNG image file is 3.33KB.
It needs to be 725 bytes or smaller.
You enter into XnView the desired file size you want.
Optionally, you enter also the desired image size (16x16, 24x24, 32x32, 48x48, or a custom size) In this case, 16x16 is too small. I'd like it to be no smaller than 24x24.

Example 2:

A JPG image file is 5MB
It needs to be 1MB or less.
You also want to convert it to GIF at the same time.

XnView automatically changes the file (reducing colors, dpi, or whatever else) to try to get the file to the physical size and pixel size you specify.
Tablet Android 4.4 and Mobile Phone Android 4.1.2. No PC at this time.
** XNVIEW ROCKS **

User avatar
xnview
Author of XnView
Posts: 32471
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Reduce image to a particular file size

Post by xnview » Tue Feb 07, 2006 7:45 am

SeaMaiden wrote:Currently, the only way I know to get an image at or below a certain file size is by trial and error. I'd like a feature where you can tell XnView to reduce the image to X file size and X file type.

Example 1:

A PNG image file is 3.33KB.
It needs to be 725 bytes or smaller.
You enter into XnView the desired file size you want.
Optionally, you enter also the desired image size (16x16, 24x24, 32x32, 48x48, or a custom size) In this case, 16x16 is too small. I'd like it to be no smaller than 24x24.

Example 2:

A JPG image file is 5MB
It needs to be 1MB or less.
You also want to convert it to GIF at the same time.

XnView automatically changes the file (reducing colors, dpi, or whatever else) to try to get the file to the physical size and pixel size you specify.
Is it the export feature from deluxe?
Pierre.

User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken » Tue Feb 07, 2006 12:55 pm

This can be done with the JP2 formats, and I've seen one prog that can do it with JPGs. It would be difficult to do with PNGs and other lossless formats though since it would involve extra steps such as reducing the colors.

With the export/preivew option that xnview deluxe and a few other programs have, you can see how big the file will be before you actually save it, and can either adjust some settings from there to reduce the filesize, or close it and go back to the main program to make some alterations. (The first option works well for JPGs, the second is usually better for PNGs since it gives you more control over the color reduction and can result in a better looking image.)
Oh the feuhrer, oh the feuhrer, oh the feuhrer's nipples bonk!

User avatar
SeaMaiden
Posts: 63
Joined: Tue Aug 17, 2004 8:36 am
Location: Central California
Contact:

Post by SeaMaiden » Tue Feb 07, 2006 7:53 pm

I am trying to get a good image for mail xfaces for the Thunderbird extension Message Faces. The image MUST be 48x48 PNG under 725 bytes. 16 colors would be good enough. 8 colors would not. Every time I experiment trying to get the image that size with those dimensions, the image quality is unacceptable. I have tried with different images. It's just so much trial and error, and I never know which resampling to use (Lanzcos, Gaussian, Bell, Mitchell, etc.). I am looking for some type of automatic solution as stated above. If XnView can't do this, is there another program you recommend I try to accomplish this?
Tablet Android 4.4 and Mobile Phone Android 4.1.2. No PC at this time.
** XNVIEW ROCKS **

User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken » Tue Feb 07, 2006 8:55 pm

Photoline32 might work (it has an export feature that lets you go down to 16 colors and see the results before saving), but it's shareware/trial.

A tool I find quite useful for fixing up images is Image Analyzer http://logicnet.dk/Analyzer/ (main site at www.meesoft.com). It has a preview feature for PNG, JPG, and JPEG2000, but you can't reduce colors from there. You can however quickly see the filesize without actually saving. IA has a lot of tools designed for enhancing images, one very useful one (especially in this case) is the quantizer. You can reduce the number of colors much more smoothly with the quantizer than by normal color reduction. It also has a so-called "lossy" PNG option which can shave some filesize on photographic images (but doesn't work well on cartoony/logo ones). IA is freeware, and thus might be your best choice.

You could also try xnview deluxe, it has a lot of options and color reduction choices in it's export feature, although the prog is shareware/trial.

If you want, you can post the image or PM it to me and I'll try to tweak it, I'm familiar with getting filesizes down without ruining the pic too much.


Some tips: It might work better not using a filter (ie use nearest neighbor). Failing that, lanczos and hanning are likely to give the best results.
When reducing colors, use the "adaptive" option, not the dither one. Ditheringlooks like crap unless it's done just right, and it bloats the filesize.
Have you tried running your best result through pngout or pnggauntlet? If it's just a little too big, either of those should be able to get it down enough.

Also, 700bytes is a miniscule limit, you won't be able to get too much out of that no matter what you do, and you'll almost certainly have to use multiple progs together to achieve it.
I made this one from your mermaid avatar, it's only about 600bytes: Image
Oh the feuhrer, oh the feuhrer, oh the feuhrer's nipples bonk!

Post Reply