找回密碼
 註冊
搜索
查看: 1026|回復: 0

[教學] Python PIL 截圖後成為新檔案後旋轉

[複製鏈接]
發表於 2021-1-26 20:52:06 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
原圖

Python PIL 截圖 旋轉

Python PIL 截圖 旋轉


結果圖

Python PIL 截圖 旋轉

Python PIL 截圖 旋轉



代碼
  1. from PIL import Image
  2. im = Image.open('../img/cat.jpg').convert('RGB')
  3. box=(240,195,760,700)
  4. image_crop=im.crop(box)
  5. image_crop.save('cat1.jpg')

  6. from PIL import  ImageDraw
  7. import  matplotlib.pyplot as plt
  8. im3 = Image.new('RGB',(700,700))
  9. im1=image_crop.rotate(45)
  10. im3.paste(im1,(50,50))
  11. plt.imshow(im3)
  12. plt.show()
  13. im3.save('cat3.jpg')
複製代碼



 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-4-30 19:46 , Processed in 0.024638 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表