Reputation: 185
Is there any simple way to remove a single row of pixels in PIL (Pillow)?
I have considered
But it seems unnecessary complicated.
I am not familiar with modifying images in other python libraries, but if it is significantly simplyfying the task I will consider it.
Upvotes: 1
Views: 2375
Reputation: 2455
You could convert the image into a numpy array using numpy.array(image)
and then use numpy.delete()
to remove a row before converting it back into an image with PIL.Image.fromarray()
.
For example, this would remove the 7th row from the image.
a = numpy.array(im)
a = numpy.delete(a, 6, 0)
im = Image.fromarray(a)
Upvotes: 3