Reducing image file sizes

J. Landman Gay jacque at hyperactivesw.com
Mon May 18 23:36:02 EDT 2009


Jim Bufalini wrote:

> FUNCTION ReduceImage pData
>   local tWidth,tHeight
>   constant kMaxSize = 800
>   constant kJpegQuality = 60
>   -----
>   put the jpegquality into tJpegQuality
>   create invisible image "Temp"
>   set the text of image "Temp" to pData
>   put the formattedwidth of image "Temp" into tWidth
>   put the formattedheight of image "Temp" into tHeight
>   -----
>   IF tWidth > kMaxSize OR tHeight > kMaxSize THEN
>     IF tWidth > tHeight THEN
>       set the width of image "Temp" to kMaxSize
>       set the height of image "Temp" to round(tHeight * (kMaxSize/tWidth))
>     ELSE
>       set the height of image "Temp" to kMaxSize
>       set the width of image "Temp" to round(tWidth * (kMaxSize/tHeight))
>     END IF
>     set the jpegquality to kJpegQuality
>     export image "Temp" to pData as JPEG
>   END IF
>   delete image "Temp"
>   set the jpegquality to tJpegQuality
>   return pData
> END ReduceImage

Thanks. This is similar to what I had in mind for the final output, only 
I was going to just save enough imagedata to account for a decent 
printout at the document's actual size. The problem is though -- what is 
the document's actual size?

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list