getting started?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Depends on what your ISP provided you.

Do you have commandline access?
What version of IM did they install?

if not then you need to find out about PHP.
Can PHP execute IM commands?
Does it have the MagickWand extension?
Does it have Imagic Pecl extension?
Do they have a simple example of using Im from PHP on their system?

For testing, Does your own machine have IM. A simular version?
Can you do quick commandline tests on your machine?

Basically you need to learn the envionment provided to you.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

First 'magic_quotes' is nothing to do with ImageMagick.

I assume you do not have a commandline login on the remote machine.
that is you only somehow upload web files for execution.

So the first thing we need to do is try and find and run the 'convert' command.

Try

Code: Select all

<?
  header('Content-Type: text/plain');
  system("exec 2>&1; type convert");
  system("exec 2>&1; convert -version");
  system("exec 2>&1; convert -list type");
?>
upload the PHP and look at it via the web.
This will run three commands to see what is present. If convert on the command PATH, and if so where is it. What version is it, and what font does IM thing it has access to.

If you only see errors, then "convert" is not on the command line path, in which case you will need to find out exactly where it is located and use something like..

Code: Select all

<?
  $im_path="/opt/php5extras/ImageMagick/bin"
  header('Content-Type: text/plain');
  system("exec 2>&1; $im_path/convert -version");
  system("exec 2>&1; $im_path/convert -list type");
?>
If the ISP did there job properly YOU should not need to do this.
If you get "ldd" library errors, the LD_LIBRARY_PATH is wrong, and the ISP has definateally fallen down on the job!

After that try some of the simplier examples from IM Examples and try to get them working. EG: output the IM 'rose' image as a JPEG.

Code: Select all

<?
  header( 'Content-Type: image/jpeg' );
  system("convert rose:  jpg:-");
?>
Or try one of the fonts listed from the first test page. On my Solaris Server I see a Utopia font set so I can try...

Code: Select all

<?
  header('Content-Type: image/gif');
  system("convert -pointsize 72 -font Utopia-Italic \\
          label:' - Font Test - ' gif:-");
?>
At this point it is all up to you. NOTE the use of a double slash to 'escape' the return for a multi-line command. and the use of single quotes in the command itself.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

This is a very interesting answer Anthony.

Using the first example I can find out the fonts and colours installed etc.

I have never been able to get identify to work but working from your example it now works

Code: Select all

system("exec identify -verbose image.jpg");
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

This is not strictly IM but shell syntax...

In your example, the exec has a different meaning to the way I used it.

Code: Select all

exec  2>&1; 

Which just map the standard error stearm to standard out for later commands. That way they can be seen.

Code: Select all

exec command ....; 
Replace the current shell interpreter with this command If this is successfully done, no other commands following will work.

So in mine I make sure errors can be seen, while in yours you replace the shell with the identify command.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply