Page 1 of 1

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

Posted: 2011-10-26T06:50:41-07:00
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.

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

Posted: 2011-10-26T07:08:40-07:00
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>

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

Posted: 2011-10-26T07:25:45-07:00
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.

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

Posted: 2011-10-26T19:18:47-07:00
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.