#!/usr/bin/env python
"""Program for converting image files from one format
to another. Will convert one file at a time or all
files (of a selected format) in a directory at once.
Converted files have same basename as original files.
Uses workaround: askdirectory() does not allow choosing
a new dir, so asksaveasfilename() is used instead, and
the filename is discarded, keeping just the directory.
"""
import os, os.path, string, sys
from Tkinter import *
from tkFileDialog import *
import Image
openfile = '' # full pathname: dir(abs) + root + ext
indir = ''
outdir = ''
def getinfilename():
global openfile, indir
ftypes=(('Gif Images', '*.gif'),
('Jpeg Images', '*.jpg'),
('Png Images', '*.png'),
('Tiff Images', '*.tif'),
('Bitmap Images', '*.bmp'),
("All files", "*"))
if indir:
openfile = askopenfilename(initialdir=indir,
filetypes=ftypes)
else:
openfile = askopenfilename(filetypes=ftypes)
if openfile:
indir = os.path.dirname(openfile)
def getoutdirname():
global indir, outdir
if openfile:
indir = os.path.dirname(openfile)
outfile = asksaveasfilename(initialdir=indir,
initialfile='foo')
else:
outfile = asksaveasfilename(initialfile='foo')
outdir = os.path.dirname(outfile)
def save(infile, outfile):
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print "Cannot convert", infile
def convert():
newext = frmt.get()
path, file = os.path.split(openfile)
base, ext = os.path.splitext(file)
if var.get():
ls = os.listdir(indir)
filelist = []
for f in ls:
if os.path.splitext(f)[1] == ext:
filelist.append(f)
else:
filelist = (of this format) in this folder?"""
var = IntVar()
chk = Checkbutton(topframe,
text=multitext,
variable=var).pack(pady=2)
Button(topframe,
text='Select save location',
command=getoutdirname).pack(side=BOTTOM, pady=4)
Label(midframe, text="New Format:").pack(side=LEFT)
frmt = StringVar()
formats = ['.bmp', '.gif', '.jpg', '.png', '.tif']
for item in formats:
Radiobutton(midframe,
text=item,
variable=frmt,
value=item).pack(anchor=NW)
Button(botframe, text='Convert', command=convert).pack(side=LEFT,
padx=5,
pady=5)
Button(botframe, text='Quit', command=root.quit).pack(side=RIGHT,
padx=5,
pady=5)
root.title('Image Converter')
root.mainloop()
실용적인 디지털 포렌식 기법과 법률 이슈 정리. Linux, UNIX, Python, 임베디드 장치 개발 등의 강좌 수록. Blockchain, FinTech, IoT 등 최신 IT 트렌드와 관련된 취미 자료를 수집하고, 보안 인식 문화 개선을 위한 정보보호 관련 자료와 일상생활 팁들을 소개.
홈페이지 jQuery 라이브러리에서 CVE-2019-11358 취약점 패치 여부 확인 방법
현재 홈페이지에서 사용 중인 jQuery 라이브러리가 CVE-2019-11358 취약점 패치를 적용했는지 확인하는 방법은 다음과 같습니다. 1. jQuery 버전 확인 홈페이지 소스 코드를 확인하여 jQuery 라이브러리 버전을 직접 확인합니다. 웹 ...
-
뉴스출처 : http://news.naver.com/main/read.nhn?mode=LSD&mid=sec&oid=023&aid=0002991158&sid1=001 내 배우자가 바람을 피우는 것이 확실할까. 심증...
-
PHPSCHOOL ( http://www.phpschool.com ) 국내 1위의 PHP 개발자 커뮤니티 사이트이다. PHP Builder ( http://www.phpbuilder.com ) PHP 최고 사이트라고 해도 과언이 아니며, 새로운 P...