Page 1 of 1

Had to install it myself in Linux---still have issues

Posted: 2008-07-30T12:47:05-07:00
by mvigor
My web host is running a Linux setup and wouldn't install ImageMagick and Ghostscript so I had to install them myself.

I finally got the install working from the command shell. The following command, when executed from the shell prompt in the /bin folder, works...

convert -quality 50 -border 3x3 -bordercolor "#000000" ../../../uploads/128108bce50a178a2e6ad66ff3074d3e.pdf[0] -resize 100x120 ../../../uploads/128108bce50a178a2e6ad66ff3074d3e_thumb.jpg

The path to the install is *root*/usr/local/bin. The PDF and thumbnail directory is *root*/uploads. Again, the command above works and will successfully make me a thumbnail image of the first page of a PDF file, saving it as a JPEG with a similar name.

But I simply cannot get the command to work from within PHP anymore.

I have tried many things, and I almost always get error 127, whatever that is.

<?
system("usr/local/bin/convert -quality 50 -border 3x3 -bordercolor \"#000000\" ../../../uploads/128108bce50a178a2e6ad66ff3074d3e.pdf[0] -resize 100x120 ../../../uploads/128108bce50a178a2e6ad66ff3074d3e_thumb.jpg);
?>

This PHP command does not work. Any help or advice please?

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:08:28-07:00
by Bonzo
I would try a simple command with everything in one folder first to see if IM is working with php. This will display any errors as well:

Code: Select all

<?php
$array=array();
echo "<pre>";
exec("convert input.pdf Output.png 2>&1", $array); 
print_r($array);
echo "</pre>";
?> 
Sometimes exec will work but not system or the otherway around; also you should get away with just using convert rather that user/local/bin/convert.
I think you will need to try some variations to see what works.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:15:02-07:00
by mvigor
Alright, I'll go try that. I figured that since I had to install IM and GS myself in a nonstandard location that I would have to specify the path.

Results:
Array
(
[0] => sh: gs: command not found
[1] => convert: Postscript delegate failed `94b11c6dadfad5315a41cbf5bc497c76.pdf'.
)

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:17:16-07:00
by Bonzo
My path to IM is usr/local/bin/convert but I can just use convert.

You can check out your setup with some of my codes here: http://www.rubblewebs.co.uk/imagemagick ... server.php

If I have a problem I always try a simple example first and the expand it when the simple one works.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:19:17-07:00
by mvigor
My path isn't the server's "real" /usr/local/bin... it's based in my root home directory. Full path seems to be
/kunden/homepages/41/d244158790/htdocs/usr/local/bin/convert . . . where htdocs is my user's root directory for hosting web files. It's a very unusual way of doing things, as I'm used to unix machines where many files are kept one level higher than the web root directory.

Alas I am also used to having these scripts installed and configured for me.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:21:08-07:00
by Bonzo
Looks like there is something wrong with the path to Ghost Script.

Just out of interest to prove IM is working why not try saving a jpg as a png or something?

OK I wonder if thats why IM can not find the Ghost script ?

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:23:34-07:00
by mvigor
I hear what you're saying, but I don't know enough about the whole thing to know why that could be true.

To me it seems like if I can go into a SSH terminal, 'cd' into the bin directory, issue the command, and it work from there...it ought to work everywhere.

Right?

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:24:45-07:00
by mvigor
P.S. I also did the default ImageMagick test on logo.gif after install and that worked as well.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:25:58-07:00
by Bonzo
No I do not think it works like that but it is beyond my knowlege as well :(

If you did the test IM is working OK but as I say IM can not find Ghost script.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-30T13:39:36-07:00
by Bonzo
Does this give you any helpful information:

Code: Select all

<?php
system ("convert -list Delegate");
?>
Just remembered this page on my site:
http://www.rubblewebs.co.uk/imagemagick ... oblems.php
Your problem is the second one on the list ?
I can not remember the full details of this now :?

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-31T08:24:31-07:00
by mvigor
I tried that last script you sent and it gave me output, but nothing that seemed helpful at first glance:

Code: Select all

Path: /usr/lib/ImageMagick-6.2.4/config/delegates.xml Delegate Command ------------------------------------------------------------------------------- cgm => ralcgm" -d ps -oC < "%i" > "%o" 2>/dev/null crw => dcraw" -3 -w -c "%i" > "%o dcr => dcraw" -3 -w -c "%i" > "%o dvi => dvips" -R -q -o "%o" "%i emf => wmf2eps" -o "%o" "%i eps<=>pdf gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pdfwrite" -sOutputFile="%o" -f"%i eps<=>ps gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pswrite" -sOutputFile="%o" -f"%i fig => fig2dev" -L ps "%i" "%o gplt => echo" "set size 1.25,0.62 set terminal postscript portrait color solid; set output "%o"; load "%i"" > "%u";"gnuplot" "%u hpg => hp2xx" -q -m eps -f `basename "%o"` "%i mv -f `basename "%o"` "%o hpgl => if [ -e hp2xx -o -e /usr/bin/hp2xx ]; then hp2xx -q -m eps -f `basename "%o"` "%i mv -f `basename "%o"` "%o else echo "You need to install hp2xx to use HPGL files with ImageMagick. exit 1 fi htm => html2ps" -U -o "%o" "%i html => html2ps" -U -o "%o" "%i https => @WWWDecodeDelegateDefault@" -q -O "%o" "https:%i ilbm => ilbmtoppm" "%i" > "%o man => groff" -man -Tps "%i" > "%o miff<= win /usr/bin/display" -immutable "%i mrw => dcraw" -3 -w -c "%i" > "%o nef => dcraw" -3 -w -c "%i" > "%o orf => dcraw" -3 -w -c "%i" > "%o pdf<=>eps gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="epswrite" -sOutputFile="%o" -f"%i pdf<=>ps gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pswrite" -sOutputFile="%o" -f"%i pnm<= ilbm ppmtoilbm" -24if "%i" > "%o pnm<= launch gimp" "%i pov => povray" "+i"%i"" +o"%o" +fn%q +w%w +h%h +a -q9 -kfi"%s" -kff"%n convert" -concatenate "%o*.png" "%o ps<=>eps gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="epswrite" -sOutputFile="%o" -f"%i ps<=>pdf gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pdfwrite" -sOutputFile="%o" -f"%i ps<= print lpr "%i rad => ra_ppm" -g 1.0 "%i" "%o raf => dcraw" -3 -w -c "%i" > "%o rgba<= rle modify" -flip -size %wx%h "rgba:%i rawtorle" -w %w -h %h -n 4 -o "%o" "%i scan => scanimage" -d "%i" > "%o shtml => html2ps" -U -o "%o" "%i txt<=>ps enscript" -o "%o" "%i wmf => wmf2eps" -o "%o" "%i x3f => dcraw" -3 -w -c "%i" > "%o
I'm wondering if I need to change a setting in my PHP.INI file to tell it where the new install location for IM and GS is?

When I ran your

Code: Select all

system ("type convert");
command I received
convert is /usr/bin/convert

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-31T08:31:47-07:00
by mvigor
Now that I have snooped around more, I noticed that the output from that last command said 6.2.4, but I have installed 6.4.1.

Perhaps my PHP is linked in with someone else's install of a IM...an install that doesn't have GS? I'm thinking I need to tell PHP where my install is. Do you know where that setting would be?

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-31T11:58:38-07:00
by mvigor
Does anybody else have any advice on getting this working?

Again, my install performs flawlessly from the Linux shell command prompt, as long as I issue the command from the directory where 'convert' and 'gs' reside. It works from there.

Code: Select all

working directory: /root/user/local/bin

command: convert -quality 50 -border 3x3 -bordercolor "#000000" ../../../uploads/128108bce50a178a2e6ad66ff3074d3e.pdf[0] -resize 100x120 ../../../uploads/128108bce50a178a2e6ad66ff3074d3e_thumb.jpg

result: SUCCESS.
But if I move into a different directory and issue the 'convert' command, I get an error

Code: Select all

working directory: /root/freebie_generator

command: ../usr/local/bin/convert -quality 50 -border 3x3 -bordercolor "#000000" ../uploads/128108bce50a178a2e6ad66ff3074d3e.pdf[0] -resize 100x120 ../uploads/128108bce50a178a2e6ad66ff3074d3e_thumb.jpg

result: convert: NoDecodeDelegateForThisImageFormat `../uploads/128108bce50a178a2e6ad66ff3074d3e.pdf'.
convert: MissingAnImageFilename `../uploads/128108bce50a178a2e6ad66ff3074d3e_thumb.jpg'.

Re: Had to install it myself in Linux---still have issues

Posted: 2008-07-31T14:38:06-07:00
by el_supremo
The fact that it works from the installation directory but nowhere else suggests that it is not completely configured. For example, the fact that you get the "NoDecodeDelegate" for the .pdf extension suggests that IM can't find the delegates.xml file which tells it how to convert a pdf file to something it understands.
I haven't used Linux/Unix for quite a while but the docs say that you should set the variable $MAGICK_CONFIGURE_PATH to the directory where the delegate and other configuration files are located and presumably that's the same one where gs and convert are.
See: http://imagemagick.org/script/resources.php

Pete

Re: Had to install it myself in Linux---still have issues

Posted: 2008-08-01T15:01:10-07:00
by Bonzo
There is a similar post here:
http://redux.imagemagick.org/discourse- ... =1&t=11805

As I thought it looks like your paths are the problem, first I would try to get the correct version of IM by trying variations of:

Code: Select all

<?php
echo "<pre>";
system("/kunden/homepages/41/d244158790/htdocs/usr/local/bin/convert  -version");  
echo "</pre>";
?> 
Then the gs in this part of the delegates.xml file is the path to Ghost Script, again I presume you have to get the correct path and so you will need to use trial and error ?

Code: Select all

pdf<=>ps gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 -sDEVICE="pswrite" -sOutputFile="%o" -f"%i
Of course you need to edit the correct file !