-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
- Load images over the web from an API that will give random images (and they might be WAY oversized).
- Try to resize them so as to not take up too much memory (either in the image cache or when uploading to the GPU). Resize them to fit within a bounding box, but also to maintain their aspect ratio
Expected behavior
You expect to be able to satisfy the use case and only cache the resized images.
Actual behavior
ResizeImage takes a width, a height, or both. You can omit one to have to maintain its aspect ratio and respect the dimension that you gave it. However, this doesn't meet the needs of the use case, because since you don't know the size of the original image, you don't know which dimension will be the limiting dimension. This means you need to first decode the original image into its intrinsic size in order to know which dimensions to give to ResizeImage. But this "pre-decoding" will inadvertently cache the image in its original size.
All in all, it would be very useful to provide an easy way to say "if you tell me the image descriptor info, I'll tell you what target size I want" and to use that facility in ResizeImage