mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Comic conversion: Fix conversion of comic images that are stored as 8-bit grayscale images in JPEG format not working when converting to PDF. Fixes #1956932 [pdf convertion of 8 bit jpg](https://bugs.launchpad.net/calibre/+bug/1956932)
This commit is contained in:
parent
5d15c9ded4
commit
0cf7af69ac
@ -98,20 +98,15 @@ class Image: # {{{
|
|||||||
path_or_bytes = f.read()
|
path_or_bytes = f.read()
|
||||||
self.img_data = path_or_bytes
|
self.img_data = path_or_bytes
|
||||||
fmt, width, height = identify(path_or_bytes)
|
fmt, width, height = identify(path_or_bytes)
|
||||||
if width > 0 and height > 0 and fmt == 'jpeg':
|
self.img, self.fmt = image_and_format_from_data(path_or_bytes)
|
||||||
self.fmt = fmt
|
self.width, self.height = self.img.width(), self.img.height()
|
||||||
self.width, self.height = width, height
|
self.cache_key = self.img.cacheKey()
|
||||||
self.cache_key = None
|
|
||||||
else:
|
|
||||||
self.img, self.fmt = image_and_format_from_data(path_or_bytes)
|
|
||||||
self.width, self.height = self.img.width(), self.img.height()
|
|
||||||
self.cache_key = self.img.cacheKey()
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def draw_image_page(writer, img, preserve_aspect_ratio=True):
|
def draw_image_page(writer, img, preserve_aspect_ratio=True):
|
||||||
if img.fmt == 'jpeg':
|
if img.fmt == 'jpeg':
|
||||||
ref = writer.add_jpeg_image(img.img_data, img.width, img.height, img.cache_key)
|
ref = writer.add_jpeg_image(img.img_data, img.width, img.height, img.cache_key, depth=img.img.depth())
|
||||||
else:
|
else:
|
||||||
ref = writer.add_image(img.img, img.cache_key)
|
ref = writer.add_image(img.img, img.cache_key)
|
||||||
page_size = tuple(writer.page_size)
|
page_size = tuple(writer.page_size)
|
||||||
|
@ -416,8 +416,8 @@ class PDFStream:
|
|||||||
self.objects.commit(r, self.stream)
|
self.objects.commit(r, self.stream)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def add_jpeg_image(self, img_data, w, h, cache_key=None):
|
def add_jpeg_image(self, img_data, w, h, cache_key=None, depth=32):
|
||||||
return self.write_image(img_data, w, h, 32, dct=True)
|
return self.write_image(img_data, w, h, depth, dct=True)
|
||||||
|
|
||||||
def add_image(self, img, cache_key):
|
def add_image(self, img, cache_key):
|
||||||
ref = self.get_image(cache_key)
|
ref = self.get_image(cache_key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user