'Windows photo viewer does not open bitmap compressed images from Android studio

I am using android custom camera to captured JPG images, But not able to preview them on windows photo viewer. Can anyone please advise. Images are visible using other applications like Ms Paint, Office, Windows 10 Photo application.

enter image description here



Solution 1:[1]

This is obviously caused by an ICC color profile that will be added to the bitmaps by Android. The Windows photo viewer isn't capable to show the images with that ICC color profile.

I did not find out yet how this ICC profile is being generated, I assume that this is done by the Android Bitmap.compress function.

Removing the profile with e.g. ImageMagick will "repair" the files and they will open in photo viewer too.

Solution 2:[2]

As of Android 10, Bitmap.compress() seems to have added an ICC profile.

This issue was caused by an incorrect version value in the added ICC profile. This issue was reported and fixed on the skia issue tracker. I don't know when it will be fixed on Android.
https://bugs.chromium.org/p/skia/issues/detail?id=12491

So, deleting the ICC profile from the jpeg image generated with Bitmap.compress() seems to be the best way at the moment. To solve it programmatically, you need to parse the JPEG data generated with Bitmap.compress() to delete the ICC profile segment.

Solution 3:[3]

Other Answers to this Question already explained the Issue which may be induced by some Bug related to the Image Compression techniques adopted by Android, preventing the image to be Opened in Windows Photo Viewer.

I have reported this issue to Google and Android Community multiple times but even after following many Android Upgrades, this issue still persist.

I understand this problem is irritating and in the wake of no direct solution, I wish to share an easy and reliable turnaround to this problem with Open Source Softwares which are reliable.

  1. For a Single Image, use GIMP to open the Image and then Export (CTRL+SHIFT+E) the image as it is while replacing the existing file. Export image pop up in GIMP

  2. For Multiple Images, use CAESIUM Image Compressor with Quality set to 100%. Caesium Image Compressor Windows

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hschottm
Solution 2 Blue Ocean
Solution 3 Anubhav Yadav