I think ImageMagick is installed, but can't get any response

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
ttmt
Posts: 4
Joined: 2011-10-26T06:33:50-07:00
Authentication code: 8675308

I think ImageMagick is installed, but can't get any response

Post by ttmt »

Hi all

After days of trying I think I finally have ImageMagick and Imagick installed.

Im using MAMP 2 with PHP 5.3.6 on Mac OSX Lion.

If I test with phpInfo() I can see the Imagick.

Image

If I try and test Imagick I don't get any response. I'm using this from php.net

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>untitled</title>
</head>

<body>
  <h1>test</h1>
  
  <?php

    header('Content-type: image/jpeg');

    $image = new Imagick('test.jpg');

    $image->adaptiveBlurImage(5,3);
    
    echo $image;

  ?>
  
  
</body>
</html>


All I get is this

Image


Am I missing something?

Any help with this would be greatly appreciated.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: I think ImageMagick is installed, but can't get any resp

Post by Bonzo »

Try this in a page on its own called something like image.php

Code: Select all

<?php

    header('Content-type: image/jpeg');

    $image = new Imagick('test.jpg');

    $image->adaptiveBlurImage(5,3);
    
    echo $image;

  ?>
Do you get an image - try removing the header('Content-type: image/jpeg'); if you still do not get an image.

In your code when above is working try:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

   <title>untitled</title>
</head>

<body>
  <h1>test</h1>
  
<img src="image.php">
  
</body>
</html>
ttmt
Posts: 4
Joined: 2011-10-26T06:33:50-07:00
Authentication code: 8675308

Re: I think ImageMagick is installed, but can't get any resp

Post by ttmt »

Thanks Bonzo, thats done it.

I keep making the same mistake - it's an image and I'm trying to put html in it.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: I think ImageMagick is installed, but can't get any resp

Post by anthony »

If you don't want to save an image. the way to do this is to have PHP either generate a HTML page or the image.

The image link in the PHP generated HTML page would call the PHP to generate a image as a separate download.
The PHP can be either separate PHP programs, or the same program with different HTTP arguments. As long as the right header and the right output (html or jpeg) is output, you should have no problems.

This way you do not have to save the image, as such do you have timing, permission, update, or cleanup problems in handling the image displayed on the HTML page. Everything is generated as needed.

If the generated image does not change on updates, you may like to add 'cache' header items, so image gets stored in web caches and/or the user the machine, for future use.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply