Forum Moderators: coopster

Message Too Old, No Replies

resize an image by filesize

         

ironik

11:44 pm on Apr 3, 2005 (gmt 0)

10+ Year Member



Just wondering if anyone knows any neat little tricks to resize an image to fit within a specified filesize. My client runs a gallery website and is not computer savvy. What I'm trying to achieve is the ability for the client to upload an jpeg in any size, then automatically resize the image to a maximum file size (say it's a 1.2mb jpeg, and I want to change that to a 200kb jpeg).

I very familiar with restricting pixel dimensions, or preventing files of a certain size from being uploaded... I guess what I need is help finding something that will do a 'guestimate' and re-size/re-sample without resorting to a more intensive loop that creates multiple versions of the image.

jatar_k

4:34 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think I would go by a max dimension and then bind them to a certain quality.

can't really think of a way to set it to a max filesize with out actually creating the file

ironik

9:56 pm on Apr 4, 2005 (gmt 0)

10+ Year Member



Thanks jatar_k, I'll probably just dodgy it up by finding a percentage, resizing and checking the filesize. I might get lucky with a loop that only has to run once.