Connecting Tech Pros Worldwide Help | Site Map

cron not working with php+gd

pushpen@gmail.com
Guest
 
Posts: n/a
#1: Aug 20 '07
I'm trying to run the following php code along with gd library as a
cron job ,but cron is not generating any output.
When I run this code from my browser I get an image correctly.
Somebody please tell me what needs to be done to get an image via cron
job.
<?php
//Header("Content-type: image/png");
$height = 300;
$width = 300;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 10,110,100);
$white = ImageColorAllocate($im, 255, 255, 255);
ImageFill($im, 0, 0, $bck);
ImageLine($im, 0, 0, $width, $height, $white);


for($i=0;$i<=299;$i=$i+10) {
ImageLine($im, 0, $i, $width, $height, $white); }


ImagePNG($im,"x.png");
?>

VS
Guest
 
Posts: n/a
#2: Aug 20 '07

re: cron not working with php+gd


At a Guess I'd say you need to find a way of making cron generate an
email with the image as an attachment, but quite how you go about that I
really don't know. (cron usually only deals with text).

--
VS
jdbartlett
Guest
 
Posts: n/a
#3: Aug 20 '07

re: cron not working with php+gd


On Aug 20, 1:41 pm, push...@gmail.com wrote:
Quote:
I'm trying to run the following php code along with gd library as a
cron job ,but cron is not generating any output.
When I run this code from my browser I get an image correctly.
Somebody please tell me what needs to be done to get an image via cron
job.
<?php
//Header("Content-type: image/png");
$height = 300;
$width = 300;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 10,110,100);
$white = ImageColorAllocate($im, 255, 255, 255);
ImageFill($im, 0, 0, $bck);
ImageLine($im, 0, 0, $width, $height, $white);
>
for($i=0;$i<=299;$i=$i+10) {
ImageLine($im, 0, $i, $width, $height, $white); }
>
ImagePNG($im,"x.png");
?>
Does the user with this cron job have permission to create/overwrite
the file "x.png"?

Rik
Guest
 
Posts: n/a
#4: Aug 20 '07

re: cron not working with php+gd


On Mon, 20 Aug 2007 21:42:30 +0200, jdbartlett <contact@jdbartlett.com
wrote:
Quote:
On Aug 20, 1:41 pm, push...@gmail.com wrote:
Quote:
>I'm trying to run the following php code along with gd library as a
>cron job ,but cron is not generating any output.
>When I run this code from my browser I get an image correctly.
>Somebody please tell me what needs to be done to get an image via cron
>job.
><?php
>//Header("Content-type: image/png");
>$height = 300;
>$width = 300;
>$im = ImageCreate($width, $height);
>$bck = ImageColorAllocate($im, 10,110,100);
>$white = ImageColorAllocate($im, 255, 255, 255);
>ImageFill($im, 0, 0, $bck);
>ImageLine($im, 0, 0, $width, $height, $white);
>>
>for($i=0;$i<=299;$i=$i+10) {
>ImageLine($im, 0, $i, $width, $height, $white); }
>>
>ImagePNG($im,"x.png");
>?>
>
Does the user with this cron job have permission to create/overwrite
the file "x.png"?
>
And keep in mind that often the working directory is wherever the cronjob
started, NOT the directory of the script itself. You might want to try:

ImagePNG($im,dirname(__FILE__)."/x.png");
--
Rik Wasmus
Steve
Guest
 
Posts: n/a
#5: Aug 22 '07

re: cron not working with php+gd


| (cron usually only deals with text).

wtf!?

cron is only responsible for initiating executables at given times. the only
time cron has anything to do with text is when it gives you vi to edit a
cron in response to 'cron -e'. even then, it's vi at work.


Closed Thread


Similar PHP bytes