 Hey guys welcome back to the Python image library module tutorial series We're still looking at image ops and image operations in this video I'm gonna show you two of the other cool ones that I think you might be interested in and I'm just kind of gonna breeze through the rest Of the functions that I want to talk about in this image ops a module because I think we're ready to wrap it up It's pretty simple pretty easy Okay, let's dive right in the first thing that I want to show you is grayscale And what this will do is it will convert the image that you're working with to grayscale black and white It's pretty simple all it takes is the image that you're working with as a function now if I run this We got our modified Python file At least Python image being black and white grayscale now when we do this We can also colorize it the other functions I want to show you is simply colorize and this is going to be image ops colorize And this takes the image and it also takes colors for would return or at least what would what would change the black And white values in the grayscale image So if I change all the black values to be red like two five five zero zero and if I change all the white values to be Let's do blue zero zero two five five now when we check this out minimize this here it's a little bit of a different thing right and We can of course change any of these colors to be what we want them to be but it's like Substituting different colors for all of the black and white values that you would normally see in the image So that's kind of cool And I mean you can play with it to do it do with it what you want now note when you run the grayscale function It is converting the image to a grayscale image mode like if I print out image dot mode We're gonna get returned L rather than RGB because it literally is a one channel black and white image So that's important to note Okay, the other images image ops functions that I'm gonna run through are pretty much stuff. We've already seen I here I'll show you Image ops has support for functions like flip and what that does is it flips the image vertically? Okay, I'll remove our grayscale line here and It has the function mirror which you know is horizontal So Those are two other simple ones. It also has support for crop We've also covered that already in the In the image module itself rather than image ops and that takes kind of a border Argument along with it like this will be the numbers that it subtracts from all the edges like if I passed in 20 Check it out. Okay. Now the image is a little bit smaller. You can see the edges have shrunk down I'll do this a little bit more drastically with 70 now if you check it out whoa crop the image it also has a function to kind of reverse this though. It's got Border, I think it's called Yeah, no, it's expand. Sorry Expand will add it 70 to the other edge to all the four edges. I run this check it out There it is now we can supply a fill color Another argument fill By default it's zero, but we can set it to be white if we want it to be 255 255 255 Check it out They can see it's white rather than the black like it was by default. So simple stuff And I'm pretty sure that's all I wanted to show you guys between grayscale colorize mirror flip and Crop and expand so those are pretty simple image ops image operations and Hey, it just wraps up the toolkit of other operations and things we can do with our image So thank you guys for watching Remember that these stuff this stuff anyway does not work unless you're working in the RGB format and RGB mode You cannot have an alpha channel if you wanted to at the very end after you've changed things here Okay, this adds a little bit more depth of tutorial. Let's say image is going to equal image ops dot invert Our image I run this we've got our inverted image, right? Now what we can do is we can say oh man image is going to equal this split let's do image load and We'll copy the same line that we had up here Rg and b are going to equal image dot split and now we'll create another image But include the alpha channel and we'll use the same a that we had up top Right up here, right? So now hopefully no errors. We can see just in the very corners here. Okay. I'm rotating with my touchscreen. Sorry You can see these up here Those are only visible because of the alpha channel and you can see this is a this gray color is different from the black color In the python's eye Because that's where the alpha channels are and okay. Let's hop back on over here We can print out image dot mode And we get rgba We know that there is an alpha channel added and it's the same alpha that we initially had in the initial image Because we kept track of it in this variable We split it created a new one. That's just rgb Modified rgb with our invert function with image ops and then we add the alpha channel back in so Kind of a little repetitive But it gets the job done because we want to invert it and we can't do it if it's an rgba mode image We just bring it back to an rgba image when we're done Inverting it or any other operations we want to run with our image ops module. So okay There we go. Uh, I'm good. I'm happy. I'm content I hope you guys are hope you guys are happy and content if you are I don't know maybe like the video Maybe maybe leave me some constructive criticism. Maybe leave a comment or maybe if you feel generous subscribe You know, I'd love that. I'll see you in the next tutorial