Ejemplo n.º 1
0
    def affine(self, a, b, c, d, dx, dy, ox, oy, ow, oh, interpolate=None):
        """
        Returns a new VImage that is affine transformed from this image.
        Uses `interpolate` as the interpolation method.

        interpolate: interpolation method (near, bilinear). Default: bilinear

        For other parameters, see LibVips.im_affinei()
        """
        if interpolate is None or interpolate == "bilinear":
            interpolate = VIPS.vips_interpolate_bilinear_static
        elif interpolate == "near":
            interpolate = VIPS.vips_interpolate_nearest_static
        else:
            raise ValueError("interpolate must be near or bilinear, not {0!r}".format(interpolate))

        # Link output to self, because its buffer is related to self.image()
        # We don't want self to get destructed in C++ when Python garbage
        # collects self if it falls out of scope.
        output = VImage()
        output.__inputref = self

        VIPS.im_affinei(self.image(), output.image(), interpolate, a, b, c, d, dx, dy, ox, oy, ow, oh)

        return output