Yalantis / uCrop

Image Cropping Library for Android
https://yalantis.com/blog/introducing-ucrop-our-own-image-cropping-library-for-android/
11.87k stars 2.16k forks source link

Change image channels in compression #179

Open amosyuen opened 8 years ago

amosyuen commented 8 years ago

When I use options

setCompressionFormat(Bitmap.CompressFormat.JPEG); setCompressionQuality(100);

and select a PNG image, the image I get back can't be loaded by server JPEG library https://github.com/EyalAr/lwip. It gives me an error "Unsupported number of channels"

Looking at https://github.com/EyalAr/lwip/issues/69 sounds like the issue is that the image has 4 channels (CMYK).

Please either change the channels for JPEG compression, or add some behavior to set number of channels in the compression.

Note: Android's Bitmap compress() function sets the number of channels to 3, which can be decoded by the aforementioned library.

shliama commented 8 years ago

Hi @amosyuen and thanks for the issue. I need to research this, and maybe contact with developers of native library that I use.

As an easy workaround you can use uCrop version 1.+ for a while because it uses just Android sdk to work with the bitmap.