M
M
mr_blaze2017-07-02 13:41:21
Python
mr_blaze, 2017-07-02 13:41:21

Pillow, OpenCV Python: how to crop an image?

Druste!
There is an image that needs to be cropped from X1 Y1 to X2 Y2 using Pillow or Opencv (Python) how to do it?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Setup, 2017-07-02
@mr_blaze

https://www.youtube.com/watch?v=mjy1_3ISAnc

D
Dimonchik, 2017-07-02
@dimonchik2013

from PIL import Image
from pathlib import Path

imgfile = Path(filename)
 img = Image.open(imgfile)
 width = img.size[0]
 height = img.size[1]
img3 = img.crop( (0,0,width,height-20) )
img3.save(filename)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question