mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Experiment w/ optipng...
This commit is contained in:
parent
b5554bd0da
commit
d6efb350bf
@ -1023,7 +1023,7 @@ class KOBO(USBMS):
|
|||||||
debug_print('FAILED to upload cover', filepath)
|
debug_print('FAILED to upload cover', filepath)
|
||||||
|
|
||||||
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, ditheredcovers, letterboxcovers, pngcovers):
|
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, ditheredcovers, letterboxcovers, pngcovers):
|
||||||
from calibre.utils.img import save_cover_data_to
|
from calibre.utils.img import save_cover_data_to, optimize_png
|
||||||
if metadata.cover:
|
if metadata.cover:
|
||||||
cover = self.normalize_path(metadata.cover.replace('/', os.sep))
|
cover = self.normalize_path(metadata.cover.replace('/', os.sep))
|
||||||
|
|
||||||
@ -1077,6 +1077,9 @@ class KOBO(USBMS):
|
|||||||
f.write(data)
|
f.write(data)
|
||||||
fsync(f)
|
fsync(f)
|
||||||
|
|
||||||
|
if pngcovers:
|
||||||
|
optimize_png(fpath)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
debug_print("ImageID could not be retreived from the database")
|
debug_print("ImageID could not be retreived from the database")
|
||||||
|
|
||||||
@ -2697,6 +2700,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
|
|
||||||
def _upload_cover(self, path, filename, metadata, filepath, upload_grayscale, dithered_covers=False, keep_cover_aspect=False, letterbox_fs_covers=False, png_covers=False):
|
def _upload_cover(self, path, filename, metadata, filepath, upload_grayscale, dithered_covers=False, keep_cover_aspect=False, letterbox_fs_covers=False, png_covers=False):
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
|
from calibre.utils.img import optimize_png
|
||||||
debug_print("KoboTouch:_upload_cover - filename='%s' upload_grayscale='%s' dithered_covers='%s' "%(filename, upload_grayscale, dithered_covers))
|
debug_print("KoboTouch:_upload_cover - filename='%s' upload_grayscale='%s' dithered_covers='%s' "%(filename, upload_grayscale, dithered_covers))
|
||||||
|
|
||||||
if not metadata.cover:
|
if not metadata.cover:
|
||||||
@ -2780,6 +2784,9 @@ class KOBOTOUCH(KOBO):
|
|||||||
with lopen(fpath, 'wb') as f:
|
with lopen(fpath, 'wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
fsync(f)
|
fsync(f)
|
||||||
|
|
||||||
|
if png_covers:
|
||||||
|
optimize_png(fpath)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err = unicode_type(e)
|
err = unicode_type(e)
|
||||||
debug_print("KoboTouch:_upload_cover - Exception string: %s"%err)
|
debug_print("KoboTouch:_upload_cover - Exception string: %s"%err)
|
||||||
|
@ -79,6 +79,7 @@ QImage ordered_dither(const QImage &image) { // {{{
|
|||||||
QImage img = image;
|
QImage img = image;
|
||||||
int y = 0, x = 0, width = img.width(), height = img.height();
|
int y = 0, x = 0, width = img.width(), height = img.height();
|
||||||
uint8_t gray = 0, dithered = 0;
|
uint8_t gray = 0, dithered = 0;
|
||||||
|
// NOTE: We went with Grayscale8 because QImageWriter was doing some weird things with an Indexed8 input...
|
||||||
QImage dst(width, height, QImage::Format_Grayscale8);
|
QImage dst(width, height, QImage::Format_Grayscale8);
|
||||||
|
|
||||||
// We're running behind blend_image, so, we should only ever be fed RGB32 as input...
|
// We're running behind blend_image, so, we should only ever be fed RGB32 as input...
|
||||||
|
@ -233,7 +233,7 @@ def save_cover_data_to(data, path=None, bgcolor='#ffffff', resize_to=None, compr
|
|||||||
img = grayscale_image(img)
|
img = grayscale_image(img)
|
||||||
if eink:
|
if eink:
|
||||||
# NOTE: Keep in mind that JPG does NOT actually support indexed colors, so the JPG algorithm will then smush everything back into a 256c mess...
|
# NOTE: Keep in mind that JPG does NOT actually support indexed colors, so the JPG algorithm will then smush everything back into a 256c mess...
|
||||||
# Thankfully, Nickel handles PNG just fine, and we generate smaller files to boot, because they're properly color indexed ;).
|
# Thankfully, Nickel handles PNG just fine, and we potentially generate smaller files to boot, because they can be properly color indexed ;).
|
||||||
img = eink_dither_image(img)
|
img = eink_dither_image(img)
|
||||||
changed = True
|
changed = True
|
||||||
if path is None:
|
if path is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user