This is a icon converter.It is able to transform image to icon.
If you want to run it your device, please make sure you have installed this.
- pgmagick > 0.5.0
git clone https://github.com/SparrowJang/icon_converter
cd icon_converter
sudo python setup.py install
from icon_converter import converter
#target image ( http or local )
path = "http://example.com/test.png"
#resize and crop image
size = {"width":40,"height":40}
border = {
"size":{"width":2,"height":2},
"color":"#BBBBBB",
"backgroundColor":"#FFFFFF"
}
blob = converter.convert_by_path( path, size, border )
f = open( "test.png" )
data = f.read()
base64data = base64.b64encode( data )
#binary data
converter.convert( data, size, border )
#base64
converter.convert( base64, size, border, format_type = "base64" )
If you don't need arrow, the "arrow" parameter set to False.
converter.convert( data, size, border, arrow = False )
# or
converter.convert_by_path( path, size, border, arrow = False )
Get a base64.
blob = converter.convert( data, size, border )
blob.base64()
Save a file.
f = open( "arrow.png", "w" )
f.write( blob.data )
f.close()