New-UDImage Resizing

When using New-UDImage, it pulls the image from the URL correctly, but retains the full size of the image. Is there a way to force New-UDImage to resize it to fit the element it’s in and keep the aspect ratio? I know it supports the height and width parameters, but if the image changes, the new image becomes distorted due to different aspect ratios.

Product: PowerShell Universal
Version: 4.0.6

You could look at using a dynamic region, e.g use some code to ‘get’ the image first, confirm it’s size, apply the ratio at the size you want and build a hashtable/splat for the new-udimage command.

Thanks for the thought. I solved this using this function. Basically, I take the URL of the image in a form, download the image locally to the server PSU runs on, using the Resize-Image function to change it’s size, then update my table with the location of the resized image on disk.

This way I can do away with New-UDImage height/width, and handle it during the Resize-Image process.