Python Tutorial: Image Manipulation with Pillow

///Python Tutorial: Image Manipulation with Pillow

Python Tutorial: Image Manipulation with Pillow

FavoriteLoadingAdd to favorites

In this video we will learn how to modify and manipulate images using the Python Pillow Library. Pillow is a fork of the Python Imaging Library (PIL). It will allow us to do many different things to our images such as: changing their file extension, resizing, cropping, changing colors, blurring, and much more.

Pillow is extremely useful when you have multiple images you wish to process at once. For example, you can use Pillow to automatically create different sized thumbnails of images you upload to your web server. Let’s get started.

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

#Python

source

By |2020-01-09T01:07:44+00:00January 9th, 2020|Python Video Tutorials|49 Comments

49 Comments

  1. Rafael Rotiroti January 9, 2020 at 1:07 am - Reply

    i can measure an object inside image with pillow?

  2. Tech Hack January 9, 2020 at 1:07 am - Reply

    Why not use CV2??

  3. Damian VDW January 9, 2020 at 1:07 am - Reply

    great tut as always, but this time ran this and the folder stays blank lol..

  4. Nitish Choudhary January 9, 2020 at 1:07 am - Reply

    @corey i needed your help with a pillow assignment could you just help me
    Is there any email through which i can contact you?

  5. ahmar ch January 9, 2020 at 1:07 am - Reply

    how can I crop the image to face using python?

  6. Daniel Henry January 9, 2020 at 1:07 am - Reply

    Thank you so much for help

  7. Melissa Renaut January 9, 2020 at 1:07 am - Reply

    great tutorial, and i've seen many. cheers!

  8. Mahesh Renganathan January 9, 2020 at 1:07 am - Reply

    Dear Corey Schafer, Thanks a lot for all of your Python tutorials. I am basically from science background, however, i am able to do python code in data analytics field. You are just amazing in teaching those. Then, I request you to make one video about HyperSpy and spectral python package's application.

  9. Amit Sen January 9, 2020 at 1:07 am - Reply

    how to add salt and pepper noise in all images in one foleder and further save it in some other folder

  10. Asif Khan January 9, 2020 at 1:07 am - Reply

    command error out with exit status 1
    Sir, there is an error occured on installing pillow using
    pip install pillow
    please help

  11. Degeneration X January 9, 2020 at 1:07 am - Reply

    Hey there, great tutorial! One small question:
    How did you manage to do the awesome trick just around 10:00, where you changed 300 to 700 but only some and not all of them?

  12. Ednawati Rainarli January 9, 2020 at 1:07 am - Reply

    thanks God, I found your channel. Actually, I'm a beginner in python. Your explanation is simple and understandable. Thank you

  13. Muhammad Atif January 9, 2020 at 1:07 am - Reply

    Hi ihave issue here plz guide me as much possible

    File "<ipython-input-3-613a1d0008dc>", line 8

    fn , fext = os.path.splitext(f)

    ^

    SyntaxError: invalid syntax
    

    from PIL import Image

    import os ,sys

    #img_link = []

    for f in os.listdir('./pictures/'): #the '.' is for current directory so the for loop looping through the current directory

    if str(f.endswith('*.jpg')):

    print(f)

    i=Image.open(open(f,'rb')

    fn , fext = os.path.splitext(f)

    print(fn)

  14. Josh James January 9, 2020 at 1:07 am - Reply

    Corey, you should make videos for Coursera. This is better than the python courses given by faculty.

  15. NeverFallingDown 94 January 9, 2020 at 1:07 am - Reply

    How do you convert one file into a gif file?

  16. M M January 9, 2020 at 1:07 am - Reply

    I did exactly what you did but I had this error:Traceback (most recent call last):

    File "C:/Users/MJ/Desktop/Flask_Application/Second_Project/fed_op/templates/os_model.py", line 11, in <module>

    f.thumbnail(risize)

    File "C:UsersMJDesktopFlask_ApplicationSecond_Projectenvlibsite-packagesPILImage.py", line 2209, in thumbnail

    if x > size[0]:

    TypeError: 'float' object is not subscriptable

  17. Aryan Rahul January 9, 2020 at 1:07 am - Reply

    I already install Pillow even after when i wrote "from PIL import Image" it shows error that ModuleNotFoundError.
    help me plzz…

  18. gnypp45 January 9, 2020 at 1:07 am - Reply

    A great video for me to get started with this library. Thanks!

  19. Amol Dhumal January 9, 2020 at 1:07 am - Reply

    How to convert Blur image to original ?????

  20. Mildly Interesting TV January 9, 2020 at 1:07 am - Reply

    How to implement loseless image compression

  21. O January 9, 2020 at 1:07 am - Reply

    Cory, i love your videos. it help me a lot with my projects. in a few months i learned python.

  22. 12major e January 9, 2020 at 1:07 am - Reply

    I just love the super detailed explanations accompanied by writing the code. Really amazing work here Corey and I hope you'll make more videos about Python libraries and common misunderstanding developers have. Big thank you!

  23. Rafael Cury Rayes January 9, 2020 at 1:07 am - Reply

    What IDE is that?

  24. shahriar keshvary January 9, 2020 at 1:07 am - Reply

    Great video but I have question. I looked around a lot to figure out a way to convert a 'jp2' image to something else. Apparently 'PIL' library does not support this format. I also tried the 'matplotlib' and that one did not work as well. do you have any recommendation to how convert a 'jp2' format to a 'mpeg' or 'Jpeg' using python? I really appreciate the help.

  25. Gerard Murillo January 9, 2020 at 1:07 am - Reply

    question were do you insert pip install pillow?????????????

  26. shyam the HADES January 9, 2020 at 1:07 am - Reply

    Instead of producing the Img, my command prompt pops up.. any idea???

  27. Radu Marian Goguta January 9, 2020 at 1:07 am - Reply

    Does anyone know why when I save an image, parts of it turns black? This is an issue I only face on Windows 10, same script, same libraries and versions, work perfectly on Windows 7

  28. Malcolm VanOrder January 9, 2020 at 1:07 am - Reply

    I know it's out of scope for this video, but if someone were using windows and duplicated your steps exactly, the "/" wouldn't be correct. Since you've already imported os, you can use os.path.join() as a platform agnostic way of building the path to the files.

  29. Brian Kantanka January 9, 2020 at 1:07 am - Reply

    How do I move my images to the same directory as python?

  30. vicky kumar January 9, 2020 at 1:07 am - Reply

    what is the function name, that is used to perform click action on images

  31. ChainMail January 9, 2020 at 1:07 am - Reply

    i keep getting a file not found error. i copy the direct path in my mac and the image still doesnt show up. help!

  32. Chris January 9, 2020 at 1:07 am - Reply

    Came for Python stayed for the puppy

  33. Victor T January 9, 2020 at 1:07 am - Reply

    When will you have OpenCV?

  34. D F January 9, 2020 at 1:07 am - Reply

    I like it. Going to have to learn more about the OS feature and how to loop through files and such without destroying my own directories lol but this looks like exactly what I will use when I have a better understanding of how that part works. Thank you

  35. ryan derksen January 9, 2020 at 1:07 am - Reply

    I am very appreciative that you are doing a tutorial on this but I am pretty sure you can do this without using other libraries. I could be wrong .

  36. Lightning in My Hands January 9, 2020 at 1:07 am - Reply

    You will be a legend in Python history.

  37. Arjun Vc January 9, 2020 at 1:07 am - Reply

    can you please explain how to read texts from images using python ? TIA

  38. Gerhard A. E. Uhlhorn January 9, 2020 at 1:07 am - Reply

    At the end: It’s not need to close and reopen the image. Preview is able to update an opened image. 😉

  39. Vasiliy January 9, 2020 at 1:07 am - Reply

    4 years later and it's still relevant. Thanks alot!

  40. Dennis January 9, 2020 at 1:07 am - Reply

    I used pip install and it's worked without any problem lol

  41. Vinod Kinoni January 9, 2020 at 1:07 am - Reply

    awesome

  42. Fabio Classo January 9, 2020 at 1:07 am - Reply

    Amazing video

  43. Slim Yelow January 9, 2020 at 1:07 am - Reply

    great intro Thanks !

  44. Matthew Stidham January 9, 2020 at 1:07 am - Reply

    Super helpful, thank you!

  45. Nia Bria January 9, 2020 at 1:07 am - Reply

    how to make 2 image in display python with pillow at the same time. thankyou

  46. Bon Bon January 9, 2020 at 1:07 am - Reply

    OK, now after I learned how to make Instagram, how about generating images pixel by pixel? (e.g. some procedural images or fancy image filtering)

  47. Vasu Deo.S January 9, 2020 at 1:07 am - Reply

    Awesome Video. Just a little rectification. The "L" mode that you used for converting your image into black and white, is actually for converting an image into greyscale. A black and white image only consists of 2 colors (Black & White) and the image that you converted had several shades of grey(0-255).

    For Converting an image into black and white you have to use "1" mode which stands for 1 bit per pixel which truly resembles a Black & White image, use that in disabled dither mode to actually see the black and white image otherwise you will see you image with grainy noise.

    You can sort of see this just by looking at the image, a black and white image should just contain black and white not any other color.

  48. Yates Snyder January 9, 2020 at 1:07 am - Reply

    i had installed Pillow but my decoder zip isn't available ………..

  49. ankit agrawal January 9, 2020 at 1:07 am - Reply

    hey the result of my (print f ) is random. How can i get that in oder starting from 0 till what ever number i have ?
    thankyou!

Leave A Comment

*