All i get is a black image, what is wrong?
<?php
$filename = "http://www.mysite.com/photos/one/name.jpg";
define("DS_OFFSET", 5);
define("DS_STEPS", 10);
define("DS_SPREAD", 1);
list($o_width, $o_height) = getimagesize($filename);
$nwidth = $o_width + DS_OFFSET;
$nheight = $o_height + DS_OFFSET;
$image = imagecreatetruecolor($nwidth, $nheight);
$background = array("r" => 255, "g" => 255, "b" => 255);
$background = array("r" => 255, "g" => 255, "b" => 255);
$current_color = $background;
for ($i = 0; $i <= DS_STEPS; $i++) {
$color[$i] = imagecolorallocate($image, round($current_color["r"]), round($current_color["g"]), round($current_color["b"]));
$current_color["r"] -= $step_offset["r"];
$current_color["g"] -= $step_offset["g"];
$current_color["b"] -= $step_offset["b"];
}
imagefilledrectangle($image, 0,0, $width, $height, $colors[0]);
for ($i = 0; $i < count($colors); $i++) {
imagefilledrectangle($image, DS_OFFSET, DS_OFFSET, $width, $height, $colors[$i]);
$width -= DS_SPREAD;
$height -= DS_SPREAD;
}
$off_site = $filename;
$fp = fopen ($off_site, 'rb') or die('Unable to open file '.$off_site.' for reading');
$buf = '';
while (!feof ($fp))
{
$buf .= fgets($fp, 4096);
}
header('Content-Type: image/jpeg');
$data = $buf;
$src = imagecreatefromstring ($data);
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $height/$width;
$aspect_ratio2 = $width/$height;
if ($size == "M") {
if ($height > $width) {
$new_h = 640;
$new_w = 480;
} else {
$new_w = 640;
$new_h = 480;
}
} elseif ($size == "L") {
if ($height > $width) {
$new_h = 960;
$new_w = 720;
} else {
$new_w = 960;
$new_h = 720;
}
} elseif ($size == "S") {
if ($height > $width) {
$new_h = 240;
$new_w = 180;
} else {
$new_w = 180;
$new_h = 240;
}
}
$img = imagecreatetruecolor ($new_w,$new_h);
imagecopymerge($image, $img, 0,0, 0,0, $o_width, $o_height, 100);
//imagecopyresampled ($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
$img2 = imagerotate($img, $degrees, 0);
imagejpeg($img2, '', 90);
imagedestroy($img2);
?>