Image Storage - Optimization

J. Landman Gay jacque at
Mon Mar 20 16:19:51 EST 2006

Sivakatirswami wrote:
> This is a spin off from my earlier thread on DRM for images in  stacks.  
> In experiments with putting compressed imageData into a  custom prop I 
> discovered it bloated the size of the stack. I then  tested "recovery" 
> of that data to an original jpeg size, with some  very interesting 
> results, possibly "stumbling" on an optimization  feature, I may need my 
> eyes tested, or at least try this same test on  images with intricate 
> "edges" and  with photos of peoples faces...

Someone with more knowledge should really address this, but what I think 
is happening is that you are trying to compress an image that is already 
compressed, which can actually add size to the file rather than decrease it.

> 1) import 3 X 5 imag 80k .jpeg (in this case  NASA space shot)
> 2) Scale the image way up on the card  (4 times)  so it becomes the  
> whole background  of the card
> 3) save stack: stack size: 80 K

This image was probably already compressed with jpg compression to 80K, 
and was much bigger when expanded.

> 4) set the uStuff of this card to compress(the imageData of img 1)
> put "" into img 1
> 5) save stack: stack size 1.2meg! ouch!

Here's where I'm guessing, but it may be that what you are compressing 
is the fully expanded jpg rather then the stored compressed version. I'm 
not sure though. Someone else may know.

> 6) try to recover:
> 7) set the imageData of img 1 to decompress(the uStuff of this card)
> 8) scale down the image to 3 X 5
> 9) set JPEGcompression to 40
> 10) export image 1 to someFile.jpg as JPEG; delete image 1
> 11) export image on disk is only 27K!

You've changed both the compression ratio, apparently to a tighter 
compression, and the original size of the image, which reduces its file 

> 12) import someFile.jpg back into the stack, save stack
> 13) stack size 27 k!

When you re-import, you've imported a more tightly compressed and 
smaller jpg.


> I cannot see *any* difference in the two images! but one stack is 80K  
> and the second one is 27K.

For photos, I've found that you can set the jpg compression to a very 
tight amount without losing much quality at all. It doesn't work so well 
with images that contain line drawings, for example, but photos are 

I think in your situation it would work very well to open your images in 
an image editor, scale them down to a smaller size, re-save them at very 
tight compression, and then import them into your stack. Set the custom 
property to the imageData without using any Rev compression at all; the 
original file size  should be retained. When you display the image in an 
image object in the stack, Rev will automatically decompress it and 
expand it to its full size for display, leaving the original property alone.

If you need to set the display size to something larger than the 
original size, do that after you've put the imagedata into the image 
object. Set the lockloc of the image object to true and then set its 
height and width to what you want. Rev will scale it for display without 
changing the size of the stored imagedata property.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list