flutter_launcher_icons icon indicating copy to clipboard operation
flutter_launcher_icons copied to clipboard

Adaptive Icon Scaling

Open knyghtryda opened this issue 4 years ago • 14 comments

Since the adaptive icons seems to have extra padding when compared to their iOS counter parts I added a new scaling factor parameter so that the image for the adaptive icon can be scaled before finally scaling down to icon size. This scaling is done by enlarging the canvas, not scaling down the original image, so image quality should in theory be better. The two new yaml parameters are:

adaptive_icon_foreground_scale_factor: 0.66
adaptive_icon_foreground_scale_fill_color: "#FFFFFFFF" #probably not needed as default is fill transparent

Adding background image scaling will be next.

knyghtryda avatar Jun 24 '20 00:06 knyghtryda

Just tested it and seems to be working well for my use case too. @MarkOSullivan94 it'd be great if this could get merged, many people in the issue #96 would appreciate it :)

Or if you could let us know what's stopping it from getting merged?

Aulig avatar Nov 13 '20 13:11 Aulig

After more extensive use I think I've found a small bug. When using a non-square image as adaptive_icon_foreground, the outputted ic_launcher_foreground in the drawable folders is off-centered.

I used this configuration:

  android: true
  adaptive_icon_background: "#000000"
  adaptive_icon_foreground: "img.png"
  adaptive_icon_foreground_scale_factor: 0.66
  adaptive_icon_foreground_scale_fill_color: "#000000"

img.png is 1240x877.

Actual result (red border added for easier visibility): issue-actual

Expected result (red border added for easier visibility): issue-expected

I've achieved the actual result by manually padding img.png with a transparent border to make sure it is square (1240x1240)

Let me know if I'm doing anything wrong or if this is actually a bug.

Thanks for this great PR!

Aulig avatar Jan 21 '21 10:01 Aulig

Any updates on this? @MarkOSullivan94

tirth-stasis avatar Feb 17 '21 07:02 tirth-stasis

few open issues mentioning this PR/adaptive icon bug (#96, #226), anyone able to take a look? @slightfoot

dsgriffin avatar Feb 17 '21 11:02 dsgriffin

After more extensive use I think I've found a small bug. When using a non-square image as adaptive_icon_foreground, the outputted ic_launcher_foreground in the drawable folders is off-centered.

I used this configuration:

  android: true
  adaptive_icon_background: "#000000"
  adaptive_icon_foreground: "img.png"
  adaptive_icon_foreground_scale_factor: 0.66
  adaptive_icon_foreground_scale_fill_color: "#000000"

img.png is 1240x877.

Actual result (red border added for easier visibility): issue-actual

Expected result (red border added for easier visibility): issue-expected

I've achieved the actual result by manually padding img.png with a transparent border to make sure it is square (1240x1240)

Let me know if I'm doing anything wrong or if this is actually a bug.

Thanks for this great PR!

@Aulig I do believe all icons (including adaptive) expect square input files. I would put your image on a square canvas before using it to generate the adaptive icon.

knyghtryda avatar Feb 23 '21 23:02 knyghtryda

After more extensive use I think I've found a small bug. When using a non-square image as adaptive_icon_foreground, the outputted ic_launcher_foreground in the drawable folders is off-centered. I used this configuration:

  android: true
  adaptive_icon_background: "#000000"
  adaptive_icon_foreground: "img.png"
  adaptive_icon_foreground_scale_factor: 0.66
  adaptive_icon_foreground_scale_fill_color: "#000000"

img.png is 1240x877. Actual result (red border added for easier visibility): issue-actual Expected result (red border added for easier visibility): issue-expected I've achieved the actual result by manually padding img.png with a transparent border to make sure it is square (1240x1240) Let me know if I'm doing anything wrong or if this is actually a bug. Thanks for this great PR!

@Aulig I do believe all icons (including adaptive) expect square input files. I would put your image on a square canvas before using it to generate the adaptive icon.

Yea, that's what I'm doing now :) Thanks for the info - in that case it makes sense that this PR doesn't handle it separately.

Aulig avatar Feb 23 '21 23:02 Aulig

Yea, that's what I'm doing now :) Thanks for the info - in that case it makes sense that this PR doesn't handle it separately.

@Aulig Now, to be fair, there was a bug in my code for the scaling that caused non-square photos to be scaled incorrectly 😛 I am now enforcing a square canvas just to make everyone's life easier 😃

knyghtryda avatar Feb 24 '21 00:02 knyghtryda

It's May 2021 and it's still not merged. :D

tirth-stasis avatar May 06 '21 09:05 tirth-stasis

@knyghtryda :tada: :tada:

tirth-stasis avatar May 13 '21 20:05 tirth-stasis

@knyghtryda could you please provide an image which has issues with the scaling? 🙂

It'll make it easy for me to test this and see the before vs after.

Definitely should provide some kind of info on the README so if people are running into similar issues they can make use of the changes you have implemented here 🥳

MarkOSullivan94 avatar Jul 25 '21 19:07 MarkOSullivan94

@knyghtryda could you please provide an image which has issues with the scaling? 🙂

It'll make it easy for me to test this and see the before vs after.

Definitely should provide some kind of info on the README so if people are running into similar issues they can make use of the changes you have implemented here 🥳

@MarkOSullivan94 I'm getting the same result after adding the scale factor with the following image not scaling for me:

AchooLogo_foreground_512x512

Current configuration:

flutter_icons:
android: true
ios: true
image_path: "assets/images/logo_192x192.png"
adaptive_icon_background: "#275DAD"
adaptive_icon_foreground: "assets/images/AchooLogo_foreground_512x512.png"
adaptive_icon_foreground_scale_factor: 0.66
adaptive_icon_foreground_scale_fill_color: "#000000"

Result:

Screenshot_1629672750

AdamBridges avatar Aug 22 '21 22:08 AdamBridges

Hey @MarkOSullivan94, I hope you are doing well.

Is there a chance this PR gets merged in the near future? :)

There are many open Issues which are related to this PR.

devj3ns avatar Jan 17 '22 18:01 devj3ns

I'll start taking a look at this.

bradintheusa avatar Jun 12 '22 03:06 bradintheusa

@MarkOSullivan94 we may need to add this to our roadmap

workaround https://github.com/fluttercommunity/flutter_launcher_icons/pull/181#issuecomment-764532004

RatakondalaArun avatar Aug 15 '22 09:08 RatakondalaArun