mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a trim cover option ot the bulk metadata edit dialog
Merge branch 'Bulk-trim-covers' of git://github.com/sengian/calibre
This commit is contained in:
commit
a401b2ab7d
@ -385,6 +385,12 @@ sort_dates_using_visible_fields = False
|
|||||||
generate_cover_title_font = None
|
generate_cover_title_font = None
|
||||||
generate_cover_foot_font = None
|
generate_cover_foot_font = None
|
||||||
|
|
||||||
|
#: Fuzz value for trimming covers
|
||||||
|
# The value used for the fuzz distance when trimming a cover.
|
||||||
|
# Colors within this distance are considered equal.
|
||||||
|
# The distance is in absolute intensity units.
|
||||||
|
cover_trim_fuzz_value = 10
|
||||||
|
|
||||||
#: Control behavior of the book list
|
#: Control behavior of the book list
|
||||||
# You can control the behavior of doubleclicks on the books list.
|
# You can control the behavior of doubleclicks on the books list.
|
||||||
# Choices: open_viewer, do_nothing,
|
# Choices: open_viewer, do_nothing,
|
||||||
|
@ -204,6 +204,16 @@ class MyBlockingBusyNew(QDialog): # {{{
|
|||||||
covers.sort(key=lambda x: x[1])
|
covers.sort(key=lambda x: x[1])
|
||||||
if covers:
|
if covers:
|
||||||
cache.set_cover({book_id:covers[-1][0]})
|
cache.set_cover({book_id:covers[-1][0]})
|
||||||
|
elif args.cover_action == 'trim':
|
||||||
|
from calibre.utils.magick import Image
|
||||||
|
for book_id in self.ids:
|
||||||
|
cdata = cache.cover(book_id)
|
||||||
|
if cdata:
|
||||||
|
im = Image()
|
||||||
|
im.load(cdata)
|
||||||
|
im.trim(tweaks['cover_trim_fuzz_value'])
|
||||||
|
cdata = im.export('jpg')
|
||||||
|
cache.set_cover({book_id:cdata})
|
||||||
|
|
||||||
# Formats
|
# Formats
|
||||||
if args.do_remove_format:
|
if args.do_remove_format:
|
||||||
@ -423,6 +433,15 @@ class MyBlockingBusy(QDialog): # {{{
|
|||||||
if covers:
|
if covers:
|
||||||
self.db.set_cover(id, covers[-1][0])
|
self.db.set_cover(id, covers[-1][0])
|
||||||
covers = []
|
covers = []
|
||||||
|
elif cover_action == 'trim':
|
||||||
|
from calibre.utils.magick import Image
|
||||||
|
cdata = self.db.cover(id, index_is_id=True)
|
||||||
|
if cdata:
|
||||||
|
im = Image()
|
||||||
|
im.load(cdata)
|
||||||
|
im.trim(tweaks['cover_trim_fuzz_value'])
|
||||||
|
cdata = im.export('jpg')
|
||||||
|
self.db.set_cover(id, cdata)
|
||||||
|
|
||||||
if do_remove_format:
|
if do_remove_format:
|
||||||
self.db.remove_format(id, remove_format, index_is_id=True,
|
self.db.remove_format(id, remove_format, index_is_id=True,
|
||||||
@ -1213,6 +1232,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
cover_action = 'generate'
|
cover_action = 'generate'
|
||||||
elif self.cover_from_fmt.isChecked():
|
elif self.cover_from_fmt.isChecked():
|
||||||
cover_action = 'fromfmt'
|
cover_action = 'fromfmt'
|
||||||
|
elif self.cover_trim.isChecked():
|
||||||
|
cover_action = 'trim'
|
||||||
|
|
||||||
args = Settings(remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
|
args = Settings(remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
|
||||||
do_autonumber, do_remove_format, remove_format, do_swap_ta,
|
do_autonumber, do_remove_format, remove_format, do_swap_ta,
|
||||||
|
@ -603,6 +603,13 @@ Future conversion of these books will use the default settings.</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="cover_trim">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Trim cover</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="cover_from_fmt">
|
<widget class="QRadioButton" name="cover_from_fmt">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -971,7 +971,7 @@ class Cover(ImageView): # {{{
|
|||||||
return
|
return
|
||||||
im = Image()
|
im = Image()
|
||||||
im.load(cdata)
|
im.load(cdata)
|
||||||
im.trim(10)
|
im.trim(tweaks['cover_trim_fuzz_value'])
|
||||||
cdata = im.export('png')
|
cdata = im.export('png')
|
||||||
self.current_val = cdata
|
self.current_val = cdata
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user