Directly use the ImageMagick "convert" binary instead of PECL extensions

Created on 24 March 2025, about 1 month ago

Problem/Motivation

This module currently requires the ImageMagick PECL extension. This extension was abandoned for a period of time and for years did not have a compatible PHP 8.3 or 8.4 release.

Also, key hosting companies like Acquia and Pantheon only provide the ImageMagick binary and do not load the PECL extension. The main ImageMagick Drupal module β†’ also does not use the PECL extension, and just calls the convert binary directly.

Steps to reproduce

Attempt to use this module on PHP 8.3 or 8.4. Installing via pecl install imagick will fail (until a new stable release is created).

Proposed resolution

Although it looks like the PECL extension situation is almost sorted out and a PHP 8.3 and 8.4 release is likely to be available soon, it may be advisable to adopt the same approach used by other modules and leverage calling the ImageMagick binary directly, rather than using the PECL extension. It may also have some benefits of saving memory within the PHP processes, since the memory would be externalized to the executable.

Using the binary will probably make this module more widely accessible, considering the state of availability on Drupal-specific hosting companies and the state of PHP 8.3 and 8.4 support.

Remaining tasks

Refactor to use the binary convert instead of in-PHP objects.

User interface changes

None

API changes

Documentation and requirements will need to be updated. This should probably be a new branch (i.e. 3.x), although any site that has the PECL extension probably will also have access to the binary, server configurations may vary.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States quicksketch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @quicksketch
  • First commit to issue fork.
  • Pipeline finished with Success
    22 days ago
    Total: 144s
    #467681
  • Added support for the graphicsmagick and imagemagick binaries. graphicsmagick is a newer and slightly faster fork, so it's checked for first, before falling back to imagemagick, and then the PHP extension.

    The generated JPG files are slightly smaller but of similar quality.

    Patch available here.

  • Pipeline finished with Success
    22 days ago
    Total: 459s
    #467712
  • Pipeline finished with Success
    12 days ago
    Total: 525s
    #475748
  • Pipeline finished with Success
    4 days ago
    Total: 137s
    #481979
  • Pipeline finished with Success
    4 days ago
    Total: 137s
    #482002
Production build 0.71.5 2024