Remove unused ImagingConvertInPlace - #9878
Conversation
akx
left a comment
There was a problem hiding this comment.
I had been looking at removing ImagingConvertInPlace (in a bid to see if the shuffler functions could be implemented in a faster way) but didn't dare go through with it.
Some thoughts within though :)
| static PyObject * | ||
| im_setmode(ImagingObject *self, PyObject *args) { | ||
| im_setalpha(ImagingObject *self, PyObject *args) { | ||
| /* attempt to modify the mode of an image in place */ |
There was a problem hiding this comment.
This comment is a little stale now?
There was a problem hiding this comment.
Is it? The method is still modifying the mode of an image in place. It's more specific now, is all.
There was a problem hiding this comment.
I suppose...
Should this function know how to do P-to-PA and L-to-LA too?
There was a problem hiding this comment.
The thought occurred to me. It is a bit different to RGB, since RGB already has the same pixelsize as RGBA.
Do you mind if that is a follow-up PR? I would rather tidy things up first.
|
I'll click the rebase button to test automerge (#9126) on a non-docs PR:
|

im.putalpha()is the only place where C'ssetmode()is called.Pillow/src/PIL/Image.py
Lines 2050 to 2052 in 3220aca
This is only trying to convert the image to LA, PA or RGBA.
However, the only operation
setmode()can actually succeed at is converting RGB or RGBX to RGBA.Pillow/src/_imaging.c
Lines 2079 to 2090 in 3220aca
Pillow/src/libImaging/Convert.c
Lines 1739 to 1748 in 3220aca
ImagingConvertInPlace()isn't able to convert anything to LA, PA or RGBA.So this PR
ImagingConvertInPlace().setmode()is the only place whereImagingConvertInPlace()is called.setmode()to more clearly only convert RGB or RGBX images to RGBA. I've also renamed it tosetalpha().