fluttercandies / flutter_photo_manager

A Flutter plugin that provides images, videos, and audio abstraction management APIs without interface integration, available on Android, iOS, macOS and OpenHarmony.
https://pub.dev/packages/photo_manager
Apache License 2.0
681 stars 311 forks source link

[How to use] how to correctly set "image size constraint" in filter option #1069

Open Hyffer opened 9 months ago

Hyffer commented 9 months ago

Platforms

dart, Android

Description

I am on version 2.7.2, and now deal with some pictures with 0 width 0 height. (I don't know why it is recognized as 0w0h, but It is a picture, which shows in my phone's native gallery app)

I have noticed there is a filterOption param in method getAssetPathList and there is SizeConstraint in imageOption, of which the default value is:

  const SizeConstraint({
    this.minWidth = 0,
    this.maxWidth = 100000,
    this.minHeight = 0,
    this.maxHeight = 100000,
    this.ignoreSize = false,
  });

On my android phone(android 10, EMUI 11.0.0), even the minWidth and minHeight set to 0, those 0 width and 0 height pictures still get filtered. Only when I set ignoreSize to true will they appear. But on an android 10 emulater, with the default filter option, those pictures will show up correctly.

This is weird why the behavior is different. Which doesn't make sense but it is the case. Maybe just an unexpected behavior of this particular android version of my phone and sadly I cannot even reproduce it on emulator.

So, to make things works, setting ignoreSize might be the only workaround for me. The question is what actually does ignoreSize do? Is it just bypass size check? will it causes more trouble if I set it to true?

My code

just calling PhotoManager.getAssetPathList to get all image folders

Try do it

No response

lxhlzyh commented 1 month ago

Images with width and height 0 are not included.See https://github.com/fluttercandies/flutter_photo_manager/blob/3862ce87020041a64f96172ce835ed3ce66a7406/android/src/main/kotlin/com/fluttercandies/photo_manager/core/entity/filter/CommonFilterOption.kt#L54 I think sizeWhre is redundant, because the image size limit is filtered in getCondFromType.