Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@ def point(self, im: Image) -> Image:

if callable(lut):
# if it isn't a list, it should be a function
if self.mode in ("I", "I;16", "I;16L", "I;16B", "I;16N", "F"):
if self.mode in {"I", "I;16", "I;16L", "I;16B", "I;16N", "F"}:
# check if the function can be used with point_transform
# UNDONE wiredfool -- I think this prevents us from ever doing
# a gamma function point transform on > 8bit images.
Expand All @@ -2094,8 +2094,7 @@ def point(self, im: Image) -> Image:
else:
flatLut = lut

if self.mode == "F":
# FIXME: _imaging returns a confusing error message for this case
if self.mode in {"I;16", "I;16L", "I;16B", "I;16N", "F"}:
msg = "point operation not supported for this mode"
raise ValueError(msg)

Expand Down
4 changes: 3 additions & 1 deletion src/libImaging/Effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ ImagingEffectMandelbrot(int xsize, int ysize, double extent[4], int quality) {
width = extent[2] - extent[0];
height = extent[3] - extent[1];
if (width < 0.0 || height < 0.0 || quality < 2) {
return (Imaging)ImagingError_ValueError(NULL);
return (Imaging)ImagingError_ValueError(
"extent width and height must be >= 0 and quality must be >= 2"
);
}

im = ImagingNewDirty(IMAGING_MODE_L, xsize, ysize);
Expand Down
20 changes: 10 additions & 10 deletions src/libImaging/Point.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,21 @@ ImagingPoint(Imaging imIn, ModeID mode, const void *table) {

if (imIn->type == IMAGING_TYPE_UINT8) {
if (imIn->mode != mode && !imIn->image8) {
goto mode_mismatch;
return (Imaging)ImagingError_ValueError(
"modes LA, La, PA, RGB, RGBX, RGBA, RGBa, CMYK, YCbCr, LAB or HSV only "
"supported for matching output modes"
);
}
} else if (imIn->type == IMAGING_TYPE_INT32) {
if (mode != IMAGING_MODE_L) {
// I images can only be used with L output mode
goto mode_mismatch;
return (Imaging)ImagingError_ValueError(
"mode I only supported for L output mode"
);
}
} else {
// Reject F modes and modes based on I;16
goto mode_mismatch;
return (Imaging)ImagingError_ValueError(
"modes F and I;16 variants not supported"
);
}

imOut = ImagingNewDirty(mode, imIn->xsize, imIn->ysize);
Expand Down Expand Up @@ -229,11 +234,6 @@ ImagingPoint(Imaging imIn, ModeID mode, const void *table) {
ImagingSectionLeave(&cookie);

return imOut;

mode_mismatch:
return (Imaging)ImagingError_ValueError(
"point operation not supported for this mode"
);
}

/**
Expand Down
Loading