mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
API to rotate images
This commit is contained in:
parent
b0844e0502
commit
019eaad9d7
@ -7,7 +7,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
import os, subprocess, errno, shutil, tempfile
|
||||
from threading import Thread
|
||||
|
||||
from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter
|
||||
from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform
|
||||
|
||||
from calibre import fit_image, force_unicode
|
||||
from calibre.constants import iswindows, plugins
|
||||
@ -238,6 +238,11 @@ class Canvas(object):
|
||||
def flip_image(img, horizontal=False, vertical=False):
|
||||
return image_from_data(img).mirrored(horizontal, vertical)
|
||||
|
||||
def rotate_image(img, degrees):
|
||||
t = QTransform()
|
||||
t.rotate(degrees)
|
||||
return image_from_data(img).transformed(t)
|
||||
|
||||
def remove_borders(img, fuzz=None):
|
||||
''' Try to auto-detect and remove any borders from the image. Returns
|
||||
the image itself if no borders could be removed. `fuzz` is a measure of
|
||||
|
Loading…
x
Reference in New Issue
Block a user