BioGeek
BioGeek

Reputation: 22907

Reading quantization tables of jpeg files on Android

A previous answer provides code for reading the quantization tables of jpeg files in Java. However it uses javax.imageio.ImageIO which, according to this answer, isn't available on the Android platform.

How can I read read the quantization tables of jpeg files on Android in Kotlin or the Java subset available on Android?

edit

I have found the korlibs/korim Kotlin library which seems to read the quantization tables. But I'm still a beginner with Kotlin so I haven't yet figured out how I go from a string with the path to the JPEG file to printing out the quantization table.

Upvotes: 1

Views: 295

Answers (2)

Vitaliy Shibaev
Vitaliy Shibaev

Reputation: 1450

If you only need to read quantization tables then the simplest solution would be to implement parsing yourself. Basic sample (in C#; but Java/Kotlin implementation is pretty similar): https://stackoverflow.com/a/46162800/136138

This conversation might also be useful: JPEG file quantization table definition


If you need to do more JPEG-related operations then look at JpegKit that wraps the native libjpeg-turbo library.

Upvotes: 1

Harald K
Harald K

Reputation: 27113

I am, unfortunately, not aware of such an API for Android.

However, parsing the JPEG quantization tables aren't that hard... You could probably have a look at my JPEGSegmentUtil and QuantizationTable (originally by Helmut Dersch) classes and adapt them to Android. The mentioned code is available under BSD license.

You would need to replace the javax.imageio.ImageInputStream with a different type, preferably something that implements java.io.DataInput and has proper seek/skip, replace javax.imageio.IIOException with normal IOException, and perhaps a few more tweaks.

Upvotes: 2

Related Questions