Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

java.io.IOException: Image failed to decode using JPEG decoder #177

Open
Cutta opened this issue Nov 5, 2015 · 5 comments
Open

java.io.IOException: Image failed to decode using JPEG decoder #177

Cutta opened this issue Nov 5, 2015 · 5 comments
Labels

Comments

@Cutta
Copy link

Cutta commented Nov 5, 2015

11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop: Error cropping image: Image failed to decode using JPEG decoder
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop: java.io.IOException: Image failed to decode using JPEG decoder
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.graphics.BitmapRegionDecoder.nativeNewInstance(Native Method)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:126)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.soundcloud.android.crop.CropImageActivity.decodeRegionCrop(CropImageActivity.java:328)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.soundcloud.android.crop.CropImageActivity.onSaveClicked(CropImageActivity.java:290)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.soundcloud.android.crop.CropImageActivity.access$000(CropImageActivity.java:45)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.soundcloud.android.crop.CropImageActivity$3.onClick(CropImageActivity.java:114)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.view.View.performClick(View.java:4247)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.view.View$PerformClick.run(View.java:17728)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.os.Handler.handleCallback(Handler.java:730)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.os.Handler.dispatchMessage(Handler.java:92)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.os.Looper.loop(Looper.java:137)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at android.app.ActivityThread.main(ActivityThread.java:5289)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at java.lang.reflect.Method.invokeNative(Native Method)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at java.lang.reflect.Method.invoke(Method.java:525)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
11-05 11:08:46.154 18450-18450/fightcountdown.netvent.com.countdown E/android-crop:     at dalvik.system.NativeStart.main(Native Method)

and image is this:
http://i.imgur.com/647p8ys.jpg?1

@jdamcd jdamcd added the bug label Nov 20, 2015
@ivanviragine
Copy link

Same here. Sounds like a JPEG and not JPG encoded.

@Sandrichka22
Copy link

I have the same problem. Any solutions?

@Sandrichka22
Copy link

I did a little research and it seems that the BitmapRegionDecoder that this library uses to decode the cropped region has a number of problems which are caused because of the Skia library that BitmapRegionDecoder uses. The Skia library seems to has a number of unfixed bugs and although it displays the vast majority of images properly, there are numerous problems while displaying CMYK JPGs, and/or grayscale PNGs.

One possible solution, according to the creator of another library which is experiencing similar problems because of BitmapRegionDecoder, is to use a custom decoder. It would be great if this problem is solved in the future releases of this library, but frankly I don't know the complexity behind the custom decoder implementation.

Here are some useful links:
https://github.com/davemorrissey/subsampling-scale-image-view/wiki/02.-Displaying-images
https://github.com/davemorrissey/subsampling-scale-image-view/wiki/04.-Custom-decoders

Hope this helps

@ivanviragine
Copy link

This lib is definitely not production ready. You should point this out on the main page.

@meremammal
Copy link

I have managed to get around this problem. BitmapFactory has no problem decoding the image, however BitmapRegionDecoder fails.

When BitmapRegionDecoder fails, I decode the full image using BitmapFactory and then compress to a temp file. Reassign the Uri and then start again.

mtrakal added a commit to mtrakal/android-crop that referenced this issue Mar 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants