mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #1959893 [Trim Image - Size of selected area is incorrect](https://bugs.launchpad.net/calibre/+bug/1959893)
This commit is contained in:
parent
57d24f0538
commit
ed209b9374
@ -83,10 +83,9 @@ class TrimImage(QDialog):
|
||||
|
||||
def selection_area_changed(self, rect):
|
||||
if rect:
|
||||
w = rect.width()
|
||||
h = rect.height()
|
||||
x, y, w, h = map(int, self.canvas.rect_for_trim())
|
||||
text = f'{int(w)}x{int(h)}'
|
||||
text = _('Size: {0}px Aspect ratio: {1:.2g}').format(text, w / h)
|
||||
text = _('Size: {0}px Aspect ratio: {1:.3g}').format(text, w / h)
|
||||
else:
|
||||
text = ''
|
||||
self.tr_sz.setText(text)
|
||||
|
@ -93,10 +93,7 @@ class Trim(Command):
|
||||
TEXT = _('Trim image')
|
||||
|
||||
def __call__(self, canvas):
|
||||
img = canvas.current_image
|
||||
target = canvas.target
|
||||
sr = canvas.selection_state.rect
|
||||
return img.copy(*map(int, get_selection_rect(img, sr, target)))
|
||||
return canvas.current_image.copy(*map(int, canvas.rect_for_trim()))
|
||||
|
||||
|
||||
class AutoTrim(Trim):
|
||||
@ -502,6 +499,12 @@ class Canvas(QWidget):
|
||||
if edge is not None:
|
||||
self.move_edge(edge, dp)
|
||||
|
||||
def rect_for_trim(self):
|
||||
img = self.current_image
|
||||
target = self.target
|
||||
sr = self.selection_state.rect
|
||||
return get_selection_rect(img, sr, target)
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
if ev.button() == Qt.MouseButton.LeftButton and self.target.contains(ev.pos()):
|
||||
pos = ev.pos()
|
||||
|
Loading…
x
Reference in New Issue
Block a user