mozilla / apk-factory-service

Web service which converts Open Web Apps into native Android apps
41 stars 18 forks source link

Convert icons to APK supported format #9

Closed ozten closed 10 years ago

ozten commented 10 years ago

Open Web Apps have looser App Icon standards, so we may have to convert images to a supported format.

ozten commented 10 years ago

Here is how AMO does this: https://github.com/mozilla/zamboni/blob/master/apps/amo/utils.py#L532 https://github.com/mozilla/zamboni/blob/master/apps/amo/utils.py#L497

ozten commented 10 years ago

Marketplace Icon standards: https://developer.mozilla.org/en-US/Apps/Developing/Manifest#icons

Android Icon standards: http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap

I'm playing with GraphicsMagick and gm. If that works well, we can use it.

Another option is to introduce Python and PIL as a dependency. This has pros and cons...

ozten commented 10 years ago

@jhugman - What are the supported Icon image sizes for native Android apps?

OWA have many sizes... what are the rules for validating App Icons and how many sizes should we output?

ozten commented 10 years ago

gm is looking very promising. Handled SVG and bmp conversion to PNG with a nice API too boot.

jhugman commented 10 years ago

The mapping used currently is here https://github.com/jhugman/synth-apks/blob/master/builder/lib/manifest-androidifier.js#L59. Generally, Android will pick the best one for the display size/pixel density.

I have noticed that neither the nexus 5 or 7 seem to be displaying the correct icon. Eyeballing this code, I would guess that I don't understand what 480dpi means.

Given a set of bmp or a gifs, I think I would be inclined to transform those, as is. SVG, I think I would go for mdpi, hdpi, xhdpi and xxhdpi. Android's documentation on the matter https://developer.android.com/guide/practices/screens_support.html#range contradicts me, by replacing ldpi with xxhdpi.

On 11/27/13 6:26 PM, Austin King wrote:

@jhugman https://github.com/jhugman - What are the supported Icon image sizes for native Android apps?

OWA have many sizes... what are the rules for validating App Icons and how many sizes should we output?

— Reply to this email directly or view it on GitHub https://github.com/mozilla/apk-factory-service/issues/9#issuecomment-29408056.

ozten commented 10 years ago

I've landed the following API:

var icon = require('../lib/android_icon');
icon.optimize('/some/path/to_a.svg', 64, 64, '/tmp/builds/12345/icon_64', function(err, filename) {
    // filename is the full path to the resized file
    // Example: /tmp/builds/12345/icon_64.png
});

I wasn't sure if the optimal output format would vary based on type of image being converted... (filename in callback is kind of weird, but that is why it exists).

Feel free to file bugs on changes to this API.