Page 1 of 1
Trouble on creating png
Posted: 2012-03-12T08:21:57-07:00
by Lupus
Ok! I have this simple code:
Code: Select all
convert -background transparent -fill red -pointsize 72 -gravity Center label:"DENEY" deney.png
and it works flawlessly on dos and bash terminal.
But this:
Code: Select all
<?php
header("Content-type: image/png");
passthru('convert -background transparent -fill red -pointsize 72 -gravity Center label:"DENEY" PNG:-');
?>
won't work on php.
the syntext
should be true. (I saw it in this forum) But I couldn't make it work. I tried exec and system commands as well but nothing changed.
I'm tryng to create a transparent backgrounded png file on fly with auto height and width base on text size. And echo this directly as page response.
Pleas help me. I'm despred.
Re: Trouble on creating png
Posted: 2012-03-12T09:51:32-07:00
by Bonzo
Not sure why it will not work but this should work:
Save your code on a page on its own called something like deny.php ( change passthrough to system ) then call from another page with <img src="deny.php"> You will probably have to remove the header line.
Re: Trouble on creating png
Posted: 2012-03-12T20:15:37-07:00
by anthony
No the header line will still be needed as the <IMG SRC=...> tag calls the web server to get the image.
You should be able to call it direct too via the URL to the PHP PHP script.
The suffix should not matter for browsers, though when a user try to save the URL contents the correct suffix is a good thing. The problem then, is making sure the web server understands that it is a PHP script (to be parsed on the sever) and not really a PHP script. I had to do something similar recently, and a local ".htaccess" on my Apache web server fixed that problem.
However the script worked for me.
http://www.ict.griffith.edu.au/anthony/public/label.php
Have you had a look in the error log "/var/log/httpd/error_log"
If you do not have access then you should (and you should do this any way), redirect your PHP errors to your own log (when debugging). See my PHP notes
http://www.ict.griffith.edu.au/anthony/ ... /php.hints
Re: Trouble on creating png
Posted: 2012-03-13T01:00:29-07:00
by Bonzo
I could not get the script to work for me; it just displays some characters which represent the image.
It displayed OK with the method I posted.
Re: Trouble on creating png
Posted: 2012-03-13T08:40:39-07:00
by Lupus
ok I couldn't find the right solution for that and because of that I turned my face to a diffrent approach;
NODEJS:
Code: Select all
var ls = spawn('C:\\ImageMagick-6.7.6-Q16\\convert.exe', ['-density', 96, '-background', 'transparent', '-fill', RGB ,'-font', 'Arial', '-pointsize', dens , '-gravity', 'NorthWest', 'label:' + metin ,'PNG:-']);
ls.stdout.on('data', function (data) {
res.write(data);
})
ls.stdout.on('end', function (data) {
res.end();
})
ls.stderr.on('data', function (data) {
console.log(data);
})
Well! I have diffrent problems now. But they are subject of another post
viewtopic.php?f=1&t=20523