vertti
vertti

Reputation: 7879

Optimize JPG images in memory with Java

I have REST service that allows users to upload images and then serves those images. The images are stored to a database. I'd like to do JPG optimization for these images.

There's several command line tools to do this but I'd like to do it without first saving them to disk and then running some command-line tools. I'd rather use some Java library to directly operate on a binary stream that contains the image data.

What I'm after is a treatment similar to what for example Trimage does:

Is this possible?

Upvotes: 1

Views: 662

Answers (1)

user3344003
user3344003

Reputation: 21607

It is possible to remove extraneous APPn and COM markers from the data stream. You can do that without expanding and recompressing.

Each time you expand and decompress with different quantization tables, you loose data in JPEG. There is no real point in decompression.

Yes to question #1. No to question #2.

Upvotes: 1

Related Questions