Please anybody guide me, I am using following code for display image on screen
header('Content-Type: image/jpeg');
$magick_wand = NewMagickWand();
if (MagickReadImage($magick_wand, "paste_img/20070309130202.jpg") != 0)
{
MagickSetFormat($magick_wand, 'jpeg');
MagickEchoImageBlob($magick_wand);
}
else
{
echo MagickGetExceptionString($magick_wand);
}
DestroymagickWand($magick_wand);
But it will display junk character on screen.
Snowby Dave
MagickEchoImageBlob() display junk character on screen
Re: MagickEchoImageBlob() display junk character on screen
I am also having this problem. I have recently installed ImageMagick and Magickwand on ubuntu for use with PHP.
I am able to load an image, rotate it, takes its width and height, however whenever i try and use
MagickEchoImageBlob i get a bunch of random characters and junk where the image should be. Tried with a .jpg and a .png image.
I am able to load an image, rotate it, takes its width and height, however whenever i try and use
MagickEchoImageBlob i get a bunch of random characters and junk where the image should be. Tried with a .jpg and a .png image.
Code: Select all
<?php
echo <<<html
Test image rotate: <br><br>
html;
$resource = NewMagickWand();
MagickReadImage( $resource, 'images/image_1.jpg' );
$w = MagickGetImageWidth($resource);
$h = MagickGetImageHeight($resource);
echo "image height & width: $h , $w <br>";
//=========================================>
// Rotate the image and see if the width
// and height change properly
//=========================================>
echo "Rotating image.... <Br>";
MagickRotateImage($resource, null, 90);
$w = MagickGetImageWidth($resource);
$h = MagickGetImageHeight($resource);
echo "rotated image height & width: $h , $w <br>";
echo "Image: <Br>";
MagickEchoImageBlob($resource);
?>
Re: MagickEchoImageBlob() display junk character on screen
You know what, in my case it doesnt matter anymore. I have found an easy way around it.
I'm just saving the image now and displaying it the way i normally would with HTML.
Heres the code of loading an image, rotating it, saving it, and then displaying it.
Each time the page refreshes, the image rotates.
I'm just saving the image now and displaying it the way i normally would with HTML.
Heres the code of loading an image, rotating it, saving it, and then displaying it.
Each time the page refreshes, the image rotates.
Code: Select all
<?php
echo <<<html
Test image rotate: <br><br>
html;
$resource = NewMagickWand();
$imagePath = "images/image_1.jpg";
MagickReadImage( $resource, $imagePath );
$w = MagickGetImageWidth($resource);
$h = MagickGetImageHeight($resource);
echo "image height & width: $h , $w <br>";
//=========================================>
// Rotate the image and see if the width
// and height change properly
//=========================================>
echo "Rotating image.... <Br>";
MagickRotateImage($resource, null, 90);
$w = MagickGetImageWidth($resource);
$h = MagickGetImageHeight($resource);
echo "rotated image height & width: $h , $w <br>";
//============================================>
// Save the image to the original image path
// specified at the beginning "$imagePath"
// over writing the original image
//============================================>
echo "Saving Rotated Image... <br>";
MagickWriteImage($resource, $imagePath);
//===============================>
// Display the image
//===============================>
echo <<<image
<img src="$imagePath">
image;
?>