mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
replace resize implementation
This commit is contained in:
parent
d781d56aa5
commit
aba798af25
11
PIL/Image.py
11
PIL/Image.py
|
@ -1539,16 +1539,7 @@ class Image:
|
||||||
if self.mode == 'RGBA':
|
if self.mode == 'RGBA':
|
||||||
return self.convert('RGBa').resize(size, resample).convert('RGBA')
|
return self.convert('RGBa').resize(size, resample).convert('RGBA')
|
||||||
|
|
||||||
if resample == ANTIALIAS:
|
return self._new(self.im.resize(size, resample))
|
||||||
# requires stretch support (imToolkit & PIL 1.1.3)
|
|
||||||
try:
|
|
||||||
im = self.im.stretch(size, resample)
|
|
||||||
except AttributeError:
|
|
||||||
raise ValueError("unsupported resampling filter")
|
|
||||||
else:
|
|
||||||
im = self.im.resize(size, resample)
|
|
||||||
|
|
||||||
return self._new(im)
|
|
||||||
|
|
||||||
def rotate(self, angle, resample=NEAREST, expand=0):
|
def rotate(self, angle, resample=NEAREST, expand=0):
|
||||||
"""
|
"""
|
||||||
|
|
21
_imaging.c
21
_imaging.c
|
@ -1513,9 +1513,26 @@ _resize(ImagingObject* self, PyObject* args)
|
||||||
|
|
||||||
imIn = self->image;
|
imIn = self->image;
|
||||||
|
|
||||||
|
if (imIn->xsize == xsize && imIn->ysize == ysize) {
|
||||||
|
imOut = ImagingCopy(imIn);
|
||||||
|
}
|
||||||
|
else if ( ! filter) {
|
||||||
|
double a[6];
|
||||||
|
|
||||||
|
memset(a, 0, sizeof a);
|
||||||
|
a[1] = (double) imIn->xsize / xsize;
|
||||||
|
a[5] = (double) imIn->ysize / ysize;
|
||||||
|
|
||||||
imOut = ImagingNew(imIn->mode, xsize, ysize);
|
imOut = ImagingNew(imIn->mode, xsize, ysize);
|
||||||
if (imOut)
|
|
||||||
(void) ImagingResize(imOut, imIn, filter);
|
imOut = ImagingTransformAffine(
|
||||||
|
imOut, imIn,
|
||||||
|
0, 0, xsize, ysize,
|
||||||
|
a, filter, 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imOut = ImagingStretch(imIn, xsize, ysize, filter);
|
||||||
|
}
|
||||||
|
|
||||||
return PyImagingNew(imOut);
|
return PyImagingNew(imOut);
|
||||||
}
|
}
|
||||||
|
|
|
@ -979,30 +979,6 @@ ImagingTransformQuad(Imaging imOut, Imaging imIn,
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Convenience functions */
|
/* Convenience functions */
|
||||||
|
|
||||||
Imaging
|
|
||||||
ImagingResize(Imaging imOut, Imaging imIn, int filterid)
|
|
||||||
{
|
|
||||||
double a[6];
|
|
||||||
|
|
||||||
if (imOut->xsize == imIn->xsize && imOut->ysize == imIn->ysize)
|
|
||||||
return ImagingCopy2(imOut, imIn);
|
|
||||||
|
|
||||||
memset(a, 0, sizeof a);
|
|
||||||
a[1] = (double) imIn->xsize / imOut->xsize;
|
|
||||||
a[5] = (double) imIn->ysize / imOut->ysize;
|
|
||||||
|
|
||||||
if (!filterid && imIn->type != IMAGING_TYPE_SPECIAL)
|
|
||||||
return ImagingScaleAffine(
|
|
||||||
imOut, imIn,
|
|
||||||
0, 0, imOut->xsize, imOut->ysize,
|
|
||||||
a, 1);
|
|
||||||
|
|
||||||
return ImagingTransformAffine(
|
|
||||||
imOut, imIn,
|
|
||||||
0, 0, imOut->xsize, imOut->ysize,
|
|
||||||
a, filterid, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Imaging
|
Imaging
|
||||||
ImagingRotate(Imaging imOut, Imaging imIn, double theta, int filterid)
|
ImagingRotate(Imaging imOut, Imaging imIn, double theta, int filterid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -285,7 +285,6 @@ extern Imaging ImagingPointTransform(
|
||||||
Imaging imIn, double scale, double offset);
|
Imaging imIn, double scale, double offset);
|
||||||
extern Imaging ImagingPutBand(Imaging im, Imaging imIn, int band);
|
extern Imaging ImagingPutBand(Imaging im, Imaging imIn, int band);
|
||||||
extern Imaging ImagingRankFilter(Imaging im, int size, int rank);
|
extern Imaging ImagingRankFilter(Imaging im, int size, int rank);
|
||||||
extern Imaging ImagingResize(Imaging imOut, Imaging imIn, int filter);
|
|
||||||
extern Imaging ImagingRotate(
|
extern Imaging ImagingRotate(
|
||||||
Imaging imOut, Imaging imIn, double theta, int filter);
|
Imaging imOut, Imaging imIn, double theta, int filter);
|
||||||
extern Imaging ImagingRotate90(Imaging imOut, Imaging imIn);
|
extern Imaging ImagingRotate90(Imaging imOut, Imaging imIn);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user