PHPackages                             takuya/php-imagick-cmd-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. takuya/php-imagick-cmd-wrapper

ActiveLibrary[CLI &amp; Console](/categories/cli)

takuya/php-imagick-cmd-wrapper
==============================

image magick command line call from php

1.0.1(1y ago)258GPL-3.0-or-laterPHPPHP &gt;=8.0CI failing

Since Aug 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/takuya/php-imagick-cmd-wrapper)[ Packagist](https://packagist.org/packages/takuya/php-imagick-cmd-wrapper)[ RSS](/packages/takuya-php-imagick-cmd-wrapper/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

php-imagick-cmd-wrapper
=======================

[](#php-imagick-cmd-wrapper)

[![](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)

Image magick shell command wrapper for php

requirements
------------

[](#requirements)

```
apt install imagemagick

```

Why using magick shell command from php?
----------------------------------------

[](#why-using-magick-shell-command-from-php)

#### Occasionally, a php-imagick (ext-imagick) is not available.

[](#occasionally-a-php-imagick-ext-imagick-is-not-available)

Some mod-php server are not supporting ext-imagck. but convert command is easy to install.

#### Imagick class ( in ext-imagick) is not documented in precisely.

[](#imagick-class--in-ext-imagick-is-not-documented-in-precisely)

Think, Can you tell how to use 'png:compression-filter' in ext-imagick ?. Perhaps you can't. But, there are very many 'convert' samples in web. and we are trying to `system('convert a.jpg b.png')` calling with escaping shell arguments. What's a irritated.

So, we need `convert` command wrapper.

Installing from GitHub
----------------------

[](#installing-from-github)

```
repo=git@github.com:takuya/php-imagick-cmd-wrapper.git
composer config repositories.takuya/php-imagick-cmd-wrapper vcs $repo
composer require takuya/php-imagick-cmd-wrapper

```

Usage Sample
------------

[](#usage-sample)

```
$f_in = 'DkzpJ1lUUAA84KP.jpg';
$width = 500;
// convert
$convert = new Convert();
$ret = $convert
      ->setInputFile( $f_in )
      ->unsharp('10x5+0.7+0')
      ->sample($width)
      ->pointsize(30)
      ->fill('blue')
      ->strokewidth(1)
      ->stroke('gray80')
      ->font('DejaVu-Sans')
      ->annotate('+10+100','unsharp_sample')
      ->setOutputFile( 'jpeg:-' )
      ->execute();
$image_bin = $ret[1];
file_put_contents('out.jpg',$image_bin)
```

Important Notice! Call Method Ordering.
---------------------------------------

[](#important-notice-call-method-ordering)

Before Use, You should know that OPTIONS Ordering is VERY IMPORTANT.

The `convert` command is Very NAIVE for option order.

We must care about Arguments Ordering.

#### Sample1 ( vain , not working. )

[](#sample1--vain--not-working-)

```
(new Identify())
    ->setInputFile('a.jpg')
    ->format('[%w,%h]')
->execute();
```

This result in ` identify a.jpg -format '[%w,%h]'` , but no work.

#### Sample2 ( works fine. )

[](#sample2--works-fine-)

```
(new Identify())
    ->setInputFile('a.jpg')
    ->format('[%w,%h]')
->execute();
```

This result in `identify  -format '[%w,%h]' a.jpg` , it will work fine.

### More Sample Usage

[](#more-sample-usage)

#### Convert JPEG to PNG.

[](#convert-jpeg-to-png)

```
$convert = ;
(new Convert())
      ->setInputile( 'a.jpg' )
      ->setOutputFile( 'b.png' )
      ->execute();
```

#### Using STDOUT - converting jpeg to png

[](#using-stdout---converting-jpeg-to-png)

```
$convert = ;
$result = (new Convert())
      ->setInputile( 'a.jpg' )
      ->setOutputFile( 'png:-' )
      ->execute();
$png_binary = $result[1];
```

#### Using STDIN - converting jpeg to png

[](#using-stdin---converting-jpeg-to-png)

```
$convert = ;
$result = (new Convert())
      ->setInputile( '-', file_get_contents('a.jpg') )
      ->setOutputFile( 'png:-' )
      ->execute();
$png_binary = $result[1];
```

#### Structure of return value

[](#structure-of-return-value)

command result is array of 3 entries

```
$result = [
  '0' => ' int / exit status code' ,
  '1' => ' string / stdout from command' ,
  '2' => ' string / stderr from command' ,
];
```

### Resize(sampling Algorithm) and UnSharp and Normalization

[](#resizesampling-algorithm-and-unsharp-and-normalization)

```
$ret = $convert
      ->setInputFile( $f_in )
      ->sample('50%')
      ->unsharp('10x5+0.7+0')
      ->normalize()
      ->setOutputFile( 'jpeg:-' )
      ->execute();
```

### IDE Auto Completion.

[](#ide-auto-completion)

Options(methods) are auto generated from Help doc from 'convert -h'.

So, in Some IDE, Auto completions will not work fine.

If it happens then add a path `src/generated/` to your Project search PATH.

Developing notice.
------------------

[](#developing-notice)

This project uses auto generated php code, parsing `converet -h`.

If you want to re-generate class, execute these command in CLI.

```
composer run generate-class convert
composer run generate-class montage
composer run generate-class identify
composer run generate-class mogrify

```

I used these environment. wsl1 debian.

```
wsl --list -v
  NAME      STATE           VERSION
* Debian    Running         1

```

```
cat /etc/debian_version
10.10

```

imagemagick from debian(wsl)

```
convert -version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

```

test results.
-------------

[](#test-results)

[![](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)](https://github.com/takuya/php-imagick-cmd-wrapper//workflows/main/badge.svg)

testing
-------

[](#testing)

```
composer install
./vendor/bin/phpunit

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance42

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1200 days

Total

2

Last Release

532d ago

PHP version history (2 changes)1.0PHP &gt;=7.2

1.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab28766f469b5f1770a63613c5f51d661226e01bd2abd180ad5460e537e7d4fa?d=identicon)[takuya](/maintainers/takuya)

---

Top Contributors

[![takuya](https://avatars.githubusercontent.com/u/55338?v=4)](https://github.com/takuya "takuya (69 commits)")

---

Tags

convertimagickshellimage-magick

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/takuya-php-imagick-cmd-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/takuya-php-imagick-cmd-wrapper/health.svg)](https://phpackages.com/packages/takuya-php-imagick-cmd-wrapper)
```

###  Alternatives

[psy/psysh

An interactive shell for modern PHP.

9.8k545.6M719](/packages/psy-psysh)[mikehaertl/php-shellcommand

An object oriented interface to shell commands

32437.5M61](/packages/mikehaertl-php-shellcommand)[kevinlebrun/colors.php

Colors for PHP CLI scripts

3426.7M45](/packages/kevinlebrun-colorsphp)[mrrio/shellwrap

Use any command-line tool as a PHP function.

738198.8k2](/packages/mrrio-shellwrap)[marcocesarato/amwscan

AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.

75317.8k1](/packages/marcocesarato-amwscan)[alecrabbit/php-console-spinner

Extremely flexible spinner for \[async\] php cli applications

24032.0k2](/packages/alecrabbit-php-console-spinner)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
