label-studio icon indicating copy to clipboard operation
label-studio copied to clipboard

Add a new column for image size (x,y dimensions in pixels)

Open uni-kod opened this issue 7 months ago • 3 comments

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!

uni-kod avatar May 17 '25 11:05 uni-kod

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:

  1. Install dependencies if you haven’t already:

    pip install label-studio-sdk pillow requests

  2. 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)

  3. In Label Studio’s Data Manager, click Columns on the right and toggle on your new width and height columns. 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

heidi-humansignal avatar May 22 '25 13:05 heidi-humansignal

Thank you, let me know if I can help in something for the community, I have C, C++, Python experience.

uni-kod avatar May 23 '25 09:05 uni-kod

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

heidi-humansignal avatar Jun 03 '25 14:06 heidi-humansignal