我正在使用Python Wand模塊(版本0.4.3。)將存儲在pdf中的圖像轉換爲PNG。當我將最終圖像保存在原始圖像的寬度和高度時,最終的PNG質量非常好。但是,當我嘗試將它保存爲較小的圖像時,最終的PNG會變得模糊,質量也不是那麼好。Python Wand Scaling問題
兩張圖片之間的差異顯示爲here。頂部圖像被轉換爲原始大小(10800x7200px)。第二個是縮放到1250x833px。
有什麼辦法可以改善第二張圖片嗎?我玩過不同的濾鏡和模糊設置。但是,無法獲得我想要的圖像質量。任何幫助是極大的讚賞。
代碼我用PDF轉換爲原始大小巴布亞新幾內亞:
def pdf_to_png(pdf_name, res):
with Image(filename=pdf_name, resolution=res) as img:
with Image(width=img.width,height=img.height, background=Color("white")) as bg:
bg.composite(img,0,0)`
bg.save(filename="Drawing_improved_wand.png")`
pdf_to_png('Drawing_1.pdf', 300)
代碼調整大小PNG:
with Image(filename="Drawing_1.pdf", resolution=(300,300)) as img:
with Image(width=1250, height=833, background=Color("white")) as bg:
img.resize(1250, 833,filter='undefined', blur=1)
img.format = 'png'
bg.composite(img,0,0)
bg.save(filename='Drawing_improved_wand1250x833.png')
這並不提供答案的問題。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/16921018) – whrrgarbl