Corrupted images
See original GitHub issueWhile I load the images in ListView, some of the images I get are corrupted and shown with half-grayish background. (link attached).
While downloading, I am also saving the image to the disk. Below is the way I’m doing it:
` GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()); builder .setFadeDuration(50) .setProgressBarImage(null) .setPlaceholderImage(R.color.colorPrimaryLightWithMoreAlpha) .setPlaceholderImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
GenericDraweeHierarchy hierarchy =builder.build();
Uri lowResUri= Uri.parse(imageUrl+"_blur");
Uri highResUri= Uri.parse(imageUrl);
imageView.setHierarchy(hierarchy);
ProductImageHelper productImageHelper = new ProductImageHelper();
Uri uriLocal = productImageHelper.getUriForProductImage(context,productId);
ImageRequest localImageRequest = ImageRequestBuilder.newBuilderWithSource(uriLocal).setRequestPriority(priority).build();
ImageRequest hiresImageRequest = ImageRequestBuilder.newBuilderWithSource(highResUri).setResizeOptions(new ResizeOptions((int) context.getResources().getDimension(R.dimen.product_width),(int) context.getResources().getDimension(R.dimen.product_height))).setRequestPriority(priority).build();
ImageRequest lowResImageRequest = ImageRequestBuilder.newBuilderWithSource(lowResUri).setRequestPriority(priority).build();
ImageRequest[] requests = { localImageRequest, hiresImageRequest};
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>> dataSource =
imagePipeline.fetchDecodedImage(hiresImageRequest, context.getApplicationContext());
dataSource.subscribe(new CustomBitmapDataSubscriber(context.getApplicationContext(),productId,highResUri,uriLocal), CallerThreadExecutor.getInstance());
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setLowResImageRequest(lowResImageRequest)
.setFirstAvailableImageRequests(requests)
.setOldController(imageView.getController())
.build();
imageView.setController(controller);
`
in CustomBitmapDataSubscriber, I am removing hiResUri from memory cache and prefetching localuri in memory cache.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Corrupted Image Repair Guide to Recover Damaged Photos ...
Are your photos corrupted? Here's is a guide on why your photos get damaged, how to perform corrupted image repair, and how you...
Read more >Top 10 ways to repair & recover corrupt JPG files - YourStory
One of the simplest way to repair corrupt JPG files is to rename it without changing the file extension (.jpg). Save the image...
Read more >Best Free Methods to Repair Corrupt JPEG Files in 2022
Top Free Ways to Repair Corrupt JPEG Files · Change the Image Format · Repair with Image Editors · Rename the JPEG files...
Read more >Repair Corrupted JPEG/JPG, GIF, TIFF, BMP, PNG or RAW ...
Do-it-yourself recovery of image files. Fix corrupted images. Restore damaged JPEG and JPG files. Recover broken TIFF files. Fix corrupt GIF files.
Read more >(3 Ways) How to Repair Corrupted/Damaged/Broken JPEG Files
Use Another Application to View Images 01:41 Fix 3. Repair Corrupted Image Files Using 4DDiG How to Use 4DDiG to Repair Corrupted/Damaged ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem solved! In my case problem was because
onBindViewHolder
was called before download was completed and i was checking only if file exists and because of that Fresco loads corrupted image (file is created when download starts), for me solution was to check in database if download was completed.@triple-dot any chance you’re doing a similar thing to @prgomet?