Scaling image in image component, but maintaining ratio

I’m trying to display an image from a network share (a printer preview), but I have no prior information on the scale of the image.

I’m currently using the image component with a file URL pointing to the filesystem.

Is it possible to scale the image so it fits inside image component, but keeps its aspect ratio?

F.e., if I make a 500x500 image component, a 1000x200 image should shrink to 500x100. And a 200x1000 image would shrink to 100x500. I don’t really care about upscaling at the moment.

I’ve tried the different stretch modes, but

  • No stretch results in cropping the image instead of scaling it
  • Bounds and % Bounds don’t maintain the aspect ratio but scale to the container
  • I can’t use Parameters as I don’t know the image size

Is there some other setting I can use, or a different trick?

1 Like

Did you obtain a solution for your question?

Nope, I ended up hardcoding a few sizes based on the image names.