CLI + Command = Success; PHP + Command = Failure
Results 1 to 4 of 4

Thread: CLI + Command = Success; PHP + Command = Failure

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,914

    CLI + Command = Success; PHP + Command = Failure

    Hey Hey,

    So as many of you know I've been doing quite a bit of php for work lately.... I know... I hear you groans but don't worry... no code to fix this time....

    I'm basically building an image library... but it has to have some quirks.... PDF and EPS files have to be treated as images... (which is part of the reason for the custom development)...

    Now I used image magick to do the conversion from the command line during testing..

    convert test.eps test.jpg (I could successfully browse to and display that image in my browser)
    convert test.pdf test.jpg (This would complete however the graphic would often be CMYK meaning the browser wouldn't convert it and I just recently learned of -colorspace RGB)

    So PDFs were done using first gs to output a jpg and then using imagemagick to convert that jpg into a usable PNG for the web... and convert was used for eps... this was all from the command line and everything worked beautifully.

    So then I started scripting it in php... I know there's MagickWand for PHP but the lack of documentation (and corrupted help file on the site) make it dificult to use or attempt to use. So I use system calls to execute these commands. First I did the pdf... called the two commands, ended up with a png, deleted the pdf and then swapped the name of the pdf for the name of the png in my array... It's beautiful... it even trims the whitespace.

    Then I went to add EPS support.... I'm using the same command as I did on the CLI... CnP even.. It always core dumps...

    So here's my question... anyone know why it core dumps? Has anyone heard of a bug in PHP where it can't call some CLI commands properly.... Or a bug in ImageMagick... Would I be better off using system() rather than exec() (which is what I'm currently using)... Or has anyone seen viable documentation for MagickWand?

    By the end of today if I haven't made this work.... (I can't really bill the client much more on it)... I'm going to just creating a bash script... I'll call the bash script with the input and output file names and it'll call convert... but I figured since we have the broad user base here that I'd poke around and see if anyone had seen this before.

    Peace,
    HT
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Did you try imagick?
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,914
    Hey Hey,

    Thanks for the response...

    I have to rely on both ghostscript and image magick bceause i'm dealing with postscript files (pdf and eps)... but it may work... I've put a request into my host to install the extension on my server

    Peace,
    HT
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  4. #4
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    I usually just use backticks for command execution in php. It may not give you different results, but it's worth a shot.
    PHP Code:
    echo `ls`; 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •