Add a new column for image size (x,y dimensions in pixels)
Hello, can you please add a new column to show image size (x,y dimensions in pixels), there are columns like ID, Inner ID, Storage filename..., but there is no column for image size. Thank you for this great project!
Thanks for the suggestion! Right now, Label Studio doesn’t include image dimensions as part of the task data, so there’s no built-in Image Size column in the Data Manager. We’ll log this as a feature request—it requires a check; maybe this function is not implemented yet.
In the meantime, you can add width/height yourself using the Label Studio SDK and then enable those as columns:
-
Install dependencies if you haven’t already:
pip install label-studio-sdk pillow requests
-
Run a script like this to fetch each task’s image, read its size, and update the task data:
from label_studio_sdk import LabelStudio from PIL import Image import requests, io # Connect to your Label Studio instance ls = LabelStudio(base_url=LABEL_STUDIO_URL, api_key=API_KEY) project = ls.project.get(PROJECT_ID) tasks_to_update = [] for task in project.get_tasks(): img_url = task['data'].get('image') if not img_url: continue resp = requests.get(img_url, stream=True) img = Image.open(io.BytesIO(resp.content)) w, h = img.size tasks_to_update.append({'id': task['id'], 'data': {'width': w, 'height': h}}) # Batch update tasks (100 at a time) for batch in [tasks_to_update[i:i+100] for i in range(0, len(tasks_to_update), 100)]: project.update_tasks(batch)
-
In Label Studio’s Data Manager, click Columns on the right and toggle on your new
widthandheightcolumns. Let me know if you run into any issues with the script or if you’d like status on the native column request!
Thank you, Abu
Comment by Abubakar Saad Workflow Run
Thank you, let me know if I can help in something for the community, I have C, C++, Python experience.
Hello,
If you want you can create a PR to help display this in the UI as well. It would require some understanding of JS (React)
Thank you, Abu
Comment by Abubakar Saad Workflow Run