-
Notifications
You must be signed in to change notification settings - Fork 18
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
add option to prevent aliasing of pngs #80
Comments
Scaling is handled by the pdfjs when it renders the pdf to a canvas. A quick glance over pdfjs options was not enough to figure out if it is possible to disable anti-aliasing. Nevertheless there are a couple of available options that you could try that come to my mind:
|
Apologies for delayed response, specifying Currently experimenting with lowering the threshold for the few other minor things, this might be best asked inside it's own thread but am I correct in assuming that the threshold difference applies to the entire PNG file? Might be out of scope of this nifty tool but I was thinking about whether a cool feature might be adding a new kind of mask that, rather than being a opaque rectangle, specifies an area that allows for a higher threshold tolerance 🤔 |
That sounds doable. We already have the latest image of the PDF and the snapshot. We would need to take portions of those images and compare them using a different threshold. |
Will close this issue since most of the aliasing issues we ran into we could influence from the application code side of things and the DPI setting was the main thing in getting more closely alignedsnapshots. My spidey sense tells me trying to do that while snapshot testing might be too far down the production line to be effective - cheers for the tips! |
One of the annoying challenges with PNG diffs is the fact that the host OS has different built in aliasing of images and text.
Going from PDF to .png mostly solves that for font since the diff is based on an image, but embedded logos on a PDF (I think?) picks up OS aliasing resulting in marginal diffs, will grab a screenshot next time it happens - I have a suspicion this is happening during the
jimp
scaling process.I could be wrong, the aliasing might be happening on the OS side at the moment of the logo being uploaded, in which case this approach might not work.
This issue seems to surface a way of scaling a PNG without anti-aliasing - this is a bit over my head - but if it's possible to add an option for
pdf-visual-diff
to output PNGs that have platform agnostic aliasing (or no aliasing at all) this would save me quite some work, mid term plan is I will eventually run the playwright specs inside a docker container to ensure developers have uniform test runs and results and go from there.TLDR: see if it's possible for
pdf-visual-diff
to output PNGs that bypass or workaround OS aliasing.The text was updated successfully, but these errors were encountered: