图像操作
from PIL import ImageColor;
from PIL import Image;
rbg_1 = ImageColor.getcolor('red', 'RGBA');
catIm = Image.open('E:\\test_1.png');
print(catIm.size);
width, height = catIm.size;
print(width);
print(catIm.filename);
print(catIm.format);
print(catIm.format_description);
catIm.save('E:\\test_dir\\2.png');
im = Image.new('RGBA', (100, 200), 'purple');
im.save('E:\\test_dir\\3.png');
new_crop = catIm.crop((50, 50, 150, 150));
new_crop.save('E:\\test_dir\\new_cop.png');
newIt = Image.open('E:\\test_1.png');
newCat = newIt.copy();
newCat.paste(new_crop, (0, 0));
newCat.save('E:\\test_dir\\new_cop_copy.png')
quar = catIm.resize((100, 3000));
quar.save('E:\\test_dir\\new_cop_copy_quar.png');
catIm.rotate(90).save('E:\\test_dir\\new_cop_copy_quar_route.png');
catIm.rotate(90, expand=True).save('E:\\test_dir\\new_cop_copy_quar_route——90.png');
catIm.transpose(Image.FLIP_LEFT_RIGHT).save('E:\\test_dir\\new_cop_copy_quar_route_Right.png');
catIm.transpose(Image.FLIP_TOP_BOTTOM).save('E:\\test_dir\\new_cop_copy_quar_route_Veri.png');
im = Image.new('RGBA', (100, 100))
im.getpixel((0, 0))
for x in range(100):
for y in range(50):
im.putpixel((x, y), (210, 210, 210))
for x in range(100):
for y in range(50, 100):
im.putpixel((x, y), ImageColor.getcolor('darkgray', 'RGBA'));
im.save('putPixel.png')