我正在寻找一个工具,可以为iOS和安卓应用程序从svg图像生成不同大小的图标。
谷歌并没有真正为我提供任何“一键式”的解决方案。有没有什么不太为人所知的工具?或者一些简单的批处理脚本也可以实现同样的效果?
理想情况下,我可以在我的windows10机器上运行,但linux也可以运行。
发布于 2018-07-17 20:52:57
首先,转换你的SVG到PNG从这个链接https://svgtopng.com/,一旦你转换.PNG,然后使用这个链接https://makeappicon.com/创建应用程序图标为安卓和iOS。
发布于 2021-01-18 17:21:20
这已经很晚了,这是针对ANDROID的,但你实际上可以直接在android studio中转换svg文件,右键单击res文件夹中的drawable文件夹,然后选择矢量资产:

然后选择本地文件(SVG、PSD)

然后,您可以从路径字段中选择svg文件,android studio将直接将该文件转换为资源。
发布于 2022-02-16 21:28:34
我的选择是https://github.com/sterlp/svg2png。对于IOS:
java -jar svg2png.jar -f app_icon.svg -o yourFolder/Assets.xcassets/AppIcon.appiconset -c ios_icon.json有了这样的ios_icon.json:
{
"files": [
{
"nameSuffix": "-20x20@1x",
"height": 20,
"width": 20
},
{
"nameSuffix": "-20x20@2x",
"height": 40,
"width": 40
},
{
"nameSuffix": "-20x20@3x",
"height": 60,
"width": 60
},
{
"nameSuffix": "-29x29@1x",
"height": 29,
"width": 29
},
{
"nameSuffix": "-29x29@2x",
"height": 58,
"width": 58
},
{
"nameSuffix": "-29x29@3x",
"height": 87,
"width": 87
},
{
"nameSuffix": "-40x40@1x",
"height": 40,
"width": 40
},
{
"nameSuffix": "-40x40@2x",
"height": 80,
"width": 80
},
{
"nameSuffix": "-40x40@3x",
"height": 120,
"width": 120
},
{
"nameSuffix": "-60x60@2x",
"height": 120,
"width": 120
},
{
"nameSuffix": "-60x60@3x",
"height": 180,
"width": 180
},
{
"nameSuffix": "-76x76@1x",
"height": 76,
"width": 76
},
{
"nameSuffix": "-76x76@2x",
"height": 152,
"width": 152
},
{
"nameSuffix": "-83.5x83.5@2x",
"height": 167,
"width": 167
},
{
"nameSuffix": "-1024x1024@1x",
"height": 1024,
"width": 1024
}
]
}只需确保生成的png文件与您在AppIcon.APPICEST/Contents.json中的配置相匹配即可。我的是
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20",
"filename" : "app_icon-20x20@2x.png"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20",
"filename" : "app_icon-20x20@3x.png"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29",
"filename" : "app_icon-29x29@2x.png"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29",
"filename" : "app_icon-29x29@3x.png"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40",
"filename" : "app_icon-40x40@2x.png"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40",
"filename" : "app_icon-40x40@3x.png"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60",
"filename" : "app_icon-60x60@2x.png"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60",
"filename" : "app_icon-60x60@3x.png"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20",
"filename" : "app_icon-20x20@1x.png"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20",
"filename" : "app_icon-20x20@2x.png"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29",
"filename" : "app_icon-29x29@1x.png"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29",
"filename" : "app_icon-29x29@2x.png"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40",
"filename" : "app_icon-40x40@1x.png"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40",
"filename" : "app_icon-40x40@2x.png"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76",
"filename" : "app_icon-76x76@1x.png"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76",
"filename" : "app_icon-76x76@2x.png"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5",
"filename" : "app_icon-83.5x83.5@2x.png"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024",
"filename" : "app_icon-1024x1024@1x.png"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}对于Android,请参考https://github.com/sterlp/svg2png上的自述文件或创建自己的json配置。
https://stackoverflow.com/questions/51381016
复制相似问题