Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Open CV
  • scikit-image
  • pycairo
  • Pyglet
  • Python
  • Numpy
  • Pandas
  • Python Database
  • Data Science With Python
  • Machine Learning with Python
  • Django
  • Flask
  • R
Open In App
Next Article:
Python Pillow - Image Sequences
Next article icon

Python | Crop image using pillow

Last Updated : 16 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will learn to crop an image using pillow library. Cropping an image means to select a rectangular region inside an image and removing everything outside the rectangle. To crop an image we make use of crop() method on image objects.

Syntax : IMG.crop(box_tuple)

Parameters :
Image_path- Location of the image
IMG- Image to crop
box_tuple- [left, up, right, bottom] of the image to crop

Returns : An Image object which represents the cropped image.

Example 1:




# import Image module
from PIL import Image
  
# open the image
Image1 = Image.open('D:/cat.jpg')
  
# crop the image
croppedIm = Image1.crop((130, 120, 200, 200))
  
# show the image
croppedIm.show()
 
 

Input Image :

Output :

Example 2:




# import Image module
from PIL import Image
  
# open the image
Image1 = Image.open('D:/cat.jpg')
  
# crop the image
croppedIm = Image1.crop((130, 50, 250, 150))
  
# show the image
croppedIm.show()
 
 

Input Image :

Output :



Next Article
Python Pillow - Image Sequences

D

DeepakDev
Improve
Article Tags :
  • Python
  • Python-pil
Practice Tags :
  • python

Similar Reads

  • Floodfill Image using Python-Pillow
    Seed Fill also known as flood fill, is an algorithm used to identify connected paths in a definite enclosed region. The algorithm has an array of practical applications, such as - Optimized pathfindingPaint Bucket Tool a generic tool found in several image processing packages, uses the algorithm int
    3 min read
  • Python Pillow - Using Image Module
    In this article, we will see how to work with Image Module of PIL in Python. First, let's see how to install the PIL.  Installation: Linux: On the Linux terminal type the following: pip install Pillow Installing pip via terminal: sudo apt-get update sudo apt-get install python-pipWorking with Image
    5 min read
  • Python - Channel Drop using Pillow
    A channel drop is a method of removing one of the channels of a multichannel image. By removing means turning the color value of a particular channel to 0 (all pixels), i.e. that particular channel doesn't have any effect on the final image (assuming colors are blended `normally`). Color theory (Col
    5 min read
  • Python Pillow - Image Sequences
    The ImageSequence module in the pillow contains a wrapper class that helps users to iterate over the frames of an image sequence. It can iterate over animations, gifs, etc. Iterator class This class accepts an image object as a parameter. It implements an iterator object that can be used by a user t
    3 min read
  • Python Image Editor Using Python
    You can create a simple image editor using Python by using libraries like Pillow(PIL) which will provide a wide range of image-processing capabilities. In this article, we will learn How to create a simple image editor that can perform various operations like opening an image, resizing it, blurring
    13 min read
  • Python Pillow - Blur an Image
    Blurring an image is a process of reducing the level of noise in the image, and it is one of the important aspects of image processing. In this article, we will learn to blur an image using a pillow library. To blur an image we make use of some methods of ImageFilter class of this library on image o
    2 min read
  • Python Pillow - Working with Images
    In this article, we will see how to work with images using Pillow in Python. We will discuss basic operations like creating, saving, rotating images. So let's get started discussing in detail but first, let's see how to install pillow. Installation To install this package type the below command in t
    4 min read
  • How to Concatenate image using Pillow in Python ?
    Prerequisites: Python Pillow Concatenate image means joining of two images. We can merge any image whether it has different pixels, different image formats namely, 'jpeg', 'png', 'gif', 'tiff', etc. In python, we can join two images using the Python image library also known as the pillow library. In
    3 min read
  • Convert PDF to Image using Python
    Many tools are available on the internet for converting a PDF to an image. In this article, we are going to write code for converting pdf to image and make a handy application in python. Before writing the code we need to install the required module pdf2image and poppler. Modules Neededpdf2image 1.1
    2 min read
  • Python PIL | Image.crop() method
    PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. PIL.Image.crop() method is used to crop a rectangular portion of any image. Syntax: PIL.Image.crop(box = None)Parameters: box - a 4-tuple defining the left, upper, right, and lower pixel coordina
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences