mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Dont put the code to convert webp in the base module
This commit is contained in:
parent
2d68fbabb0
commit
555b629e17
@ -89,8 +89,7 @@ class Resources(object):
|
|||||||
if item.media_type not in OEB_RASTER_IMAGES:
|
if item.media_type not in OEB_RASTER_IMAGES:
|
||||||
continue
|
continue
|
||||||
if item.media_type.lower() == 'image/webp':
|
if item.media_type.lower() == 'image/webp':
|
||||||
self.log.info(f'Converting WebP image {item.href} to PNG')
|
self.convert_webp(item)
|
||||||
item.convert_webp()
|
|
||||||
try:
|
try:
|
||||||
data = self.process_image(item.data)
|
data = self.process_image(item.data)
|
||||||
except:
|
except:
|
||||||
@ -132,6 +131,14 @@ class Resources(object):
|
|||||||
self.item_map[item.href] = len(self.records)
|
self.item_map[item.href] = len(self.records)
|
||||||
self.has_fonts = True
|
self.has_fonts = True
|
||||||
|
|
||||||
|
def convert_webp(self, item):
|
||||||
|
from calibre.utils.img import image_and_format_from_data, image_to_data
|
||||||
|
img, fmt = image_and_format_from_data(item.data)
|
||||||
|
if fmt == 'webp' and not img.isNull():
|
||||||
|
self.log.info(f'Converting WebP image {item.href} to PNG')
|
||||||
|
item.data = image_to_data(img, fmt='PNG')
|
||||||
|
item.media_type = 'image/png'
|
||||||
|
|
||||||
def add_extra_images(self):
|
def add_extra_images(self):
|
||||||
'''
|
'''
|
||||||
Add any images that were created after the call to add_resources()
|
Add any images that were created after the call to add_resources()
|
||||||
|
@ -1145,13 +1145,6 @@ class Manifest(object):
|
|||||||
href = os.path.normpath(href).replace('\\', '/')
|
href = os.path.normpath(href).replace('\\', '/')
|
||||||
return href
|
return href
|
||||||
|
|
||||||
def convert_webp(self):
|
|
||||||
from calibre.utils.img import image_and_format_from_data, image_to_data
|
|
||||||
img, fmt = image_and_format_from_data(self.data)
|
|
||||||
if fmt == 'webp' and not img.isNull():
|
|
||||||
self.data = image_to_data(img, fmt='PNG')
|
|
||||||
self.media_type = 'image/png'
|
|
||||||
|
|
||||||
def __init__(self, oeb):
|
def __init__(self, oeb):
|
||||||
self.oeb = oeb
|
self.oeb = oeb
|
||||||
self.items = set()
|
self.items = set()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user