Re: Re: new IM driver for Image_Transform

From: Date: Sun, 26 May 2002 14:55:51 +0000
Subject: Re: Re: new IM driver for Image_Transform
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6435@lists.php.net to get a copy of this message
Peter Bowyer wrote: > > > > What is the advantage of this rather than using a defined constant? AFAIK > > > which() won't work on Windows? (using CMD::which() for path to > > > identify and convert) > >Well, it should...the advantage is for autodetecting (good) instead > >of using a constant (bad). It is common in PEAR to try to > >autodetect the environment...and frees the user from having to know > >that imagemagick is being used from the commandline... > > Well, in its current state the function *will not* work on windows: > a) It expects $HTTP_ENV_VARS['PATH'] to have ":" between the paths, and > Windows uses ";" > b) $location = $path . "/" . $cmd; has the / when all the other slashes in > the Window's path will be \. > c) On Windows it isn't customary to always put files in the environment > path, unlike Unix. Take a look at the System.php method System::type() > > I couldn't find a way of capturing the error message... is this what exec > will do? I thought it was just a status value, not an error message that > was returned. $output = cmd 2>&1; or exec('cmd 2>&1', $output, $return_var) if ($return_var != 0) { return PEAR::raiseError(implode("\n", $ouput)); } > > Imagine a production environment where > >the end user is seeing something like > > > >'convert' [Unknown arguments] > > Imagine anyone putting some code into production without testing it. > > >Very bad...we should try to capture every last bit of error output > >and handle it appropriately...Using the commandline is very fragile > >unless this is done, since it is a child process and it is easily to > >write a program that can silently fail. > > That was the problem I had as I couldn't capture or display any error > message without using passthru() > > > > it so that we can support cURL etc for fetching the images - I have remote > > > fopen calls disabled and use cURL instead on my server. > >Fine, either way...autodetect of course the best method...point is > >it should be able to do this since the GD extension can. > > Q: Can we autodetect if the curl module is loaded into PHP? I'm sure > there's a simple way but I've never looked. function assertExtension($name) { if (!extension_loaded($name)) { $dlext = OS_WINDOWS ? '.dll' : '.so'; @dl($name . $dlext); } return extension_loaded($name); } Tomas V.V.Cox

« previous php.pear.dev (#6435) next »