Bug 370382 - Using non-default size for custom stamp pixelates the stamp
Summary: Using non-default size for custom stamp pixelates the stamp
Status: CONFIRMED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2016-10-09 22:16 UTC by Carl-Daniel Hailfinger
Modified: 2024-07-31 17:59 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carl-Daniel Hailfinger 2016-10-09 22:16:02 UTC
Using the "custom stamp from PNG/SVG file" feature in okular 0.26.70 to e.g. add a signature to a PDF will result in the signature being pixelated with varying resolution if the size of the stamp is determined manually with click+drag during creation. This problem affects both PNG and SVG stamps. The pixel size is roughly 1 mm, but it varies.

This is probably caused in the source by importing the custom stamp file as icon instead of using the same way as the other SVG stamps shipped with okular.
Comment 1 Nate Graham 2017-08-17 21:58:26 UTC
Confirmed. But it's only seen at a low zoom setting; zoom in and you'll see that it's still got its full resolution.
Comment 2 Thomas Ramsauer 2022-03-14 09:39:49 UTC
I know this is old.. but for me this bus is still present in version 21.12.2 . It would be very nice to be able to add a high-res signature with the custom stamp feature. 

The stamp/signature is pixelated for me for both options: click or click/hold/drag.

For click only: It shows clear on click, yet pixelates on release.

It does not have its full resolution when zoomed in..
Comment 3 Candid Dauth 2023-10-15 22:10:46 UTC
This is still the case in Okular 23.08.2. It would be really nice if this got fixed!

I have my signature as an SVG file and am trying to an Okular stamp to insert my signature into a document and then use the "Print to PDF" functionality to generate a signed PDF to send. However, the signature is so blurry that it really cannot be used.
Comment 4 Keyu Tao 2024-07-31 17:59:46 UTC
This looks like a bug related to QPixmap scaling and DPI stuffs. In setPopplerStampAnnotationCustomImage() it calls Okular::AnnotationUtils::loadStamp() with a rect size calculated from page size and annotation size. However it looks like this code assumes that 1 pts = 1 pixel on screen (72 DPI?), then in Okular::AnnotationUtils::loadStamp() the stamp is scaled too small, and results in a blurry result. setStampCustomImage() stores the scaled image in PDF, so stamps saved by Okular would also be blurry in other PDF readers.

A very dirty workaround is to enforce it to be at least 288 (=72*4) DPI in setPopplerStampAnnotationCustomImage():

diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp
index 20ad117ea..9d0680919 100644
--- a/generators/poppler/annots.cpp
+++ b/generators/poppler/annots.cpp
@@ -285,7 +285,7 @@ static void setPopplerStampAnnotationCustomImage(const Poppler::Page *page, Popp
     const QSize size = page->pageSize();
     const QRect rect = Okular::AnnotationUtils::annotationGeometry(oStampAnnotation, size.width(), size.height());
 
-    QImage image = Okular::AnnotationUtils::loadStamp(oStampAnnotation->stampIconName(), qMax(rect.width(), rect.height())).toImage();
+    QImage image = Okular::AnnotationUtils::loadStamp(oStampAnnotation->stampIconName(), qMax(rect.width(), rect.height())*4).toImage();
 
     if (!image.isNull()) {
         pStampAnnotation->setStampCustomImage(image);


I don't think it's a nice fix that should be included in upstream, but at least my signature image looks clear with this workaround.