<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_size(self, w, h):
 """Record size."""

        if (w is None):
            self.sw = self.rw
            self.sh = self.rh
        else:
            self.sw = w
            self.sh = h
        # Now we have region and size, generate the image
        image = Image.new("RGB", (self.sw, self.sh), self.gen.background_color)
        for y in range(0, self.sh):
            for x in range(0, self.sw):
                ix = int((x * self.rw) // self.sw + self.rx)
                iy = int((y * self.rh) // self.sh + self.ry)
                color = self.gen.pixel(ix, iy)
                if (color is not None):
                    image.putpixel((x, y), color)
        self.image = image