A command-line utility for generating Android drawables in the required densities.
Project description
The Android asset resizer can be used to generate drawable assets from a larger source image, like an iOS @2x asset or an xhdpi drawable.
The script will generate the expected ldpi, mdpi, hdpi and xhdpi assets from the source image.
Requirements
PIL (tested with version 1.1.7, may work with earlier versions)
Installing
$ pip install android-asset-resizer
Examples
You can easily generate Android assets from your @2x iOS assets:
$ aaresize assets/icon@2x.png
Running this command will generate the following assets:
- res - drawable-ldpi - icon.png - drawable-mdpi - icon.png - drawable-hdpi - icon.png - drawable-xhdpi - icon.png
These assets were created from the original @2x asset where the icon in the drawable-xhdpi folder is just a copy of the original.
You can also resize an entire directory of images:
$ aaresize assets/*@2x.png
An Android xhdpi asset is roughly equivalent to an @2x asset, so you can easily resize those too:
$ aaresize res/drawable-xhdpi/*.png
If you have a large drawable-xxhdpi asset you can use the --density flag to generate the smaller assets:
$ aaresize res/drawable-xxhdpi/*.png --density=xxhdpi
You can also easily add a prefix to your new assets:
$ aaresize assets/*@2x.png --prefix=ic_
You can also import the AssetResizer class and incorporate it into your own scripts:
from PIL import Image from android_asset_resizer.resizer import AssetResizer # Create our resizer resizer = AssetResizer(out_dir, source_density='xhdpi', prefix='ic_', image_filter=Image.ANTIALIAS) # Make our resource directories resizer.mkres() # Resize an image resizer.resize(path)
Publishing
# Register with pypi (only done once) $ python setup.py register # Upload a new binary distribution to pypi $ python setup.py bdist_egg upload # Upload a new source distribution to pypi $ python setup.py sdist upload
Bug reports
If you encounter any issues, please open a new issue on the project’s GitHub page.
License
See the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for android-asset-resizer-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f74fa15e4e09f24a875e8be13939dcf3e506aeab920f9c8e777df2cef229352d |
|
MD5 | 5286cab5116a1af7555030d7aaab6054 |
|
BLAKE2b-256 | 39e263cb3a6c7c43a6fd0758cac83dfcf98ffed4731ff0871dea153c6fda38d9 |
Hashes for android_asset_resizer-1.0.1-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6696ad1fcbc4abd361b42910aeffaefccc60d21c5ac16fda79c078a08465ca39 |
|
MD5 | c73a95e4920a21736384ef3e34714101 |
|
BLAKE2b-256 | 1b88eb5dbb2cb42f86c36b4b4110a4ec45f53615a8763801123a6550f8bf9978 |