我在旋转我创建的图像时遇到问题。因为代码分布在许多方法中,所以我将我认为相关的命令放在下面。在
问题是,当图像创建成功时,当我使用图像旋转但图像不旋转(请参见背景)。在
我怎样才能纠正这一点。我需要创建一个更大的透明背景吗?我可以让背景/画布也旋转…还是旋转然后调整背景/画布的大小?在
第一个示例图像(QRCODE)img = Image.new('RGB', (x,y), 'white')
qr = qrcode.QRCode(version=1,error_correction=qrcode.constants.ERROR_CORRECT_L,box_size=10,border=1,)
qr.add_data('QRB.NO/AbCd1')
qr.make(fit=True)
QRimg = qr.make_image()
img = img.paste(QRimg, (x,y))
img.show() #333
raw_input('(Above is unrotated QRcode image) Press enter...') #333
img = img.rotate(-90)
print img, type(img)
img.show() #333
raw_input('Above is the rotated -90 QRcode image. Press enter...') #333
第二个示例图像
^{pr2}$
输出
(Above is unrotated QRcode image) Press enter...
Above is the rotated -90 QRcode image. Press enter...
(Above is the unrotated test image). Press enter...
(Above is the ROTATED 90 text image). Press enter...
编辑:x,y = img.size
img = img.resize( (y, x), Image.ANTIALIAS )
img = img.rotate(-90)
……或者。。。在x,y = img.size
img = img.rotate(-90)
img = img.resize( (y, x), Image.ANTIALIAS )
……似乎帮不了什么忙。在