/    Sign up×
Community /Pin to ProfileBookmark

save php created image

[code=php]
<?php
$settings = parse_ini_file(“apple.ini”,TRUE);
header(“Content-type: image/PNG”);
$clocksize = $settings[“analogclock”][“clocksize”];
$image = ImageCreateTrueColor($clocksize,$clocksize);

imagesetthickness($image,$settings[“analogclock”][“linethickness”]);

$cH = imagecolorallocate($image,hexdec(substr($settings[“analogclock”][“hourcolor”],0,2)),hexdec(substr($settings[“analogclock”][“hourcolor”],2,2)),hexdec(substr($settings[“analogclock”][“hourcolor”],4,2)));
$cM = imagecolorallocate($image,hexdec(substr($settings[“analogclock”][“minutecolor”],0,2)),hexdec(substr($settings[“analogclock”][“minutecolor”],2,2)),hexdec(substr($settings[“analogclock”][“minutecolor”],4,2)));
$cS = imagecolorallocate($image,hexdec(substr($settings[“analogclock”][“secondcolor”],0,2)),hexdec(substr($settings[“analogclock”][“secondcolor”],2,2)),hexdec(substr($settings[“analogclock”][“secondcolor”],4,2)));
$h = date(“h”)+2+date(“O”)+substr($settings[“analogclock”][“timezone”],0,-2);
$m = date(“i”)+substr($settings[“analogclock”][“timezone”],-2,2);
$s = date(“s”);

$bgimage = imagecreatefrompng($settings[“analogclock”][“image”]);
imagecopy($image,$bgimage,0,0,0,0,imagesx($bgimage),imagesy($bgimage));
imagedestroy($bgimage);

$srad = ($clocksize/2)-($clocksize/10);
$send = (($s*(2*M_PI))/60)-(M_PI/2);
$mrad = ($clocksize/2)-($clocksize/7.5);
$mend = (($m*(2*M_PI))/60)-(M_PI/2)+($send/60);
$hrad = ($clocksize/2)-($clocksize/3.5);
$hend = ((($h*(2*M_PI))/12)-(M_PI/2))+($mend/12);

$x = ($clocksize/2)+($hrad*cos($hend));
$y = ($clocksize/2)+($hrad*sin($hend));
$nx1 = ($clocksize/2)-0.8*5*cos(M_PI*($h/6+$m/360));
$ny1 = ($clocksize/2)-0.8*5*sin(M_PI*($h/6+$m/360));
$nx2 = ($clocksize/2)+0.8*5*cos(M_PI*($h/6+$m/360));
$ny2 = ($clocksize/2)+0.8*5*sin(M_PI*($h/6+$m/360));
if($settings[“analogclock”][“fill”] == TRUE)
{
$values = array(0=>$nx1, 1=>$ny1, 2=>$x, 3=>$y, 4=>$nx2, 5=>$ny2);
imagefilledpolygon($image, $values, 3, $cH);
}
else
{
imageline($image,$nx1,$ny1,$x,$y,$cH);
imageline($image,$nx2,$ny2,$x,$y,$cH);
imageline($image,$nx1,$ny1,$nx2,$ny2,$cH);
}
$x = ($clocksize/2)+($mrad*cos($mend));
$y = ($clocksize/2)+($mrad*sin($mend));
$nx1 = ($clocksize/2)-.5*5*cos(M_PI*($m/30+$s/1800));
$ny1 = ($clocksize/2)-.5*5*sin(M_PI*($m/30+$s/1800));
$nx2 = ($clocksize/2)+.5*5*cos(M_PI*($m/30+$s/1800));
$ny2 = ($clocksize/2)+.5*5*sin(M_PI*($m/30+$s/1800));
if($settings[“analogclock”][“fill”] == TRUE)
{
$values = array(0=>$nx1, 1=>$ny1, 2=>$x, 3=>$y, 4=>$nx2, 5=>$ny2);
imagefilledpolygon($image, $values, 3, $cH);
}
else
{
imageline($image,$nx1,$ny1,$x,$y,$cM);
imageline($image,$nx2,$ny2,$x,$y,$cM);
imageline($image,$nx1,$ny1,$nx2,$ny2,$cM);
}
$x = ($clocksize/2)+($srad*cos($send));
$y = ($clocksize/2)+($srad*sin($send));
imageline($image,$clocksize/2,$clocksize/2,$x,$y,$cS);

$middleimage = imagecreatefrompng($settings[“analogclock”][“middleimage”]);
imagecopy($image,$middleimage,32,32,0,0,imagesx($middleimage),imagesy($middleimage));
imagedestroy($middleimage);

imagepng($image);
imagedestroy($image);
?>
[/code]

How do I save this image to a file on the ftp server?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJul 03.2004 — replace

[b]imagepng($image);[/b]

with

[b]imagepng($image, 'path/to/image.png');[/b]

and of course, change 'path/to/image.png' to what you want to save it to
×

Success!

Help @MACnus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...