How to get png images using Cordova 3.5 on Android

I am trying to get a PNG image using cordova-plugin camera with this code:, onFailPict, { quality: 50, encodingType:Camera.EncodingType.PNG,});


But it always returns a JPG file. Did anyone manage to get the PNG on Android?

Looking at the source of the android java plugin in l.390 and many other places the ".jpg" seems to be hardcoded:

uri = Uri.fromFile(new File(getTempDirectoryPath(), System.currentTimeMillis() + ".jpg"));


I tried to replace ".jpg" with ".png" but of course only change the name of the extension.


source to share

1 answer

Well, I was not that far from a solution. A few lines below in processResultFromCamera () (l.413) the jpeg link is also hardcoded

bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);


which I replaced with:

if (this.encodingType == JPEG) {
    bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
else if (this.encodingType == PNG) {
     bitmap.compress(Bitmap.CompressFormat.PNG, this.mQuality, os);


So the doc plugin is wrong. PNG is not supported for Android. And I dont know more about github for code fix



All Articles