0
<?php

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

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

// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

?>

is giving error The image “http://localhost/test/into.php” cannot be displayed because it contains errors.Solve this please?

user1559763
  • 141
  • 8
  • possible duplicate of [imagemagick convert.exe error](http://stackoverflow.com/questions/11702187/imagemagick-convert-exe-error) – Yan Berk Jul 28 '12 at 15:38
  • What does the image contain when you view it in a text editor? I bet there's a PHP error message in there. – Pekka Jul 28 '12 at 15:39
  • he edited the other question.. I asked him to put this question separate – Elzo Valugi Jul 28 '12 at 15:40
  • I see the same error here http://stackoverflow.com/questions/8675336/cmyk-to-rgb-using-php – Elzo Valugi Jul 28 '12 at 15:41
  • @Pekka in log file it is showing class imagick not found – user1559763 Jul 28 '12 at 15:41
  • That's your problem then. You will need to install the imagick library. http://www.php.net/manual/en/imagick.installation.php – Pekka Jul 28 '12 at 15:45
  • but i have already see here http://i.stack.imgur.com/IRJlG.png – user1559763 Jul 28 '12 at 15:46
  • Nope, that's only the system-wide PATH setting. It doesn't mean the library is installed. It seems like the only way to get this library on Windows is to recompile PHP - ugh.... – Pekka Jul 28 '12 at 15:49

2 Answers2

2

Please read details in commented lines

<?php

//drawing stuff that creates $image

ob_get_clean(); //this statement is what mine was lacking before I could get it to work properly
header("Content-type: image/png");
echo $image;
cyborg86pl
  • 2,597
  • 2
  • 26
  • 43
BobR
  • 21
  • 2
  • In my case `ob_get_clean()` was needed too, until I noticed a hidden `print "
    ";` statement earlier in my code. Still this solution can save a lot of time.
    – Code4R7 Mar 06 '23 at 10:18
0

Your image is created at 0 px height and probably invalid format. Try and see docs.

$image->thumbnailImage(100, 100);
Elzo Valugi
  • 27,240
  • 15
  • 95
  • 114