Skip to content

Unable to use ResizeImage effectively when you don't know the aspect ratio of the image ahead of time #118543

@tvolkert

Description

@tvolkert

Steps to reproduce

  1. Load images over the web from an API that will give random images (and they might be WAY oversized).
  2. 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

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagesc: performanceRelates to speed or footprint issues (see "perf:" labels)frameworkflutter/packages/flutter repository. See also f: labels.perf: memoryPerformance issues related to memory

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions