多くの画像とその網膜画像を含むプロジェクトがあります。各画像に関連する網膜画像ファイルがあるかどうかを確認する簡単な方法またはツールはありますか? どの Retina ファイルが見落とされているかを教えてくれるソフトウェア ツールまたは簡単なスクリプトになることを願っています。
コメント歓迎
多くの画像とその網膜画像を含むプロジェクトがあります。各画像に関連する網膜画像ファイルがあるかどうかを確認する簡単な方法またはツールはありますか? どの Retina ファイルが見落とされているかを教えてくれるソフトウェア ツールまたは簡単なスクリプトになることを願っています。
コメント歓迎
この python スクリプトを試すことができます。@2x 画像が非 Retina バージョンと同じディレクトリにあると想定していることに注意してください。Retina 画像と標準画像を別のフォルダーに保存すると、これは機能しません。.png
と拡張子の付いたファイルをそのまま処理します.jpg
が、簡単に追加できます。
これは *nixfind
コマンドを使用して、現在の作業ディレクトリ内のすべてのファイルのパスを再帰的に取得します。私は Python の初心者なので、コメント/修正/改善は大歓迎です!
これは手動で実行することも、xcode のプリコンパイル フックで使用することもできます。@2x バージョンを持たないファイルのパスを返します。
from subprocess import check_output
from os import path
import string
# Get all the files in the current working dir, recursively
files_raw = check_output(["find","-type","f"])
paths = files_raw.split("\n")
# Remove the empty last element (find command ends with a newline)
paths.pop()
for item in paths:
# Ignore any @2x items
if("@2x" in item):
continue
# Break up the path
filename, extension = path.splitext(item)
# Ignore files without these extensions
if(extension not in [".png", ".jpg"]):
continue
# Make the rentina path and see if it's in the list of paths
retina = filename+"@2x"+extension
if(retina not in paths):
print item
たとえば、次のフォルダの場合:
.:
file.txt
john.png
test@2x.png
test.png
./more:
cool_image.jpg
john@2x.png
file.png
./other:
[empty]
実行中 (ターミナル内):
cd /home/stecman/test-dir
python /home/stecman/missing-retina.py
出力
./john.png
./more/cool_image.jpg
./more/file.png