-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch thumbnail image resize library #18
Conversation
That is indeed much better :).
That's with a tiny bit of extra logging just to make things obvious ;). diff --git a/kobo-uncaged/main.go b/kobo-uncaged/main.go
index 95cecd4..660cf25 100644
--- a/kobo-uncaged/main.go
+++ b/kobo-uncaged/main.go
@@ -518,6 +518,7 @@ func (ku *KoboUncaged) saveCoverImage(contentID string, size image.Point, imgB64
if !sz.Eq(nsz) {
nimg = image.NewYCbCr(image.Rect(0, 0, nsz.X, nsz.Y), img.(*image.YCbCr).SubsampleRatio)
rez.Convert(nimg, img, ku.KuConfig.Thumbnail.rezFilter)
+ log.Printf(" -- Resized to %s\n", nimg.Bounds().Size())
} else {
nimg = img
log.Println(" -- Skipped resize: already correct size") |
How's the quality? Seemed fine to me, but I'm not picky... |
Yup, it's in the same ballpark as what Calibre would do. |
Cool. It's never going to be great anyway. IIRC calibre sends the thumbnail at 75 JPEG quality to begin with. |
FWIW, the original cover (the one stored in the Library) is encoded @ 95, and the ones sent over USB @ 90. |
Just double checked. The default quality for the wireless server is indeed 75. It's configurable by the user though in the "device options" when KU (or CC) is connected |
Well, I've heard no screams, so unless there are any concern, I'll merge this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general.
My only slight concern is I'm not 100% sure whether Calibre always sends the thumbnail as a JPEG. Current code doesn't deal with PNG at all, although it will error gracefully if a PNG is encountered. Trying to navigate the Calibre source code is an exercise of frustration, i have to admit... |
Try using sourcegraph, as it really helps navigate large codebases. Based on a quick glance, I'm pretty certain Calibre only sends JPEGs. Update: Here's some proof: scale_image, cover_to_thumbnail, THUMBNAIL_WIDTH. Update 2: And here's where it uses PNG thumbnails (content server, generating comic thumbnail, hanvon). |
Yup, pretty sure it'll only ever send JPGs, and that the source (i.e., cover.jpg in the Library's book folder) can only ever be a JPG, too. In fact, even if you feed the metadata editor a PNG cover, it'll re-encode it as a JPG and store that. |
Sounds good to me. Won't worry about it then, Thanks |
This PR changes the image resizing library used from disintegration/imaging to bamiaux/rez, as discussed in #16
The change is primarily around performance. An initial "full thumbnail" test using the bicubic algorithm seems very promising performance wise.
I have also exposed some thumbnail generation configuration to the user in
ku.toml
. See that file for available options. This allows us to test various options and combinations to come up with a sane set of defaults, and to allow easy experimentation.@NiLuJe would you mind testing this please?
@geek1011 would you mind reviewing the code on this please?