[PYTHON] Image addition memo in reportlab

When bottomup is not specified

filename = 'pdftest'
# -*- coding: utf-8 -*-
from reportlab.pdfgen import canvas
from PIL import Image

image =Image.open('/Users/momiji/work/spam.jpg')

pdf_cnvs = canvas.Canvas('./spam.pdf' )  
pdf_cnvs.setPageSize((image.size[0]+10,image.size[1]+10))
pdf_cnvs.drawInlineImage(image,0,0)
pdf_cnvs.save()

スクリーンショット 2014-01-25 22.28.59.png

The origin is at the bottom left.

When bottmup = False

pdf_cnvs = canvas.Canvas('./spam.pdf',bottomup=False)  

スクリーンショット 2014-01-25 22.42.18.png It will be like this.

change y coordinate

pdf_cnvs.drawInlineImage(image,0,-image.size[1])

スクリーンショット 2014-01-25 23.04.57.png

It is drawn from the upper left, but it is rotated 180 degrees.

-- When I paste an image with drawInlineImage, a case occurs that is interrupted on the ipad. If you read it on ipad, drawImage was better.

Recommended Posts

Image addition memo in reportlab
Image reading memo
Image sending / receiving memo in Python (Flask)
CG image quality evaluation memo in Python
Clip shape in reportlab
Image format in Python
Image uploader in Flask
Image normalization in TensorFlow
Tweet with image in Python
SLIC Superpixel segmentation in scikit image
Detect mosaic points in the image
[Image connection] Arrange images in tiles
Install tensorflow in Docker (LINUX) (memo)
Hello World in Flask [Appropriate memo]
Linux command (basic in basic) personal memo
Memo of pixel position operation for image data in Python (numpy, cv2)