Yalantis / uCrop

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

CImg<unsigned char>::load(): Failed to recognize format of file #140

Closed jtyang closed 7 years ago

jtyang commented 8 years ago

07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: java.io.IOException: [instance(0,0,0,0,0x0,non-shared)] CImg::load(): Failed to recognize format of file '/storage/emulated/0/Mob/com.nono.android/cache/images/acf956da88368898762ede6c90c3c372.jpg'. 07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: at com.yalantis.ucrop.task.BitmapCropTask.cropCImg(Native Method) 07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: at com.yalantis.ucrop.task.BitmapCropTask.crop(BitmapCropTask.java:139) 07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:88) 07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: at com.yalantis.ucrop.task.BitmapCropTask.doInBackground(BitmapCropTask.java:30) 07-05 21:25:32.686 22919-22919/com.nono.android W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295) 07-05 21:25:32.687 22919-22919/com.nono.android W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 07-05 21:25:32.687 22919-22919/com.nono.android W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 07-05 21:25:32.687 22919-22919/com.nono.android W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 07-05 21:25:32.687 22919-22919/com.nono.android W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 07-05 21:25:32.687 22919-22919/com.nono.android W/System.err: at java.lang.Thread.run(Thread.java:818)

shliama commented 8 years ago

Can you please attach the image so I can reproduce this error?

jtyang commented 8 years ago

a Sorry,Maybe the file has been damaged, use ucrop can open the file and preview success at UCropActivity, but when cutting out the exception. In addition, I use the system application Intent can be successful crop.

Thanks!

ghost commented 8 years ago

i got this problem too ,here is my detail message ;

CImg::load(): Failed to recognize format of file '//storage/emulated/0/netease/lofter/LOFTER/download20160816000508.jpg'.

through step by step debug , we find out that "BitmapCropTask" inner native method

native public boolean cropCImg(String inputPath, String outputPath, int left, int top, int width, int height, float angle, float resizeScale, int format, int quality, int exifDegrees, int exifTranslation) throws IOException, OutOfMemoryError;

i open the file on Mac it shows file damaged ,can not open the picture.

shliama commented 8 years ago

Something is clearly wrong with the attached photo. It cannot be opened on my mac via several programs, also I cannot open it my Android device via DropBox image preview and several others. However I can open it via Google Photos and uCrop can decode it into a Bitmap and show in the image view.

uCrop uses native library (which uses ligjpeg & libpng under the hood) cannot recognise the format too, that's why you see the error. You can either use version 1.5.0 that doesn't make use of native code (but having problems with high resolution images), or try to figure out, why there are is so much trouble with that image.

coolmu commented 7 years ago

but I found other tool can crop the attached photo

TeeRawk commented 7 years ago

outdated