Skip to content

Set padding bytes in new 2 channel images to zero - #10511

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:new_zero
Open

radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:new_zero

Conversation

@radarhere

Copy link
Copy Markdown
Member

For the padding bytes in two channel images, I've previously suggested setting them to zero in convert() in #7276. That had a lukewarm reception, so I closed it.

However, in the case of getink(),

Pillow/src/_imaging.c

Lines 609 to 610 in b60880a

getink(PyObject *color, Imaging im, char *ink) {
int g = 0, b = 0, a = 0;

Pillow/src/_imaging.c

Lines 673 to 683 in b60880a

if (im->bands == 2) {
if (tupleSize != 1 && tupleSize != 2) {
PyErr_SetString(
PyExc_TypeError,
"color must be int, or tuple of one or two elements"
);
return NULL;
} else if (!PyArg_ParseTuple(color, "L|i", &r, &a)) {
return NULL;
}
g = b = r;

it really does seem simpler to remove g = b = r; and leave g and b as zero.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant