PHP code example of takuya / php-imagick-cmd-wrapper

1. Go to this page and download the library: Download takuya/php-imagick-cmd-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

takuya / php-imagick-cmd-wrapper example snippets


$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)    

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

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

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

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

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

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

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

[email protected]:takuya/php-imagick-cmd-wrapper.git
composer config repositories.takuya/php-imagick-cmd-wrapper vcs $repo
composer