def main(argv): img = Image.open(argv[1]) document = dsc_document("Raster Image Demo") page = document.page() canvas = page.canvas(margin=mm(18), border=True) eps = raster_image(canvas, img, document_level=False, border=True) page.append(eps) fp = open(sys.argv[1] + ".ps", "w") document.write_to(fp) fp.close()
def draw(self, canvas): image_box = box.raster_image(canvas, self.image, document_level=True, border=False, clip=False) iw, ih = self.image.size iw, ih = float(iw), float(ih) w, h = self.size(canvas) scale_factor = w / iw canvas._("gsave", 0, canvas.h() - h, "translate", scale_factor, scale_factor, "scale") canvas.append(image_box) canvas._("grestore") return h, True