私は、背景が大(大)、画像がプロキPIC貼り付け後の画像品質を低くする
コード:この後
# open the profile pic
im = PIL.Image.open(pic)
# resize it to dim of oblique box
im = im.resize((picX, picY))
# this is the degree of oblique box
degree = 13.67
# open the background
bg = PIL.Image.open(bgsrc)
bgosize = bg.size
bginfo = bg.info
# first, I rotate the background to be paralell with profile pic
bg = bg.rotate(-degree, resample = PIL.Image.BILINEAR, expand = True)
# paste the profile pic to background
bg.paste(im, (px1, py1, px2, py2))
# rotate back to original orientation
bg = bg.rotate(degree, resample = PIL.Image.BILINEAR, expand = False)
# crop the rotated image, because it's greater than original size,
# after first rotate - coords are stored
bg.crop(bgx1, bgy1, bgx2, bgy2)
PIL.ImageFile.MAXBLOCK = bg.size[0] * bg.size[1]
bg.save(dst, quality = 250, optimize = True, **bginfo)
結果画像を変換がnubbly litlebitです...
にはどうすれば良いqualtiyの画像を得ることができますか?
ありがとう:
a。
こんにちはマーク、返信ありがとう 1:私もBILINEARを試しました。効果はありません。 2:プロファイル画像を最初に回転すると、黒い背景のある大きな寸法にリサイズされます - JPEGを透明PNGに回転/変換するにはどうすればいいですか? 3:例があれば、マスク引数をチェックします。ありがとうございました。 – airween
こんにちはマーク、この例に感謝します。 im.rotateとmask.rotateの後で画像をオンザフライで保存すると、それらもまた鼻くそです...私が背景を開いてPILから保存しても、それは鼻をかわすでしょう。 私の別のコメント:(imの代わりに)crオブジェクトがマスクされているとき、黒い背景があります - 透明な背景を作成するにはどうすればいいですか?どうもありがとう: – airween