课程: Python Essential Libraries

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Image manipulation

Image manipulation

- [Instructor] Let's try using Pillow for some more advanced purposes, now that we've seen some of the basic operations it can perform. And we're going to do that in our transforms_start.py code file. So the image class that we briefly saw earlier in the chapter, provides some functions for resizing, rotating and even cropping images. So let's try the crop function first. So you can see I've already defined a variable named infile that references this image called Connections, inside the ImagesArchive folder. So you can take a quick look at that image. So this is the image that we're going to crop and it's essentially a graphic image of circuit connections. So let's go back to the code. So back here in the code, let's open the image for processing using the open function. And we already know how to do this. So we'll open infile, as image. Now after the image has opened, we can use the width and height properties…

内容