[212_6]Fix export as image for jpeg,tif#2955
[212_6]Fix export as image for jpeg,tif#2955git-lakshy wants to merge 3 commits intoMoganLab:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes “Export selection as image” for JPEG and TIFF when built with the MuPDF renderer by avoiding MuPDF’s PNG-only save_picture path and ensuring the PDF→raster converter pipeline (pdftocairo / ImageMagick) is correctly wired for TIFF.
Changes:
- Gate
print_snippet’s bitmap (direct raster) export path to PNG only whenUSE_MUPDF_RENDERERis enabled; route JPEG/TIFF through the PDF→converter pipeline instead. - Fix
pdftocairoraster conversion flag selection by deriving the format from the destination suffix and mappingtif→tifffor the CLI. - Register a
pdf-file → tif-fileconverter via pdftocairo and add missing imports forget-raster-resolution.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/Edit/Editor/edit_main.cpp |
Avoids MuPDF PNG-only raster saving for JPEG/TIFF by routing those exports through the converter pipeline. |
TeXmacs/plugins/binary/progs/binary/pdftocairo.scm |
Uses format-from-suffix + tif→tiff mapping for correct pdftocairo flags; imports image-format for resolution. |
TeXmacs/plugins/binary/progs/binary/convert.scm |
Imports image-format so get-raster-resolution is available for ImageMagick conversion. |
TeXmacs/plugins/image/progs/image/pdf.scm |
Adds a pdftocairo-based pdf-file → tif-file converter to support TIFF without ImageMagick. |
devel/212_6.md |
Developer documentation / test instructions for the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Then please mention this issue in the How to Test section of |
Document known issue with PNG exports trimming content.
|
@wumoin I updated the How to test section, any other changes required ? |
|
I took another look and noticed that exporting as jpeg and tiff fails; it automatically changes them to jpg and tif. |




212_6: Fix export selection as image for jpeg, tiff
How to Test
.jpg→ verify file is created and contains the selection.tifand.tiff.pngand.pdfworks as expected(Tested on debian works)
Issue #2728
JPEG and TIFF formats could not be exported via "Export Selected Area as Image".PNG and PDF export worked.
What
1.
src/Edit/Editor/edit_main.cppThe root cause.
print_snippetrouted jpeg/tiff throughmake_raster_image, but mupdf'ssave_pictureonly supports PNG (hardcodedfz_write_pixmap_as_png). The fix gates the bitmap path by renderer:With mupdf, jpeg/tiff now go through the PDF→Scheme converter pipeline instead.
2.
TeXmacs/plugins/binary/progs/binary/pdftocairo.scmurl-formatreturned format names (via C++ glue) that didn't match pdftocairo CLI flags. Replaced withformat-from-suffix(proper Scheme API) plus atif→tifffix because pdftocairo accepts-tiffbut not-tif:Also added
(convert images image-format)import forget-raster-resolution.3.
TeXmacs/plugins/binary/progs/binary/convert.scmAdded missing
(convert images image-format)import. Without it,get-raster-resolutionwas unbound when ImageMagick converter was invoked, causing a crash.4.
TeXmacs/plugins/image/progs/image/pdf.scmRegistered
pdf-file → tif-fileconverter via pdftocairo. Previously only ImageMagick had a TIFF converter, so systems without ImageMagick could not export TIFF.Why
mupdf's
save_pictureonly supports PNG output. The old code unconditionally treated jpeg/tiff as bitmap formats, sending them through a rendering path that silently failed. The converter pipeline (pdftocairo/ImageMagick) also had bugs: missing imports, missing converter registrations, and incorrect CLI flag generation.