I have two seperate codes
Code 1;
This is my working resize code, needs to stay like this as it's a remote image.
<?php
if ($size == "") {
$size = "M";
}
$off_site = "BKK/10.jpg";
$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;
if ($height < $width) {
$new_w = 640;
$new_h = 480;
} else {
$new_h = 640;
$new_w = 480;
}
$img = imagecreatetruecolor ($new_w,$new_h);
imagecopyresampled ($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
imagejpeg($img, '', 90);
imagedestroy($img);
}
?>
Code 2;
This works for images on the same site, problem is I'm having major problems taking the shadow parts of this code out and adding it to the above code...
list($width, $height) = getimagesize($filename);
$newwidth = "640";
$newheight = "480";
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
define("DS_OFFSET", 5);
define("DS_STEPS", 10);
define("DS_SPREAD", 1);
$background = array("r" => 255, "g" => 255, "b" => 255);
$filename = isset($_REQUEST['filename']) ? urldecode($_REQUEST['filename']) : null;
if(isset($filename) && file_exists($filename)) {
$width = $newwidth + DS_OFFSET;
$height = $newheight + DS_OFFSET;
$image = imagecreatetruecolor($width, $height);
$step_offset = array("r" => ($background["r"] / DS_STEPS), "g" => ($background["g"] / DS_STEPS), "b" => ($background["b"] / DS_STEPS));
$current_color = $background;
for ($i = 0; $i <= DS_STEPS; $i++) {
$colors[$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;
}
imagecopymerge($image, $thumb, 0,0, 0,0, $newwidth, $newheight, 100);
header("Content-type: image/jpeg");
$image2 = imagerotate($image, $degrees, 0);
imagejpeg($image2, "", 100);
imagedestroy($image2);
imagedestroy($original_image);
}
Can someone please help.