2012-06-26 2 views
0

우리는 많은 이미지와 망막 이미지가있는 프로젝트를 가지고 있습니다. 각 이미지에 관련된 망막 이미지 파일이 있는지 확인하는 간단한 방법이나 도구가 있습니까? 나는 당신이 파이썬 스크립트를 시도 할 수있는 코멘트망막 이미지 파일을 확인하십시오.

+2

당신이 본 적이 : HTTP : // www.splinter.com.au/quickly-check-for-any-missing-retina-graphics/? –

답변

1

에 오신 것을 환영는 소프트웨어 도구 또는

을 놓친 망막 파일 말해 줄 수있는 간단한 스크립트되기를 바랍니다. @ 2x 이미지는 비 망막 버전과 같은 디렉토리에 있다고 가정합니다. 망막과 표준 이미지를 다른 폴더에 보관하면이 기능이 작동하지 않습니다. .png.jpg 확장자를 가진 파일을 처리하지만 더 쉽게 추가 할 수 있습니다.

이 명령은 * nix find 명령을 사용하여 현재 작업 디렉토리의 모든 파일 경로를 재귀 적으로 가져옵니다. 나는 파이썬 초보자 다. 그래서 어떤 의견/수정/개선도 환영한다!

수동으로 실행하거나 xcode의 사전 컴파일 후크에서 사용할 수 있습니다. @ 2x 버전이없는 파일의 경로를 반환합니다.

.: 
    file.txt 
    john.png 
    [email protected] 
    test.png  

./more: 
    cool_image.jpg 
    [email protected] 
    file.png 

./other: 
    [empty] 

(터미널에서) 실행 :이 폴더에 대한 예를 들어

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 

,

cd /home/stecman/test-dir 
python /home/stecman/missing-retina.py 

출력

./john.png 
./more/cool_image.jpg 
./more/file.png 
+0

이 답변을 확인하는 다른 사람들은 질문의 첫 번째 의견에있는 링크가이 답변보다 더 좋은 답변이라고 생각합니다 (cf. http://www.splinter.com.au/quickly-check-for-any-missing 참조). -retina-graphics /). 왜? 1/이미지의 파일 시스템 위치에 대해 신경 쓰지 않습니다. 2/이미지가 실제로 iOS 대상의 일부인지 확인합니다. –