Resize UWP, Xamarin.Android and Xamarin.iOS assets automatically at build time.
Available on NuGet
The easiest way is to use Assetxport from its build task. Simply add a NuGet package reference to your Xamarin.iOS, Xamarin.Android or Universal Windows Platform project and add a Config.assets.json
configuration file at the root of your project.
Config.assets.json
{
"Platform": "<iOS|Android|UWP>",
"Input": [ "<input folder path relative to this file, containing all the source hd assets>" ],
"Output": "<output folder path relative to this file, where all the density assets are generated to>"
}
{
"Platform": "iOS",
"Input": [ "../Assetxport.Sample.Cli/Images/" ],
"Output": "Assets.xcassets"
}
In your high definition asset source folder, all .png
|.jpg
images should have a suffix qualifier indicating their original density. Here is the list of available qualifiers :
<name>.<ext>
: 1.00<name>@<value>x.<ext>
: value<name>@ldpi.<ext>
: 0.75<name>@mdpi.<ext>
: 1.00<name>@hdpi.<ext>
: 1.50<name>@xhdpi.<ext>
: 2.00<name>@xxhdpi.<ext>
: 3.00<name>@xxxhdpi.<ext>
: 4.00
Then simply build the project to generate your various assets (with densities lower or equal to the original density) to the output folder!
Assets are generated as asset catalog entries (.imageset
).
Assets are generated inside qualified drawable sub folders (drawable-hdpi
, drawable-xhdpi
, ...).
Assets are generated with a qualified suffix indicating the scale (scale-100
, scale-240
, ...).
The standalone .exe
CLI used by the build task is available from the /tools
folder of the NuGet package.
The tool uses SkiaSharp to resize all images.
Contributions are welcome! If you find a bug please report it and if you want a feature please report it.
If you want to contribute code please file an issue and create a branch off of the current dev branch and file a pull request.
MIT © Aloïs Deniel