def _get_scaled_image(self, resource):
        """
        Get scaled watermark image
        :param resource: Image.Image
        :return: Image.Image
        """
        image = self._get_image()
        original_width, original_height = resource.size

        k = image.size[0] / float(image.size[1])

        if image.size[0] >= image.size[1]:
            target_width = int(original_width * self.size)
            target_height = int(target_width / k)
        else:
            target_height = int(original_height * self.size)
            target_width = int(target_height * k)

        image = image.resize((target_width, target_height), Image.ANTIALIAS)

        return image
def _get_scaled_image ( self , resource ) : image = self . _get_image ( ) original_width , original_height = resource . size k = image . size [ 0 ] / float ( image . size [ 1 ] ) if image . size [ 0 ] >= image . size [ 1 ] : target_width = int ( original_width * self . size ) target_height = int ( target_width / k ) else : target_height = int ( original_height * self . size ) target_width = int ( target_height * k ) image = image . resize ( ( target_width , target_height ) , Image . ANTIALIAS ) return image
Get scaled watermark image
        :param resource: Image.Image
        :return: Image.Image