python 이미지 처리 인터페이스
#http://pillow.readthedocs.org/en/latest/index.html
#
# #coding:utf-8
# import os, sys
# from PIL import Image
# sys.argv.append(" ")#
'''Image '''
# im = Image.open(sys.argv[1])
# print(im.format,im.size,im.mode)#format ,size X ,mode
# # L ,RGB ,CMYK pre-press
#
# size = (32,32)
# im.thumbnail(size)#
# im.save("/home/zyh/picture/the.jpg")# jpg
#
''' '''
# # jpg
#
# for infile in sys.argv[1:]:# ,
# f,e = os.path.splitext(infile)# ; (fname,fextension) ,
# outfile = f +".jpg"
# # print e
# if infile != outfile:
# try:
# Image.open(infile).save(outfile)
# except IOError:
# print("can't convert", infile)
# #
#
# size = (16,16)
# for infile in sys.argv[1:]:
# outfile = os.path.splitext(infile)[0]+".thumbnail"
# if infile != outfile:
# try:
# im = Image.open(infile)
# im.thumbnail(size)
# im.save(outfile,"JPEG")
# except IOError:
# print("can't creat thumbnail for",infile)
# #
# for infile in sys.argv[1:]:
# try :
# # with Image.open(infile) as im:#
# im = Image.open(infile)
# print(infile,im.format,"%d x %d"%im.size,im.mode)
# except IOError:
# pass
''' , , '''
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
#
# #
#
# # box = im.copy()#
# box = (im.size[0]/3,im.size[1]/3,im.size[0]*2/3,im.size[1]*2/3)# ,left ,upper,right,lower
# region = im.crop(box)# ,
#
# # ,
#
# region = region.transpose(Image.ROTATE_180)# 180
# im.paste(region,box)# paste( ) , region ,
# im.save(outfile+"box.jpeg")
# except IOError:
# pass
# #rolling an Image
#
# def roll (image,delta):
# '''Roll an image sideways'''
# image = image.copy()
# xsize,ysize = image.size
# delta = delta%xsize
# if delta ==0 : return image
#
# part1 = image.crop((0,0,delta,ysize))
# part2 = image.crop((delta,0,xsize,ysize))
# image.paste(part2,(0,0,xsize-delta,ysize))
# image.paste(part1,(xsize-delta,0,xsize,ysize))
#
# return image
#
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
#
# #
# roll(im.copy(),300).save(outfile+"roll.jpeg")
# #im.save(outfile+"box.jpeg")
# except IOError:
# pass
# #
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
# r,g,b= im.split()# ,split()
# im = Image.merge("RGB",(b,r,g))# (RGB)
# im.save(outfile+"tongdao.jpeg")
# #im.save(outfile+"box.jpeg")
# except IOError:
# pass
#
''' '''
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
# #
#
# out = im.resize((64,64))#
# out = im.rotate(30) #
# out.save(outfile+"jihe .jpeg")
# #
# out = im.transpose(Image.FLIP_LEFT_RIGHT) #
# out.save(outfile+"jiheLR.jpeg")
# out = im.transpose(Image.FLIP_TOP_BOTTOM) #
# out.save(outfile+"jiheTB.jpeg")
# out = im.transpose(Image.ROTATE_90) # 90, rotate
# out.save(outfile+"jiheR45.jpeg")
# out = im.transpose(Image.ROTATE_180)
# out.save(outfile+"jiheR180.jpeg")
# out = im.transpose(Image.ROTATE_270)
#
# out.save(outfile+"jiheR270.jpeg")
# #im.save(outfile+"box.jpeg")
# except IOError:
# pass
''' '''
#
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
# #
# out = im.convert("L")
# out.save(outfile+"convertL.jpeg")
# except IOError:
# pass
''' ()'''
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
# #
#
# from PIL import ImageFilter
# out = im.filter(ImageFilter.DETAIL)
# out.save(outfile+"filter.jpeg")
# except IOError:
# pass
''' '''
# for infile in sys.argv[1:]:
# try :
# im = Image.open(infile)
# outfile = os.path.splitext(infile)[0]
#
# #
#
# out = im.point(lambda i: i * 0.3)# 0.3, point paste
# out.save(outfile+"point.jpeg")
#
# #
#
# source = im.split()
# R,G,B = 0,1,2
#
# # select regions where red is less than 100
# mask = source[R].point(lambda i: i<100 and 255)
# #mask : 0 , ,255 paste , transparency
#
# # process the green band
# out = source[G].point(lambda i: i*10)
#
# # paste the processed band back, but only where red was < 100
# source[G].paste(out,None,mask)
#
# im=Image.merge(im.mode,source)
# im.save(outfile+"tongdao.jpeg")
# except IOError:
# pass
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.