Open Binnette opened 2 weeks ago
Hello,
The problem you're experiencing is due to how image orientation metadata (EXIF data) is handled. When you take a portrait photo with your phone, the image file is often saved with the original data in landscape orientation and includes an EXIF orientation tag that instructs image viewers to display it rotated. While Label Studio displays the image correctly by respecting this metadata, the COCO export process retrieves the image dimensions directly from the file without accounting for the EXIF orientation. This results in the width and height being swapped in the result.json
file.
Workaround Solution:
To resolve this issue, you can preprocess your images to apply the EXIF orientation before importing them into Label Studio. This involves rotating the actual image data to match the desired orientation and removing the EXIF orientation tag. Here's how you can do it:
Using ImageMagick's mogrify
Tool:
Before importing your images into Label Studio, run the following command in the directory containing your images:
mogrify -auto-orient *.jpg
This command rotates all JPEG images to the correct orientation based on their EXIF metadata and updates the images accordingly.
result.json
file should now be correct, reflecting the proper width and height.Thank you, Abu
Comment by Abubakar Saad Workflow Run
Hi Abu, thank for the workaround. I hope this bug will be fixed in future. Have a nice day.
Describe the bug When I export with "Coco export". The resulting "result.json" contains bad image width and height. In fact this export do not respect image orientation. So It set width as height and height as width.
To Reproduce Steps to reproduce the behavior:
Expected behavior Coco export should rotate image according to image orientation before getting its size and height (the ones that are set in result.json)
Environment (please complete the following information):
How to bypass the bug