Bug 391625 - Okular displays blurry images when opening epub files
Summary: Okular displays blurry images when opening epub files
Status: CONFIRMED
Alias: None
Product: okular
Classification: Applications
Component: EPub backend (show other bugs)
Version: 22.04.3
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-09 17:10 UTC by humanix
Modified: 2023-07-04 00:24 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Okular blurry images (336.83 KB, image/png)
2018-03-09 17:10 UTC, humanix
Details
Same image opened im Mcomix (1.17 MB, image/png)
2018-03-09 17:12 UTC, humanix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description humanix 2018-03-09 17:10:49 UTC
Created attachment 111286 [details]
Okular blurry images

When opening epub files, without exception, the images appear blurry even if displayed at 100%. However, if I open the file with a image viewer such as mcomix or convert it to pdf with ebook-convert, the image displays normally without distortion.
Comment 1 humanix 2018-03-09 17:12:12 UTC
Created attachment 111287 [details]
Same image opened im Mcomix
Comment 2 Nate Graham 2018-03-09 18:29:17 UTC
The file that reproduces the issue is available at https://nofile.io/f/wx5M48ugyO9/10.1007_978-1-4302-6653-2.epub. I can't attach it here because it's slightly too large for the 4MB file size limit.
Comment 3 Albert Astals Cid 2018-07-28 21:14:43 UTC
Git commit 57be655c15e2a9349e0f1dd5c9d083675c85a7f4 by Albert Astals Cid, on behalf of Gilbert Assaf.
Committed on 28/07/2018 at 21:13.
Pushed by aacid into branch 'Applications/18.08'.

Improve picture scaling issues in epub generator

Test Plan: I tested the file mentioned in the bug report. Pictures look less blurry

Reviewers: #okular

Subscribers: ngraham, aacid, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D13766

M  +2    -2    generators/epub/epubdocument.cpp

https://commits.kde.org/okular/57be655c15e2a9349e0f1dd5c9d083675c85a7f4
Comment 4 Christoph Feck 2018-08-17 21:30:54 UTC
Any work left for this ticket?
Comment 5 Nate Graham 2018-08-17 23:04:17 UTC
Yes, the path patch improved things, but it's not 100% solved yet.
Comment 6 Heinz Wiesinger 2018-11-03 15:54:42 UTC
I looked into this today and I think I found the root cause of the issue. I don't know how to fix it though :/

The problem seems to be

setPageSize(QSizeF(600, 800));

This has the effect that images loaded later will be scaled to fit that size. If they are smaller, they will be scaled up, if they are larger they will be scaled down. When you view a document at 100%, you're thus not viewing the image in its original size, but 100% of its scaled version.

I verified this by setting the page size to what is defined in the epub itself and disabling the scaling altogether. Images were showing fine then.

The problem is that there is no standard for defining the page size for an epub.
In fact, the epub mentioned earlier doesn't even mention a page size.

I have a Manga epub which defines the page size like this:

<meta content="width=900, height=1350" name="viewport"/>

(which at least seems to be some standard among art books)

and the title page of a novel which looks like this:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 592 871">
<image width="592" height="871" xlink:href="9783838717227_front.jpg"/>
</svg>

On top of this, different pages in the same document can have different sizes.

Not really sure how to go about this :/
Comment 7 lordjaba 2019-04-28 12:07:05 UTC
Same on Kubuntu 18.10
Comment 8 Mads 2022-07-25 15:52:36 UTC
This is still an issue with Okular 22.04. Seems like an easy solution would be to just double the setPageSize to 1200, 1600. Seems to work fine here, tested on a HiDPI screen.
Comment 9 Mads 2022-07-25 15:56:43 UTC
When I checked now with an epub of a comic I just got from Kobo, and there the png was 1400x2000. So I don't think we should just double it, we should triple the size to 1800, 2400 to be sure. Or make it configurable, of course.
Comment 10 Mads 2022-07-25 16:41:59 UTC
This doesn't have an easy fix, unfortunately, because more often than not a page is css data, not a raw png, even if it's a comic. So I haven't found a simple method for scaling the page when it needs to expand to fill the frame in okular - I guess it needs some kind of viewport/zoom functionality on a page itself. You can't do it in image scaling alone, at least I couldn't get it to work.
Comment 11 almborg33 2022-09-10 13:22:15 UTC
I think it is the same bug.
My images gets zoomed in so much that they are not shown whole and are very pixelated.
This really hampers Okular to be used as an epub reader.
E.g. If I have a table that I can only read half of.
Here is an image of the problem https://imgur.com/a/eTxXqyE

Until the bug is fixed is there a workaround to see the whole image?
Comment 12 lfsj_egrfq79 2023-07-04 00:24:31 UTC
yes I believe this is a good solution for now. we should add the ability to, for example double click on an image in an epub, to view it in its full original resolution. in a popup for example.