有没有人开发了一个工具来扫描iOS应用程序目录,以确保所有.png图像都有匹配的@2x.png图像?我可以花2-3个小时开发一个Java应用程序来做这件事。然而,虽然我对shell脚本一点也不在行,但我认为只需几行shell脚本就可以完成(我很高兴能给你们中的一个人一个机会来展示你们做这件事的才华:-)。
发布于 2013-05-07 02:46:48
这是一个快速的shell脚本。这甚至可以处理带有~ipad或~iphone后缀的图像。
#!/bin/bash
for img in `find . -name '*.png' | grep -v "@2x"`; do
noext=${img%.png}
suffix=
base=${noext%~ipad}
if [ "$base" != "$noext" ]; then
suffix="~ipad"
else
base=${noext%~iphone}
if [ "$base" != "$noext" ]; then
suffix="~iphone"
else
base=${noext}
fi
fi
retina="${base}@2x${suffix}.png"
if [ ! -f $retina ]; then
echo "Missing $retina"
fi
done从项目的根目录运行此命令,它将检查找到的每个图像。
我刚发现我的一张图片有问题。我有@2,但没有x。
更新:我刚刚开始使用python。下面是用python编写的相同脚本:
#!/usr/bin/python
import fnmatch
import os
for root, dirnames, filenames in os.walk('.'):
for filename in fnmatch.filter(filenames, '*.png'):
if filename.find('@2x') == -1:
noext = filename[:-4]
suffix = ''
base = noext
if noext.endswith('~ipad'):
suffix = '~ipad'
base = noext[:-5]
elif noext.endswith('~iphone'):
suffix = '~iphone'
base = noext[:-6]
retina = os.path.join(root, base + '@2x' + suffix + '.png')
if not os.path.exists(retina) :
print('Missing ' + retina)发布于 2013-05-07 02:37:42
我以前就用过slender
https://stackoverflow.com/questions/16404941
复制相似问题