Python - Rotate Image

前端 未结 5 1793
时光说笑
时光说笑 2021-01-06 17:41

How can I rotate an image in Python with the help of OpenCv library, and by changing the value of height and width of the image (without using the built-in methods for rotat

5条回答
  •  半阙折子戏
    2021-01-06 18:13

    I use the PIL package, it's very simple to do that.

    from PIL import Image
    path = '/Users/diegodsp/sample.jpg'
    img = Image.open(path)
    img = img.rotate(90) # 90, -90, 180, ...
    img.save(path) # to override your old file
    

提交回复
热议问题