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.
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.
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..
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.
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.
This is still a problem for me with Okular 24.12.3.
(In reply to Miren Radia from comment #5) > This is still a problem for me with Okular 24.12.3. Anyone with a okular master who is up for testing a patch ? (It's likely clear what the issue is, I just don't use the stamp feature so I don't know if I broke stuff)
A possibly relevant merge request was started @ https://invent.kde.org/graphics/okular/-/merge_requests/1153
Git commit c76cb7a9e7deced85fb5575e2d992fba83586599 by Sune Vuorela. Committed on 07/06/2025 at 12:09. Pushed by sune into branch 'master'. Improve scaling of stamp for annotation M +17 -7 core/annotations.cpp M +2 -1 core/annotations.h M +1 -1 gui/pagepainter.cpp M +1 -1 part/annotationactionhandler.cpp M +2 -5 part/annotationwidgets.cpp https://invent.kde.org/graphics/okular/-/commit/c76cb7a9e7deced85fb5575e2d992fba83586599
I believe the patch did not solve the problem and created other issues. I'm copy the comment I posted in https://bugs.kde.org/show_bug.cgi?id=315930 The image is very pixelated (both in the single click original size and the drag-to-resize version). Furthermore, the default size became tiny. See the attached screenshot using the png file https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png and the pdf https://upload.wikimedia.org/wikipedia/commons/1/13/Example.pdf
Created attachment 184865 [details] Pixelated stamp in Okular 25.08.0
(In reply to Guilherme Dias da Fonseca from comment #9) > I believe the patch did not solve the problem and created other issues. I'm > copy the comment I posted in > https://bugs.kde.org/show_bug.cgi?id=315930 > > The image is very pixelated (both in the single click original size and the > drag-to-resize version). Furthermore, the default size became tiny. > > See the attached screenshot using the png file > https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png and the pdf > https://upload.wikimedia.org/wikipedia/commons/1/13/Example.pdf I do think that there is room for improvement in the stamp handling code, especially it should be re-rendered from the original data when being resized rather than just being scaled up/down from previous size. Improvements here are not on my near-time todo, so please everyone feel empowered to try take a stab at it. The mentioned MR can be used for inspiration where some of the stuff is happening. The MR in question just loads to expected scale, rather than load, then scales, which should only make a difference for vector graphics files.
Things worked fine for me in okular-25.04.3. Now it's broken in okular-25.08.1. Something was changed I guess?
This garbage patch "fixes" the problem but is obviously incorrect: diff --git a/core/annotations.cpp b/core/annotations.cpp index 21c01b2be..f83249f73 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -212,7 +212,7 @@ QPixmap AnnotationUtils::loadStamp(const QString &nameOrPath, QSize size, Qt::As QSize imageSize = reader.size(); if (!reader.size().isNull()) { - reader.setScaledSize(imageSize.scaled(size, keepAspectRatio)); + reader.setScaledSize(imageSize.scaled(size * 8, keepAspectRatio)); } auto pix = QPixmap::fromImageReader(&reader); if (!pix.isNull()) {
(In reply to Jason A. Donenfeld from comment #12) > Things worked fine for me in okular-25.04.3. Now it's broken in > okular-25.08.1. Something was changed I guess? https://invent.kde.org/graphics/okular/-/commit/c76cb7a9e7deced85fb5575e2d992fba83586599 was changed. The more I study it, the less I see why it should be causing this though.
(In reply to Keyu Tao from comment #4) > 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. This workaround helps in my case, too. Thanks for posting it - the stamp feature is very useful with image overlays and it didn't work for a while now. Okular 25.08 and 25.08.01 still seem to have that bug.