If you need the image to resize with the window while keeping its aspect ratio, the easiest approach is to turn on layout-wide Auto-Scaling (right-click the editor background → Auto-Scaling) so everything scales together. That already preserves ratios for you.
If you still want manual control, enable Advanced Sizing on the image and drive its width/height with placeholders that use the screen size and your image’s aspect ratio. For example:
{"placeholder":"calc","values":{"decimal":"false","expression":"({"placeholder":"guiwidth"} - 40)"}}
for width and then calculate height with the ratio (e.g., if the image is 16:9):
{"placeholder":"calc","values":{"decimal":"false","expression":"({"placeholder":"guiwidth"} - 40) * 9 / 16"}}
That way the image grows/shrinks when the window resizes and keeps the same ratio. You can also combine those expressions with min/max limits if needed.
(If you’re not comfortable with calculator placeholders yet, the Advanced Positioning & Sizing doc explains how to plug in screen width/height values safely.)