Created
May 25, 2016 17:02
-
-
Save wesky93/79e1bd432e98b0e23467ea86af92080c to your computer and use it in GitHub Desktop.
wand 포맷 오류
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import datetime | |
import glob | |
from wand.image import Image | |
def ctime_prefix(name): | |
""" | |
파일 생성 시간을 취득하여 prefix를 생성해주는 함수 | |
:param path: 파일 절대경로 | |
:return: 파일 생성시간 prefix (str) | |
""" | |
ctime = os.path.getmtime(name) # 파일 생성시간 취득 | |
ctime = "/" + str(datetime.datetime.fromtimestamp(ctime))[:10] + "_" | |
return ctime | |
sync = "/Users/sinsky/Documents/Sync" # sync의 파일이 자동 동기화 되는 폴더 절대 경로 | |
pdflist = glob.glob("%s/*.pdf" % (sync)) # snyc의 폴더에서 pdf파일만 추출 | |
for pdf in pdflist: | |
rename = "{syncfolder}{prefix}{filename}".format(syncfolder=sync, prefix=ctime_prefix(pdf), | |
filename=pdf[len(sync) + 1:]) | |
os.rename(pdf, rename) | |
# pdf를 png로 변환 | |
with Image(filename=rename, resolution=300) as pdf: | |
rename = rename[:-3] + "png" | |
pdf.format = "png" | |
pdf.save(filename=rename) | |
print(rename) | |
""" | |
오류 발생 | |
Traceback (most recent call last): | |
File "/Users/sinsky/code/python/sync2png/sync_pdf2png.py", line 30, in <module> | |
pdf.format = "png" | |
File "/Users/sinsky/code/vertualenv/pdf2png/lib/python3.5/site-packages/wand/image.py", line 2711, in format | |
raise ValueError(repr(fmt) + ' is unsupported format') | |
ValueError: 'png' is unsupported format | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment