Page 1 of 1

Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T12:20:14-07:00
by AphelionZ
I installed all the necessary libraries and ImageMagick from source, and then installed the imagick extension. Everything looks like its in the right place (phpinfo showing imagick and all the proper formats)

However, when I try to run THIS script: http://pastebin.com/m1531bed6
with THIS input: http://takesalltypes.org/fb/card.php?ty ... e=John+Foo
(or any input for that matter)

it barfs out and the php error log says

Code: Select all

PHP Fatal error:  Uncaught exception 'ImagickException' with message 'Corrupt image `/var/www/vhosts/takesalltypes.org/httpdocs/images/cards/O-.png'' in /var/www/vhosts/takesalltypes.org/httpdocs/fb/card.php:15
Stack trace:
#0 /var/www/vhosts/takesalltypes.org/httpdocs/fb/card.php(15): Imagick->__construct('../images/cards...')
Very frustrating. I've included the image as well.

Help!!!
A+.png
A+.png (34.87 KiB) Viewed 18044 times

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T13:06:17-07:00
by Bonzo
I would try something simple first to get the code working and then add it into the form; echo out your variables to see if they contain what you expect.

I do not use imagick but the first time through I find I get A .png as the image so I assume the + in A+ is causing a problem. Removing the + I then get A.png which is still wrong.
Next I change $image = new Imagick($type.'.png'); to $image = new Imagick('card.png'); and I get an image of a card with the the blood group and the name putting the + back in I get an error so I assume you have to escape it in some way.

A saved version:
Image

So not an Imagick problem after all :D

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T13:40:52-07:00
by AphelionZ
Unfortunately this didn't solve my problem! I made a copy called card.png just like you in the same directory as my script and i still get the corrupt file error!

Code: Select all

PHP Fatal error:  Uncaught exception 'ImagickException' with message 'Corrupt image `/var/www/vhosts/takesalltypes.org/httpdocs/fb/card.png'' in /var/www/vhosts/takesalltypes.org/httpdocs/fb/card.php:15
I dont know if its something with permissions or what? I just don't know where to look from here.

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T14:22:12-07:00
by Bonzo
I would not have thought it was a permission problem as your code is not saving the image just displaying it.

As I say I do not know that much about Imagick and so I can not offer any more advice; it could be a version problem. I ran it with Image magick 6.4.0-9-Q16 on a windows XP machine using XAMPP but no idea what version of Imagick I have installed.

This is the actual code I used in case I changed something else I forgot about:

Code: Select all



Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T14:24:42-07:00
by Bonzo
I would not have thought it was a permission problem as your code is not saving the image just displaying it.

As I say I do not know that much about Imagick and so I can not offer any more advice; it could be a version problem. I ran it with Image magick 6.4.0-9-Q16 on a windows XP machine using XAMPP and Imagick 2.0.0-rc1

This is the actual code I used in case I changed something else I forgot about:

Code: Select all

<?
 
//phpinfo();die();
 
header('Content-type: image/png');
 
if (strpos($_GET['type'], "?") !== false) {
        $type = "?";
} else {
        $type = $_GET['type'];
}
 
error_reporting(E_ALL);
 
$image = new Imagick('card.png');
 
$draw = new ImagickDraw();
 
$draw->setFont("./FutuBd__.ttf");
$draw->setFontStretch(3);
$draw->annotation(24,86,'Blood Type '.$type);
 
//$draw->setFontWeight(30);
$draw->annotation(24,65,$_GET['name']);
 
$image->drawImage($draw);
 
$image->writeImage("a.png");
?>

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T20:41:16-07:00
by AphelionZ
I believe it's a server configuration problem. I've been told that my Plesk control panel can get in the way. I can definitely post this on the plesk boards too but hopefully somebody here has had experience.

I only say this because it's one of the last places I have remaining to look...

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-11T23:55:55-07:00
by Bonzo
You could try using php and the comand line and see what happens ( I gave up posting last night as the forum was extremly slow ) it would be quite a simple thing to do.

Re: Damn it, IMagick, my png files are NOT corrupt.

Posted: 2008-09-12T09:19:24-07:00
by Bonzo
The + in the URL gives a problem; I have used z in the URL instead and changed it for + in the code. This save the image rather than displaying it but it should give you the idea of how it works.

Code: Select all

<?
 
//phpinfo();die();
 
header('Content-type: image/png');
 
if (strpos($_GET['type'], "?") !== false) {
        $type = "?";
} else {
        $type = $_GET['type'];
		$type = str_replace( 'z', '+', $type);
}
 
error_reporting(E_ALL);
 
$image = 'card.png';;
$font = "./FutuBd__.ttf";
$colour = "black";
$pontsize = 16;
$name = $_GET['name'];

$cmd = " $image -font $font -fill $colour -pointsize $pontsize ".
" -annotate +24+86 \"Blood Type $type\" ".
" -annotate +24+65 \" $name \" ";
 echo $cmd;
exec("convert $cmd ab.png");
?>