-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Custom book covers #10329
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
Custom book covers #10329
Conversation
frontend/docsettings.lua
Outdated
new.candidates = candidates | ||
new.cover_file = self:getCoverFile(util.splitFilePathName(candidate_path)) |
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.
(In #10311 (comment), I missed not having a reference to the candidate used - so I would not mind if it were added here, something like new.candidate_used = candidate_path
or with a better name, candidate_read
, candidate_source
, new.source_file
...?)
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.
Also, not really fond of having, for each DocSettings read, 7 additional checks/stat() for a file existence for each of the cover extension.
How many DocSettings can be read in our usual operations ? With CoverBrowser, I guess 12 will be read if there are 12 items per page - which would each currently do 3 stat() for the 3 possible DocSettings locations - so now each page would requre 10x12 stat() instead of 3x12.
Dunno how bothering this may be in the grand scheme of things. @NiLuJe ?
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.
It's... certainly not ideal. (Not terrible, but, not ideal).
I'd, at the very least, limit it to png/jpg, very, very eventually svg.
And, ideally, make it entirely opt-in so nobody actually has to suffer though the costs, as it's an extremely niche feature, and we shouldn't suffer for its sake ;).
I'm not really a customer for that feature :), so my comments:
My main (my) usability issue I immediately noticed when seeing the screenshots are the "Cover image: tap to display", that I use quite often, being too near the new (totally useless to me) "Custom cover image:..." and the risk to tap on it (and the more useless items you add to that Book information KVP, the more items-per-page I'll have to increase, the smaller the font size and item will be, the more risk of wrong tap :/). Dunno if there would be a better UI, not bothering Book information display with Book information editing. |
FWIW, I'd KISS and scrap the "set custom cover" UI bits altogether ;). |
frontend/docsettings.lua
Outdated
png = true, | ||
jpg = true, | ||
jpeg = true, | ||
gif = true, | ||
tif = true, | ||
tiff = true, | ||
svg = true, |
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.
If this is to keep it limited, it's probably better to keep it truly limited to png, jpg and svg.
Otherwise, see:
koreader/frontend/document/pdfdocument.lua
Lines 384 to 404 in af45ec7
--- Picture types --- | |
registry:addProvider("gif", "image/gif", self, 90) | |
-- MS HD Photo == JPEG XR | |
registry:addProvider("hdp", "image/vnd.ms-photo", self, 90) | |
registry:addProvider("j2k", "image/jp2", self, 90) | |
registry:addProvider("jp2", "image/jp2", self, 90) | |
registry:addProvider("jpeg", "image/jpeg", self, 90) | |
registry:addProvider("jpg", "image/jpeg", self, 90) | |
-- JPEG XR | |
registry:addProvider("jxr", "image/jxr", self, 90) | |
registry:addProvider("pam", "image/x-portable-arbitrarymap", self, 90) | |
registry:addProvider("pbm", "image/x‑portable‑bitmap", self, 90) | |
registry:addProvider("pgm", "image/x‑portable‑bitmap", self, 90) | |
registry:addProvider("png", "image/png", self, 90) | |
registry:addProvider("pnm", "image/x‑portable‑bitmap", self, 90) | |
registry:addProvider("ppm", "image/x‑portable‑bitmap", self, 90) | |
registry:addProvider("svg", "image/svg+xml", self, 80) | |
registry:addProvider("tif", "image/tiff", self, 90) | |
registry:addProvider("tiff", "image/tiff", self, 90) | |
-- Windows Media Photo == JPEG XR | |
registry:addProvider("wdp", "image/vnd.ms-photo", self, 90) |
(1) UI (2) Too many syscalls. |
Agreed on the screenshot/page thing.
Both as a user and as a maintainer that's a bit dissatisfying. If we take the approach that the extension is ignored it should just be |
I would not mind the deception :) It should at least be the format in which we would save any screenshot, so probable cover.png. Users could then rename any ISBN21321312.jpg to cover.png, if we are able to load it and auto detect/handle it as a JPEG. |
Image viewers that I know (in Windows) shows image files with incorrect extensions well, just showing a warning about the extension. |
For all non-svg files koreader/frontend/ui/widget/imagewidget.lua Line 183 in af45ec7
and then the header is checked koreader/frontend/ui/renderimage.lua Lines 51 to 54 in af45ec7
and finally koreader/frontend/ui/renderimage.lua Line 78 in af45ec7
|
Wouldn't the approach I sketched be much more efficient? Just get the list of files in sidecar, go through the list without doing anything until you hit the first |
lfs.dir() would also give files in some random order, which would be even more non-deterministic and different from one sdr directories to another. |
The order can be whatever you want, my point is you don't need to do lfs.attributes on everything one by one.
I've always thought that'd be better the way I sketched too tbh. ;-) |
Well, yeah. I can't see any reason why anybody would want to anyway? |
Because our icons are nice, and one might want to reuse them to associate a cover to ie. some shell script ? |
Yeah, I'm rather of the opposite opinion, that the icons are the prime candidate for covers in an exclusively on-device situation. ;-) |
No it doesn't koreader/frontend/ui/widget/imagewidget.lua Lines 197 to 201 in 60849ae
|
Then the whole caching aspect of is_icon needs to be rethought in there ;). (Or, better, just a way to pass is_alpha, as that's sorta the only thing that matters here?) |
What I meant to say in my previous answer (had to run, so it was a bit on the short side ;p) is that, currently, ImageWidget's handling of SVG is built exclusively for use with our icons. It does a lot of weird shit that is is very very specific to that use-case, and should absolutely not be used for anything else, ever. So, basically, we'd need a whole new way of handling SVGs in ImageViewer, with sensible alpha behavior, is what I meant ;). (So either do that, or drop the SVG support until that's doable). |
Okay, re-reading ImageWidget, it's slightly less problematic than I initially remembered, still, not a fan of it, and you shouldn't need to.
That would imply something is compositing against a black background somewhere? ImageWidget should get you a BB with an alpha channel if
(The excerpt linked after that is not entirely relevant, as it's there to allow us to actually keep the alpha channel of the icon in the very few cases we need it so as to be able to do alpha-blending at display time; otherwise, we composite over a white background and cache that composition). TL;DR: I'm still not a fan of this, and it at the very least would require a comment to explain that this is because something something we don't support covers with an alpha channel, so we fudge it by compositing against a white background via this flag. That does leave an actual branch that might be problematic in practice, though: koreader/frontend/ui/widget/imagewidget.lua Lines 574 to 584 in 60849ae
|
Another way is to get cover image as usual, i.e. to replace koreader/frontend/apps/filemanager/filemanagerbookinfo.lua Lines 292 to 302 in e38bb05
with if custom_cover then
local cover_doc = DocumentRegistry:openDocument(custom_cover)
if cover_doc then
cover_bb = cover_doc:getCoverPageImage()
cover_doc:close()
return cover_bb
end
end
|
I was surprised not to see it that way in the first place. ^_^ |
I was not keen on using the possibly more expensive openDocument - as it would load crengine when you have to handle a SVG. |
Updates based on the reviews. |
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 okay at a (very) quick glance ;).
Reviewed 4 of 4 files at r20, all commit messages.
Reviewable status: all files reviewed, 36 unresolved discussions (waiting on @hius07 and @poire-z)
So, really not a concern ? |
As long as it's not for "Don't ask again", fine with me :) (#9786 (comment), #9786 (comment)). |
Not yet merged because of the conflicts? - or else? |
Not strictly related, but just witnessed that when looking at this feature: |
From its birth (#8646, default TitleBar size). |
Ok :) really not using that widget often :/ (Although I must have seen it when picking a file in TextEditor.) |
Support for user's custom book covers.
Cover file
cover.ext
is located in the book sdr folder.Can be added/removed manually or via the Book Information page.
No support for downloading covers from the web so not closing #3677.
This change is