 Hey everyone, welcome back to the Python image library module tutorial series, and I think we are finally ready to move on You know, I mean we've been stuck in the land of simple image for a while now But let's check out what more the Python image library has to offer for us. Let's move on to image ops Now image ops stands for image operations and they're kind of like ready-made Processing operations for messing with your image and doing lots of really cool stuff So the module is a little experimental not all of it works And the things that do work typically only work on either gray scale images that are just black and white or RGB images things that don't have an alpha channel or a transparency like Band to them. So that's why in the last tutorial. I wanted to show you Image mode and strip and merge and everything like that So I'm going to build up some functionality here if the mode is going to equal RGB a if we have the alpha channel Which we know that the file that we're working with right now does what we'll do is we'll change it to you know the regular RGB Band simple RGB without the alpha channel so we can use some of the functions in our image ops module up here So you guys know we need to run image dot load RGB and a are going to equal image dot split and Okay, did I say image dot strip earlier? I meant to say image dot split. I keep getting these things Messed up. I keep saying strip when I meant to say split So I think actually yeah, I got to go back and change the video name even alright. Here we go We're gonna split the image and I didn't think that ticks any arguments in it No, it doesn't take any arguments So what we can do from there is we can make this new image equal to image dot merge the RGB Mode and the tuple for RGB So now I've got our image now what we can do is we can actually go through with the image ops Argument what I want to show off here is first the invert function What this one does is it will return an inverted image So we'll set image equal to what's being returned to us and we'll do image ops because the function lives inside the module Invert and we'll pass in the image which of course we have to be image here now if I run this code Check it out. I'll go to my desktop here and Here is our modified pie image with all the colors inverted super cool, right? Let's check out some of the other functions that the the module can offer us. There is posterize posterize and The values that I've been playing with the ones that work for me are integers One this works. Okay This probably is not the best image to show it off with there are plenty of others that I could be using here and That will actually have a little bit more display and better look to it But okay back to what I was talking about the images the integers that work for me go up until about eight Eight doesn't seem to have much of a change in the image But if I go any higher Like if I go to nine back to it if I try and run this it gives me an error If I do like one back to what we had before but if I go like 1.2 It doesn't like that. It always wants an integer floats don't work for me So I can't get any lower than one and zero is just not gonna do anything zero is gonna get us a black image so One through eight seem to work okay for me and you should play around with these on other images other than the Python logo because There's not a whole lot of change in this simple like only three colors in the image, you know All right. There's also solar eyes. This is what I was checking out image dot solar rise Actually image equals image ops. Sorry image ops on solar eyes Passing the image and what this takes is a threshold Typically the threshold is 128 if you call the function without the arguments It'll run to 128 and Everything all the colors that are greater than this 128 value will be inverted So if we set this to like zero All the colors will be inverted and we'll have the same Outputs or at least changed modification as the invert function that we had up top 255 is going to get us to like all the colors That are being solarized Or inverted and now if I go 256 though It gets us back to our original image so that's kind of the limit there So that's around to play with it if you want to but those are three functions that I've been using and they're in the Image ops module so we can move on from the simple image In the PIL the Python image library and now we're checking out image operations. So inverts Posterize and solarize I'm gonna keep this functionality that converts it to an RGB image if there is an alpha channel And you might want to do the same thing because this is gonna be pretty handy when we're looking through more of the image ops Functions because typically those only work with RGB Try it. Let's see if I try and run this Without them it tells me nope This is not supported for this image type if I just try and simply invert it I think posterize won't work either. I Doubt solarize would to begin with either No, so yeah Definitely keep this functionality for more of the stuff that we look through with the image ops module. So okay Thanks for checking out this video guys I hope this is a building up a little bit of a toolkit and a repertoire for what you can use with images and Python and We'll get to learn more stuff in the coming tutorials. Thanks guys