close
from PIL import ImageColor from PIL import Image def main(): rushMore= Image.open("abc.jpg") print(type(rushMore)) #<class 'PIL.JpegImagePlugin.JpegImageFile'> width, height = rushMore.size print(width, height) # 1920 1080 #rushMore.show() #show image #rushMore.save("AAAAAA.jpg") #Storage ''' 建立新的影像物件 可以使用new()的方法來建立新的影像物件 new(mode,size,color=0) ''' obj = Image.new("RGBA",(300,180),"Yellow") #create aqua color image print(obj.getpixel((150,50))) #列印中心點的色彩 obj.save("newImg.png") if (__name__ == '__main__'): main()
newImage = Image.new('RGBA' ,(300,300),"Yellow") for x in range (50,251): #X軸區間在50-250 for y in range(50,151): #Y軸區間在50-150 newImage.putpixel((x,y), (0,255,255,255)) #填滿青色 newImage.save("1.png") for x in range (50,251): for y in range (151,251): newImage.putpixel((x,y),ImageColor.getcolor("Blue","RGBA")) newImage.save("2.png")
from PIL import ImageColor from PIL import Image,ImageDraw from PIL import ImageFilter def main(): newImage = Image.new('RGBA', (300,300) , "Yellow") drawObj = ImageDraw.Draw(newImage) for x in range(100,200,3): for y in range(100,200,3): drawObj.point([(x,y)],fill='Green') drawObj.line([(0,0), (299,0), (0,299), (0,0)], fill="Black") for x in range(150,300,10): drawObj.line([(x,0) , (300,x-150)], fill="Blue") for y in range(150,300,10): drawObj.line([(0,y), (y-150,300)], fill="Blue") newImage.save("Output.png") if (__name__ == '__main__'): main()
全站熱搜
留言列表