Skip to content

feat: add pure-Perl Image::Magick CLI wrapper#494

Merged
fglock merged 8 commits intomasterfrom
feature/image-magick-cli-wrapper
Apr 12, 2026
Merged

feat: add pure-Perl Image::Magick CLI wrapper#494
fglock merged 8 commits intomasterfrom
feature/image-magick-cli-wrapper

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 12, 2026

Summary

Adds a pure-Perl Image::Magick module that wraps the ImageMagick CLI tools (magick for IM7, convert/identify for IM6), providing the Image::Magick API without requiring native PerlMagick XS bindings.

Also fixes a pre-existing Net-SSLeay POD test failure that surfaces when Test::Pod is CPAN-installed.

Key features

  • Deferred execution model: Operations queue as CLI flags and flush only when output is needed (Write, Get, Clone), so a typical read-transform-write pipeline launches exactly one process
  • Broad API coverage: Read, Write, Set, Get, Clone, Composite, Montage, Ping, ImageToBlob, BlobToImage, Annotate, Draw, Compare, Append, Flatten, Coalesce
  • ~60 image manipulation methods via Mogrify dispatch (Blur, Resize, Crop, Rotate, Sharpen, etc.)
  • PerlMagick error constants exported (Success, ErrorException, QuantumDepth, etc.)
  • Auto-detects IM7 (magick) or IM6 (convert) at load time; dies with install instructions if neither is found
  • Unsupported methods (Display, GetPixel, etc.) die with clear messages

Files

File Purpose
src/main/perl/lib/Image/Magick.pm CLI wrapper module (~1240 lines)
src/test/resources/module/Image-Magick/t/basic.t 30 tests (skips if magick not installed)
dev/modules/image_magick.md Design document
src/test/resources/module/Net-SSLeay/t/local/01_pod.t Skip unconditionally (no blib/ for XS module)

Net-SSLeay POD test fix

01_pod.t checks POD in blib/lib/ files, but Net::SSLeay is an XS module that cannot be built in PerlOnJava so blib/ never exists. When Test::Pod is installed via CPAN, the test runs instead of skipping and fails on the missing files. Now skipped unconditionally with a comment explaining why.

Known limitation

When a user has previously installed the CPAN Image::Magick (broken XS version) via jperl -MCPAN -e 'install Image::Magick', the CPAN copy in ~/.perlonjava/lib/ takes precedence over the jar-bundled version due to @INC ordering. Users can fix this by copying our .pm over the installed one, or we can address @INC ordering for bundled overrides in a follow-up.

Test plan

  • 30/30 Image::Magick tests pass on macOS with ImageMagick 7 installed
  • Image::Magick tests skip gracefully when ImageMagick CLI is not available
  • Net-SSLeay 01_pod.t now skips cleanly instead of failing
  • make passes (all unit tests green)
  • CI (ImageMagick not installed, tests should skip)

Generated with Devin

fglock and others added 8 commits April 12, 2026 17:33
Implements Image::Magick API by delegating to ImageMagick CLI tools
(magick for IM7, convert/identify for IM6). This provides the
Image::Magick API without requiring native PerlMagick XS bindings.

Key features:
- Deferred execution model (operations queue as CLI flags, flush on
  Write/Get/Clone) for efficient process usage
- Supports Read, Write, Set, Get, Clone, Composite, Montage, Ping,
  ImageToBlob, BlobToImage, Annotate, Draw, Compare, Append, Flatten
- ~60 image manipulation methods via Mogrify dispatch
- PerlMagick error constants exported
- Auto-detects IM7 (magick) or IM6 (convert) at load time
- Dies with install instructions if neither is found

Test: 30/30 passing on macOS with ImageMagick 7 installed.
Tests skip gracefully when ImageMagick CLI is not available.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Net::SSLeay is an XS module that cannot be built in PerlOnJava, so the
blib/ and helper_script/ directories never exist.  When Test::Pod is
installed via CPAN into ~/.perlonjava/lib/, the test would run instead
of skipping and report "not ok" for every missing file.

Skip unconditionally with a comment explaining why.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Skills are canonical in .agents/; .cognition/ was a stale duplicate.
The .agents/ copies are already up to date and more complete.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Complete list of all 150+ bundled modules organized by category, with
implementation type (Java, Perl, or both) and special instructions for
modules with external requirements (DBI/JDBC drivers, Image::Magick
CLI tools, etc.).

Linked from docs index and using-cpan-modules guide.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Remind developers to update docs/reference/bundled-modules.md when
bundling new modules:
- port-cpan-module SKILL.md: added to Documentation checklist
- module-porting.md: added to Bundled Module Checklist and See Also
- using-cpan-modules.md: added to See Also

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Points to the module porting guide and reminds developers to update
this page when adding new modules.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Updated from 171 to 833 modules tested. Pass rate: 20.5% (171 pass).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fix _flush() clearing pending ops with `[]` (array ref) instead of `()`
(empty list), which left a stray ARRAY ref in the pending queue. This
caused Clone and any subsequent flush to pass "ARRAY(0x...)" as a file
path to the magick command.

Add three new test files:
- mogrify.t: tests for Resize, Crop, Rotate, Flip, Flop, Negate,
  Scale, Thumbnail, Trim, Border operations (21 tests)
- pipeline.t: tests for chained operations, Clone after Write,
  multi-format output, and blob round-trip (16 tests)
- errors.t: tests for error handling — bad file, empty image,
  undefined methods, error constants (10 tests)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 7f674c4 into master Apr 12, 2026
2 checks passed
@fglock fglock deleted the feature/image-magick-cli-wrapper branch April 12, 2026 17:26
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.

1 participant