You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Take a portrait picture with your phone
Import in label-studio (the image is correctly shown in label-studio)
Add one annotation on this picture
Export project with "Coco export"
Open result.json from exported zip file
See that image width and height are incorrect.
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):
OS: Debien
Label Studio Version: 1.14.0
How to bypass the bug
I checked database in .local/share/label-studio/label_studio.sqlite3 everything about my image seems correct.
I opened .local/share/label-studio/upload/1
My image is correctly (correct orientation) shown when I open it with default debian image viewer
When I open the image with gimp, Gimp advise me to rotate image according to orientation. So yes "original image" is 90° incorrect. But when Gimp applied image orientation, then image is correct. So I overwrite image with Gimp. Then the Coco Export work great for this image. But I was having errors on all other portraits images
Finally I run command "mogrify -auto-orient *.jpg" in folder .local/share/label-studio/upload/1 to fix all images orientation. Then Coco export worked perfectly
The text was updated successfully, but these errors were encountered:
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'smogrifyTool:
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.
Re-import and Annotate:
After running the command, the images will have the correct orientation embedded in the actual image data.
Import the images into Label Studio and proceed with your annotations as usual.
Exporting Annotations:
When you export your project using the COCO format, the image dimensions in the result.json file should now be correct, reflecting the proper width and height.
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
The text was updated successfully, but these errors were encountered: