# Scaling image in image component, but maintaining ratio

**URL:** <https://forum.inductiveautomation.com/t/scaling-image-in-image-component-but-maintaining-ratio/16216>\
**Category:** Ignition\
**Created:** [December 5, 2017, 10:26am UTC](https://forum.inductiveautomation.com/t/scaling-image-in-image-component-but-maintaining-ratio/16216 "2017-12-05T10:26:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [December 5, 2017, 10:26am UTC](https://forum.inductiveautomation.com/t/scaling-image-in-image-component-but-maintaining-ratio/16216/1 "2017-12-05T10:26:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JHortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@JHortenberry](https://forum.inductiveautomation.com/u/JHortenberry)\
**Post date:** [June 29, 2018, 3:53pm UTC](https://forum.inductiveautomation.com/t/scaling-image-in-image-component-but-maintaining-ratio/16216/2 "2018-06-29T15:53:45Z")

</div>

Did you obtain a solution for your question?

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 29, 2018, 4:14pm UTC](https://forum.inductiveautomation.com/t/scaling-image-in-image-component-but-maintaining-ratio/16216/3 "2018-06-29T16:14:57Z")

</div>

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