2

I realize that Imagick has it's own command line executables, but why whenever I try to run an Imagick command written in PHP it breaks my script and exits without warning?

Take something simple:

<?php
$imagepath = realpath('1.gif');
var_dump('111');
$image = new Imagick($imagepath);
var_dump('222');
var_dump($image);

Running php -f imagick.php on my command line interface just simply outputs string(3) "111" and then immediately exits once it hits any Imagick function.

Imagick is properly installed on my machine, and if I do a php -m it shows Imagick as an installed module.

Is there anyway to get it working in command line scripts (aside from using exec())?

I was slightly worried that it wouldn't work on cron jobs, but I just did a quick test and it seems to be working within that (least on VPS).

Am trying from Windows x64 WAMP server PHP v7.1.16.

Note: To clarify, this is just a command line issue. Imagick is installed correctly, no issue with syntax, I've been using it for months in the browser with no issues.

Even command line attempts.. php -d display_errors imagick.php, same, dies upon impact of IM with no notice php -n -l -d display_errors -d display_startup_errors imagick.php brings back 'No Syntax Errors'. It's peculiar, nothing should simply kill the script (although it does try to load for a second before it essentially breaks out of the script no matter where it's at) without any notice.. then again since there's no issue running it in the browser over and over, so I don't think there is any errors (especially sampling my above one liner Imagick initalization).. it's just a CLI thing that I do not understand.

Brian Bruman
  • 883
  • 12
  • 28
  • Possible duplicate of [Install Imagick for PHP and Apache on Windows](https://stackoverflow.com/questions/27193631/install-imagick-for-php-and-apache-on-windows) – r_a_f Feb 16 '19 at 22:28
  • Looks like the error reporting is turned off. Please run `var_dump(error_reporting());` before instantiating the Imagick object. – arueckauer Feb 16 '19 at 22:36
  • I don't think you understood the question @r_a_f. I have it installed just fine, it works as it should within a browser. It took me way too long to figure out that Imagick was killing the script when I was running some scripts within the command line. I have all the error_reporting on that I can possibly think of. It, at least for me, just kills the scripts in its tracks and leaves no trace, no error (in the log files or on screen), when run on the command line. @arueckauer it showed nothing besides the variable dump, which was the `E_ALL` Constant int `32767`. – Brian Bruman Feb 16 '19 at 22:45
  • A couple things: try adding `ini_set('display_errors', true);` at the beginning of your script so we can see the issue when it occurs. Also - are you sure you're referencing the `Imagick` class correctly? Try referencing it as `\Imagick`. – 1000Nettles Feb 17 '19 at 01:33
  • It's been like that (and other possible error reporting avenues). All errors should be reporting.. And tried numerous slight variations, it's not an issue with syntax.. It's either my machine or Imagick itself or maybe both. Curious if this is just an issue on my end, or more widespread.. – Brian Bruman Feb 17 '19 at 01:51

1 Answers1

0

This was a local issue, apparently.

I recently reinstalled Windows and subsequently reinstalled Imagick and PHP.

Anyone else having similar issues I recommend reinstalling Imagick (it's a big pain to install -- recommend using these references for installing on a Windows 10 machine:

Also I've yet to try this personally, but by the looks of it, seems a better method for imagick integration with PHP: ImageMagickPHP (Imagick PHP Class that utilizes command line exec as opposed to the PHP version).

Brian Bruman
  • 883
  • 12
  • 28