pwa-asset-generator icon indicating copy to clipboard operation
pwa-asset-generator copied to clipboard

Manifest icons with purpose `any` and `maskable` do not adhere to the spec

Open atjn opened this issue 2 years ago • 4 comments

When generating images for the web app manifest, PAG currently generates two copies of each size; one with purpose maskable and one with purpose any. PAG generates these two copies as identical, but if you look at the documentation for these purposes, you will find that they should not be identical:

  • any should have almost no padding, as is expected from traditional icons that are shown as favicons and used in splash screens.
  • maskable should have a lot of padding, and should adhere to a very strict standard for the size of the padding, as it is specifically designed to let the operating system cut away large portions of the image, to make it fit in custom shapes.

The way the images are padded right now, seem to be a sort of in-betweeny, where there is slightly too much padding for an any purpose, and slightly too little padding for a maskable purpose.

In order to fix this problem, the padding system has to be much more sophisticated. I believe it will have to auto-detect which parts of the image are padding, and then add/remove padding to fit these purposes.

One way to do that, could be to find the smallest possible centered circle for an image, where every pixel outside the circle is the exact same color (transparent is also a color in this context). Then the image could be cut to exactly fit this circle, generating a base image where the logo is known to be as large as possible. When that base image exists, it should be trivial to create different image types with varying amounts of padding, that hit precise targets of % padding.

Related: #725 #679

atjn avatar Jan 02 '22 00:01 atjn

Wouldn't this be solved if there were different padding options for favicons, splash screens, and maskable icons? It doesn't really make sense to use the same for all of them.

dantman avatar Jan 19 '22 01:01 dantman

Actually I think instead of a --masked-padding option I'd prefer being able to use an alternate maskable source. Perhaps we need a --maskable-only/--no-maskable pair of options that would only generate maskable icons or generate non-maskable icons without altering the definitions for maskable icons.

Then we can generate maskable and non-maskable icons with any options we want, just like with favicons, app icons, and splash screens now.

dantman avatar Jan 20 '22 04:01 dantman

Sure, it would also be great to have extra options that allows for customizing what PAG outputs. But we also need the default settings to work properly.

atjn avatar Jan 29 '22 11:01 atjn

Assuming we can't make --maskable behave like the --maskable-only and pair it with a --no-maskable. --maskable should probably be deprecated. So the default setting is to only output non-maskable icons, but not delete maskable icons from the manifest. So you can then separately add a run to generate maskable icons with different parameters. I guess it would make sense for this to also change the default --padding.

dantman avatar Jan 29 '22 12:01 dantman