[212_6]Fix export as image for jpeg,tif#2955
Open
git-lakshy wants to merge 2 commits intoMoganLab:mainfrom
Open
[212_6]Fix export as image for jpeg,tif#2955git-lakshy wants to merge 2 commits intoMoganLab:mainfrom
git-lakshy wants to merge 2 commits intoMoganLab:mainfrom
Conversation
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.