Local image with exif rotation and ResizeOptions display's wrong
See original GitHub issueDescription
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
Without resizing everything works fine
Additional Information
- Fresco version: 1.9.0
- Platform version: Android 8.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top 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 >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
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?
This issue should be fixed. If it is still an issue, please let us know.