diff --git a/src/calibre/gui2/tweak_book/editor/canvas.py b/src/calibre/gui2/tweak_book/editor/canvas.py index de3da967f8..39126e7e92 100644 --- a/src/calibre/gui2/tweak_book/editor/canvas.py +++ b/src/calibre/gui2/tweak_book/editor/canvas.py @@ -21,7 +21,7 @@ from calibre.gui2.dnd import ( IMAGE_EXTENSIONS, dnd_has_extension, dnd_has_image, dnd_get_image, DownloadDialog) from calibre.gui2.tweak_book import capitalize from calibre.utils.imghdr import identify -from calibre.utils.img import remove_borders, gaussian_sharpen, gaussian_blur, image_to_data, despeckle +from calibre.utils.img import remove_borders, gaussian_sharpen, gaussian_blur, image_to_data, despeckle, normalize def painter(func): @wraps(func) @@ -149,6 +149,13 @@ class Despeckle(Command): def __call__(self, canvas): return despeckle(canvas.current_image) +class Normalize(Command): + + TEXT = _('Normalize image') + + def __call__(self, canvas): + return normalize(canvas.current_image) + class Replace(Command): ''' Replace the current image with another image. If there is a selection, @@ -368,6 +375,11 @@ class Canvas(QWidget): self.undo_stack.push(Despeckle(self)) return True + @imageop + def normalize_image(self): + self.undo_stack.push(Normalize(self)) + return True + # The selection rectangle {{{ @property def dc_size(self): diff --git a/src/calibre/gui2/tweak_book/editor/image.py b/src/calibre/gui2/tweak_book/editor/image.py index facbd190a3..028a03ee11 100644 --- a/src/calibre/gui2/tweak_book/editor/image.py +++ b/src/calibre/gui2/tweak_book/editor/image.py @@ -273,6 +273,7 @@ class Editor(QMainWindow): m.addAction(_('Sharpen image'), self.sharpen_image) m.addAction(_('Blur image'), self.blur_image) m.addAction(_('De-speckle image'), self.canvas.despeckle_image) + m.addAction(_('Improve contrast (normalize image)'), self.canvas.normalize_image) self.info_bar = b = self.addToolBar(_('Image information bar')) b.setObjectName('image_info_bar')