in reply to Re^2: How to create JPEG of specified size
in thread How to create JPEG of specified size

halley,
The fake file has to be a valid JPEG and the purpose for needing this has nothing to do with web servers. If you have any ideas on how to manipulate an dummy image through trial and error to reach an approximate target size I would be most appreciative.

Cheers - L~R

  • Comment on Re^3: How to create JPEG of specified size

Replies are listed 'Best First'.
Re^4: How to create JPEG of specified size
by halley (Prior) on Jul 25, 2007 at 19:12 UTC
    Pseudocode, since I don't have ImageMagick installed here.
    # load original image (lena.jpg) # get original image's geometry # do # inflate dimensions by 1.2* # resize image to target geometry # add a little scatter noise to the image # set target quality to a high number like 99 # save target image (lenna.jpg) to disk # while (target image file size is too small);
    The scatter noise and quality numbers are to frustrate jpeg's compression as the image grows.

    Are we talking gigabytes of disk space? I think jpeg as a format will break at 2^15 (or maybe 2^16) pixel dimensions.

    --
    [ e d @ h a l l e y . c c ]