The PythonImagingLibrary ([[PIL]]) adds ImageProcessing capabilities to your [[Python]] interpreter. This library supports many file formats, and provides powerful ImageProcessing and graphics capabilities. http://www.pythonware.com/products/pil/ = 예제코드 = GradationEffect -> [[EvalueGradation.py]] SONY DigitalCamera multiburst 연사사진 슬라이스 스크립트 {{{#!python #!/usr/local/bin/python2.3 import sys,os, unittest import Image def usage(): print "Usage: ./imgslice.py filename" def getBoxes((x,y),num=4): stepx = x/num; stepy = y/num for eachy in range(0,y,stepy): for eachx in range(0,x,stepx): yield (eachx, eachy, eachx+stepx, eachy+stepy) def sliceImage(inFileName): prefix,ext = os.path.splitext(inFileName) outDir = os.path.join(os.curdir, prefix) if not os.path.isdir(outDir): os.makedirs(outDir) try: im = Image.open(inFileName) except IOError: print "no exist filename" usage() os._exit(1) for i,box in enumerate(getBoxes(im.size)): outName = os.path.join(outDir, prefix+'_'+str(i+1).zfill(2)+'.'+ext) print 'writing %s...'%outName im.crop(box).save(outName) class TestSlicerBox(unittest.TestCase): def test1(self): it = getBoxes((400,40)) self.assertEquals((0,0,100,10),it.next()) self.assertEquals((100,0,200,10),it.next()) def main(): try: inFileName = sys.argv[1] except IndexError: usage() os._exit(1) sliceImage(inFileName) }}} ---- RedHatEnterpriseLinux 에서 jpeg를 못읽어 한참을 해맸다. libjpeg 를 따로 설치하고, 경로를 PIL 의 setup.py 에 명시해야 한다. -- [[yong27]] <> ---- CategoryProgramLibrary