Skip to content

cmd/mfp-test: add raster conversion and wire image evaluation - #104

Merged
alexpevzner merged 11 commits into
OpenPrinting:masterfrom
ArmxG:master
Sep 20, 2026
Merged

alexpevzner merged 11 commits into
OpenPrinting:masterfrom
ArmxG:master

Conversation

@ArmxG

@ArmxG ArmxG commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

This PR Adds convertToPNG() in raster.go to convert captured print documents to PNG for image evaluation:

  • PWG Raster / Apple URF: vendored cupsraster package (derived from github.com/rusq/thermoprint/cupsraster, MIT) — no external dependency
  • PDF, JPEG, TIFF, WEBP, GIF: github.com/h2non/bimg (libvips)
  • PostScript: direct gs (Ghostscript) subprocess — no ImageMagick dependency, no policy.xml changes needed

Embeds enhanced_comparison.py into the binary via //go:embed — --comparator flag is now optional (embedded script used by default).

Wires evaluation into runner.go: captured bytes → PNG → eval.Compare.

New flags: --comparator, --quick, --timeout, --keep, --list-quick.

go.mod stays at go 1.21 (no imagick or thermoprint dependency).

go build and go vet: clean

ArmxG and others added 11 commits September 6, 2026 05:48
  Add notes about Ubuntu ImageMagick policy blocking PostScript coders
  and unsupported formats (image/vnd.cups-raster, image/jpeg+gzip) not
  yet handled for image evaluation.

  Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  Claude-Session: https://claude.ai/code/session_01SgcYjdrNyPsMQLUGQvZpaa
…ster

  - Replace ImageMagick PostScript conversion with a direct Ghostscript
    call, removing the imagick dependency and Ubuntu policy.xml requirement
  - Vendor cupsraster from github.com/rusq/thermoprint (MIT) into
    cmd/mfp-test/cupsraster/, removing the thermoprint dependency
  - Add CREDITS.txt crediting the cupsraster author and license
  - Downgrade golang.org/x packages to origin/master versions, restoring
    go.mod to go 1.21

  Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  Claude-Session: https://claude.ai/code/session_01SgcYjdrNyPsMQLUGQvZpaa
Add //go:embed for imgeval/enhanced_comparison.py so that image
evaluation works out of the box without requiring the user to supply
--comparator. NewDefaultEvaluator writes the embedded script to a
temp file and sets ownedComparator so Close() cleans it up.
--comparator still overrides with an external file when provided.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgcYjdrNyPsMQLUGQvZpaa
@alexpevzner
alexpevzner merged commit 4a416f9 into OpenPrinting:master Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants