Skip to content
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

[Editor] Support svg images in the stamp annotation #16650

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

calixteman
Copy link
Contributor

createImageBitmap doesn't work with svg files (see bug 1841972), so we need to workaround this in using an Image.
When printing/saving we must rasterize the image, hence we get the biggest bitmap as image reference to avoid duplications or poor quality on rendering.

src/display/editor/stamp.js Outdated Show resolved Hide resolved
src/display/editor/tools.js Show resolved Hide resolved
src/display/editor/tools.js Outdated Show resolved Hide resolved
src/display/editor/tools.js Outdated Show resolved Hide resolved
@calixteman calixteman force-pushed the editor_allow_svg branch 2 times, most recently from eaf9ea2 to 91e17c9 Compare July 6, 2023 14:43
@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Jul 6, 2023

Can you please add reference tests for this, e.g. copying these existing ones and using svg-files for the images, since these changes aren't really covered by existing tests?

@calixteman
Copy link
Contributor Author

Can you please add reference tests for this, e.g. copying these existing ones and using svg-files for the images, since these changes aren't really covered by existing tests?

The problem is that we always pass a bitmap to the worker and these tests only test saving/printing.
The only way to test that stuff would be to have an integration test which will add a svg, then we should make a screenshot and finally compare it to a reference.... It'd be really nice to have.

@calixteman
Copy link
Contributor Author

Something else we could try is to make an integration test and at some save the pdf but in using directly the api to get the saved stream, then parse the result and finally check that everything is ok: it'd be a mix of integration test and unit test. Wdyt ?

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Jul 7, 2023

Something else we could try is to make an integration test and at some save the pdf but in using directly the api to get the saved stream, then parse the result and finally check that everything is ok: it'd be a mix of integration test and unit test. Wdyt ?

If that works without too much trouble, then it sounds like a good idea!

@calixteman
Copy link
Contributor Author

It's easy to get the bytes buffer from a saved pdf but it's more complex to parse it.
So I just tested that editors and the serialized images have the correct dimensions (which means that the image behind is the correct one).

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with the comment addressed; thank you!

test/integration/stamp_editor_spec.js Outdated Show resolved Hide resolved
createImageBitmap doesn't work with svg files (see bug 1841972), so we need to workaround
this in using an Image.
When printing/saving we must rasterize the image, hence we get the biggest bitmap as image
reference to avoid duplications or poor quality on rendering.
@calixteman
Copy link
Contributor Author

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/28257170328eab0/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/c931795028f38e4/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/c931795028f38e4/output.txt

Total script time: 3.96 mins

  • Integration Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/28257170328eab0/output.txt

Total script time: 26.42 mins

  • Integration Tests: FAILED

@calixteman calixteman merged commit c33e6ce into mozilla:master Jul 7, 2023
3 checks passed
@calixteman calixteman deleted the editor_allow_svg branch July 7, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants