question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local image with exif rotation and ResizeOptions display's wrong

See original GitHub issue

Description

I have image, token with samsung camera and placed on sd-card. File EXIF rotation is ORIENTATION_ROTATE_90 (6). If I add ResizeOptions to ImageRequestBuilder, the image looks compressed by vertical.

Reproduction

Here is the sample file https://www.dropbox.com/s/fsixt3lfbw6zqiv/Exif270.jpg?dl=0 Place it to sd-card root

And here is code

public class MainActivity extends AppCompatActivity {

    private static String[] PERMISSIONS_STORAGE = {
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Fresco.initialize(this);

        verifyStoragePermissions(this);

        SimpleDraweeView simpleDraweeView = new SimpleDraweeView(this);
        simpleDraweeView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        File file = new File("/storage/emulated/0/Exif270.jpg");
        ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(
                Uri.fromFile(file)).setResizeOptions(ResizeOptions.forDimensions(100, 300));
        PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequestBuilder.build());
        simpleDraweeView.setController(controllerBuilder.build());
        setContentView(simpleDraweeView);
    }

public static void verifyStoragePermissions(Activity activity) {
        int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (permission != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, 1);
        }
    }
}

Screenshot of result resize-bug

Without resizing everything works fine

Additional Information

  • Fresco version: 1.9.0
  • Platform version: Android 8.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
dmitrychistyakovcommented, Jul 25, 2018

Hello, I investigated issue a bit and have some new details.

The problem is in exif thumbnail of the photo. Fresco uses exif thumbnail if resize options below 512x512 (LocalExifThumbnailProduser)

This produser uses getThumbnail() method of ExifIterface to get image bytes directly from exif thumbnail.

For my particular case this thumbnail is compressed and has wrong dimentions, so exif thumbnail width = 512 exif thumbnail height = 384 and at the same time exifInterface.getAttribute(ExifInterface.TAG_IMAGE_WIDTH) = 1920 exifInterface.getAttribute(ExifInterface.TAG_IMAGE_HEIGHT) = 1080

As you can see thumbnail is not valid for this case.

I think it is vendor camera problem, but still, maybe is’t good approach to compare aspect of the thumbnail and real image size in LocalExifThumbnailProducer.canProvideImageForSize and return false here if aspects are not same in some approximation?

0reactions
oprisnikcommented, Mar 10, 2021

This issue should be fixed. If it is still an issue, please let us know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Images being displayed in wrong orientation - Stack Overflow
I'm guessing the OP is having problems due to EXIF data. If the original images contain EXIF data indicating that they should be...
Read more >
image rotation is on wrong direction - General Support
When I upload the image to image field - image gets rotation in wrong direction. ... you said EXIF data is lost, so...
Read more >
39905 – Image Resizer API - WebKit Bugzilla
Derive EXIF orientation metadata from image and rotate image ... API: Use Cases: Begin with a user giving a local image file to...
Read more >
GraphicsMagick GM Utility
Name Mode Description 3FR r‑‑ Hasselblad Photo RAW 8BIM rw‑ Photoshop resource format 8BIMTEXT rw‑ Photoshop resource text format
Read more >
Image Processing | Hugo
The image resource also, since Hugo 0.58, implements the method Exif and Filter . Resize. Resizes the image to the specified width and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found