Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr.Image fullscreen button does not scale the image but scales the EventData #10268

Open
1 task done
Zarxrax opened this issue Dec 30, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@Zarxrax
Copy link

Zarxrax commented Dec 30, 2024

Describe the bug

When I load an image into gr.Image which is smaller than my screen, and I press the fullscreen button, the image remains the same size and surrounded by black borders, rather than being enlarged to fill the screen. I would expect the fullscreen button to make the image larger, otherwise, what is the point?

However, I noticed that when in fullscreen mode, the EventData x/y coordinates DO get scaled as if the image is fullscreen, which breaks use cases where you need to obtain the clicked coordinates.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

# Define a function to handle the image click event
def handle_click(image, event_data: gr.SelectData):
    # Extract the coordinates from the event data
    x, y = event_data.index
    # Return the coordinates as a string
    return f"Clicked at coordinates: ({x}, {y})"

# Create a Gradio Blocks app
with gr.Blocks() as demo:
    # Add an Image component for the user to upload an image
    image_input = gr.Image(label="Upload an Image")
    # Add a Textbox to display the coordinates
    coordinates_output = gr.Textbox(label="Coordinates")
    # Attach the click event to the image input
    image_input.select(handle_click, [image_input], coordinates_output)

# Launch the app
if __name__ == "__main__":
    demo.launch(show_error=True)

Screenshot

No response

Logs

No response

System Info

Operating System: Windows
gradio version: 5.9.1
gradio_client version: 1.5.2

Severity

I can work around it

@Zarxrax Zarxrax added the bug Something isn't working label Dec 30, 2024
@abidlabs
Copy link
Member

When I load an image into gr.Image which is smaller than my screen, and I press the fullscreen button, the image remains the same size and surrounded by black borders, rather than being enlarged to fill the screen

My understanding is that the image itself needs to be sufficiently large, otherwise blowing it up to be full screen will result in a low-res blurry image. cc @hannahblair for confirmation

However, I noticed that when in fullscreen mode, the EventData x/y coordinates DO get scaled as if the image is fullscreen, which breaks use cases where you need to obtain the clicked coordinates.

This is a bug! We should fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants