Link to home
Start Free TrialLog in
Avatar of hagur
hagur

asked on

Makings JPEGs smaller ...

I have a simple code which takes screenshots in bmp format, converts them to jpg by assigning the picture from the TBitmap to a TJPEGImage and then saving the file to disk.

I generally get files that are 40-50kb when screenshots are taken at 1024*768 in 32 bit color.  Does any of you have any routines to make those files smaller, either by resampling them to a smaller size or decreasing the quality?
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
listening :o)
Note that 40-50kb for a 1024*768 image is already quite a strong compression, and compressing more will certainly lower the visual image quality quite a lot.

If you really need smaller (bytewise) images, try resizing the bitmap to half the size in both horizontal and vertical direction (512*284 pixels) and you should get images of about 10-15k with the same compression ratio.
Avatar of edey
edey

Do you need to make just one screen shot smaller, or are you taking several shots & need the total to be smaller?

GL
Mike
Avatar of hagur

ASKER

I will try your methods.

Edey:

I am taking screenshots at a regular interval, and I'd want each screenshot to be smaller, if possible.  I have not tried setting the CompressionQuality on the TJPEGImage

Thanks.
I'm just wondering because it may be possible to make use of that. If the contents of the screen shot don't change a whole lot you could try something like this:

1)take first snapshot
2)take second, xor the bits against the first & use something like zlib to compress the image. if there's no change this should be effecient as there'll be many consecutive zeros to highly compress.
3)take third, xor against the second ....
...
n)take nth shot, xor against n-1th shot ....

I haven't tested such a scheme, but it's a different approach that may yeild better results.

GL
Mike
Or if you're getting a high degree of change you migh look to actually use some sort of movie codec - lot's of reasearch on making big movies smaller these days :).

GL
Mike
Mike, the idea to detect and store only changed parts in a sequence of images if being used in most video codecs. However, the problem is that with the lossy JPEG compression, the image will look MUCH worse with each time you do this step since the modification will be in relation to an already "unclear" image. That's where key frames are used: these are full images, from where the "modifications" can be made again.

Especially for screen contents, which doesn't compress this well in high quality as JPEG when there is much information on it (like texts etc.), this method is not very prectical, but a non-lossy method with change detection as described by you would work better.
Avatar of hagur

ASKER

Hi guys,

I want to thank you for all your input, greatly appreciated.

I tried using the CompressionQuality like EddieShipman suggested ... I can't see why I didn't notice this method myself before.  Anyways, when I set the quality to 35% I was able to get a very acceptable image and only ~27kb.

This will be more than enough for now atleast.

Thanks again!