Target file size when compressing images

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Formadores
Posts: 2
Joined: Thu Jan 22, 2015 1:49 pm

Target file size when compressing images

Post by Formadores »

Hi. I use a database in access wich was pictures. Those are compressed using vba code and nconvert.exe before they are in the database to dissalow big file sizes. The method i'm using is iterating the file size each time i compress that file with nconvert.exe. If file size after last compression is still bigger than xxxx bytes, then the code goes on again...

That is useful, but in some point, the pictures normally :
- have a very very very little filesize (like 10Kb -> changing the size of the picture by 50% each iteration and making the image "unviewable")
- have poor quality (because I reduce only in about 5% each iteration, but as its needed a lot more of iterations to filesize gets the size i want, all the optimizations are made as much as iterations are made)

I'll try an example:
I have a file 1024x768px with a current filesize of 2Mb. My target size will be 90Kb...
do while (filesize>90kb)...
nconvert.exe -overwrite -rtype lanczos -autolevels -resize 50% 50% """ & completefilenamepath & """"
loop

(in a raw manner, that's what im doing... the problem is as described above... can u help me?)

Is there any command line switch that i could use to specify a target final file size? (and that way, i wouldn't use iterations anymore, degrading the overall quality each time an iteration is made)

Thankx,

Tiago
obelisk
Posts: 465
Joined: Fri Jan 09, 2009 9:54 am

Re: Target file size when compressing images

Post by obelisk »

No there isn't. And the feature doesn't make sense. You should be using temp files anyway.
User avatar
XnTriq
Moderator & Librarian
Posts: 6354
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Target file size when compressing images

Post by XnTriq »

[color=green]nconvert.exe -help[/color] wrote:-max_filesize value: Maximum filesize (JPEG2K)
RIOT (Radical Image Optimization Tool) allows you to “compress files to desired filesize threshold”:
Formadores
Posts: 2
Joined: Thu Jan 22, 2015 1:49 pm

Re: Target file size when compressing images

Post by Formadores »

XnTriq wrote:
[color=green]nconvert.exe -help[/color] wrote:-max_filesize value: Maximum filesize (JPEG2K)
RIOT (Radical Image Optimization Tool) allows you to “compress files to desired filesize threshold”:
Perfect!!! Thanks!

Tiago