Skip to content

instantiateImageCodec resizing issues #59578

Closed

Description

@dnfield

Internal: b/160377720

instantiateImageCodec has some problematic documentation and defaults.

Specifically, the docs currently say:

The targetWidth and targetHeight arguments specify the size of the output image, in image pixels. If they are not equal to the intrinsic dimensions of the image, then the image will be scaled after being decoded. If only one dimension is specified, the omitted dimension will remain its original size. If both are not specified, then the image maintains its real size.

The second to last sentence there is not true - if only one dimension is specified, we scale the other dimension along its aspect ratio.

Additionally, the API is very challenging to use correctly since the caller may not know the intrinsic size of the image. I wrote a proposal to provide that from Dart (issue here: #50022 (comment)), but I think we can pretty easily clean up this API without requiring that.

We should do the following:

  • Update the docs to be accurate
  • Add a parameter to control whether we allow for upscaling of the image, i.e. whether the image should be allowed to be expanded beyond its intrinsic dimensions - and default it to false.
  • Add a parameter to control how the aspect ratio is maintained, if it is maintained at all.

If we can fix these things, #50022 would either be mostly obsolete or could be moved easily to some kind of package status.

/cc @zanderso @chinmaygarde @cbracken

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    a: imagesLoading, displaying, rendering images
    perf: memoryPerformance issues related to memory
    on Jun 16, 2020
  2. added this to the 1.21 - July 2020 milestone on Jun 16, 2020
  3. self-assigned this
    on Jun 16, 2020
  4. added
    d: api docsIssues with https://api.flutter.dev/
    on Jun 16, 2020
  5. dnfield commented on Jun 29, 2020

    @dnfield
    ContributorAuthor

    Considering an alternative here: creating a new dart:ui API surface for obtaining and decoding images.

  6. added
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    on Jul 9, 2020
  7. dnfield commented on Jul 21, 2020

    @dnfield
    ContributorAuthor

    Rather than adding a parameter, I've refactored the way this works. I'll file a new bug to expose this up through the framework, but the engine side work is done with #19537

  8. github-actions commented on Aug 18, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Aug 18, 2021
  10. added
    P0Critical issues such as a build break or regression
    and removed on Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: imagesLoading, displaying, rendering imagesc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: crowdAffects or could affect many people, though not necessarily a specific customer.customer: money (g3)d: api docsIssues with https://api.flutter.dev/engineflutter/engine related. See also e: labels.perf: memoryPerformance issues related to memory

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions