[Image-SIG] bug in pildriver.py PASTE operation (1.1.5)

Bill Janssen janssen at parc.com
Tue Feb 28 22:43:48 CET 2006


The code for the pildriver.py "paste" operation currently looks like this:

    def do_paste(self):
        """usage: paste <image:figure> <int:xoffset> <int:yoffset> <image:ground>

        Paste figure image into ground with upper left at given offsets.
        """
        figure = self.do_pop()
        xoff = int(self.do_pop())
        yoff = int(self.do_pop())
        ground = self.do_pop()
        if figure.mode == "RGBA":
            self.push(ground.paste(figure, (xoff, yoff), figure))
        else:
            self.push(ground.paste(figure, (xoff, yoff)))

This seems somewhat useless -- a None value gets pushed on the stack.

More useful would be:

    def do_paste(self):
        """usage: paste <image:figure> <int:xoffset> <int:yoffset> <image:ground>

        Paste figure image into ground with upper left at given offsets.
        """
        figure = self.do_pop()
        xoff = int(self.do_pop())
        yoff = int(self.do_pop())
        ground = self.do_pop()
        if figure.mode == "RGBA":
	    ground.paste(figure, (xoff, yoff), figure)
        else:
            ground.paste(figure, (xoff, yoff))
        self.push(ground)

Otherwise you need an extraneous dup (to make a copy of the ground)
and pop (to get rid of the None) in there.

Bill



More information about the Image-SIG mailing list