Skip to content

Add ICC profiles to images in PDF and update usvg, svg2pdf - #822

Merged
laurmaedje merged 4 commits into
mainfrom
image-icc
May 2, 2023
Merged

laurmaedje merged 4 commits into
mainfrom
image-icc

Conversation

@reknih

@reknih reknih commented Apr 15, 2023 •

Copy link
Copy Markdown
Member

This branch updates image to version 0.24.6 which supports ICC profile extraction for JPEG, PNG, and AVIF.
Consequently, the ICC profile of JPEG and PNG files is now embedded into the PDF file. It is not read or processed in-between. GIF files with ICC profiles exist, but are not in common use, for now I continue to assume Device color spaces for all GIFs and other files without a color profile.

Raster image generation will continue to ignore the ICC profile in images.

This PR also contains updates for svg2pdf and the version bumps for usvg, resvg, ttf-parser, tiny-skia, and rustybuzz.

Why is this still a draft?

  • pdf-writer contains the necessary features on main, but the current release does not. Release pdf-writer 0.7.0.
  • The version of pdf-writer in Typst needs to be in sync with the version in svg2pdf. Update svg2pdf. This is also why CI is failing.
  • The ICC profile needs to be extracted from the image decoder struct, all of which share a common trait. I currently avoided an allocation by writing the code for each of them separately in the match in src/image.rs. This is ugly. Decide if we want to eat the run time cost of a Box so I can deduplicate this code.

Fixes #1027
Fixes #368

@reknih reknih added pdf Related to PDF export or PDF embedding. visualize Related to the visualize category, which is about drawing and illustrating labels Apr 15, 2023
@reknih
reknih marked this pull request as draft April 15, 2023 17:57
@reknih reknih changed the title WIP: Add ICC profiles to images WIP: Add ICC profiles to images in PDF Apr 15, 2023
@reknih
reknih force-pushed the main branch 4 times, most recently from 102fa05 to b79121d Compare April 23, 2023 17:35
@reknih reknih changed the title WIP: Add ICC profiles to images in PDF WIP: Add ICC profiles to images in PDF and update usvg, svg2pdf May 2, 2023
@reknih reknih changed the title WIP: Add ICC profiles to images in PDF and update usvg, svg2pdf Add ICC profiles to images in PDF and update usvg, svg2pdf May 2, 2023
@reknih
reknih marked this pull request as ready for review May 2, 2023 10:38
@reknih
reknih requested a review from laurmaedje May 2, 2023 10:44
@laurmaedje
laurmaedje merged commit 17cef8d into main May 2, 2023
@laurmaedje
laurmaedje deleted the image-icc branch May 2, 2023 11:53
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pdf Related to PDF export or PDF embedding. visualize Related to the visualize category, which is about drawing and illustrating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG text style dominant-baseline is ignored. SVG images are translated lossy

2 participants