Christian
Christian

Reputation: 7310

How to detect if JPG is in RGB (or CMYK) format?

I need a (really fast) way to check if a JPG file is in RGB format (or any other format that Android can show).

Actually, at this moment, I just know if a JPG file can be show when I try to convert it to Bitmap using BitmapFactory.

I think this should not be the fastest way. So I try to get it by using ExifInterface. Unfortunately, ExifInterface (from Android) does not have any tag that indicates that the jpg can be shown in Android (color space tag or something).

Then, I think I have 2 ways:

1) A fast way to get bitmap from jpg: any tip of how to do it?

2) Or try to read Exif tags by my self, but without adding any other lib to the project: I don't have any idea of how to do it!

Upvotes: 2

Views: 5511

Answers (1)

Larry McKenzie
Larry McKenzie

Reputation: 3283

Ok so I did some looking around and I may have a solution for you but it may require a little work. The link is a pure java library that I think you can use in your project or at least modify and include a few classes. I have not worked with this yet but it looks like it will work.

http://commons.apache.org/proper/commons-imaging

final ImageInfo imageInfo = Imaging.getImageInfo(File file);
if(imageInfo.getColorType() == ImageInfo.COLOR_TYPE_CMYK){

}
else {

}

Upvotes: 2

Related Questions