Hey all,
I wanted a script that makes a reflection of my images so they look more like web2.0
I found this script somewhere on the internet and it workes fine, as long as the script is placed in the same directory as the images. When I upload it in some other directory, it doesn't work.
This is the page from where I would like to run the script:
<?php
// Image name, handy for doubleclick-paste.
$image = 'astanajersey';
// Refix the .jpg extention
$image = $image.'.jpg';
// Echo it out.
echo '<img src="'.$image.'" border=1><br /><img src="http://cyclingcoverage.my2gig.com/images/image.php?src='.$image.'" class="reflection">';
?>
This will work fine, but when I change the value of $image to an entire URL, it doesn't work. I want to pass an entire URL as I have images in different directories and the URL's will be generated by another script (coming from a database)
The script:
<?php
$imgName = $_GET[src];
$size = getimagesize("$imgName");
$imgImport = imagecreatefromjpeg($imgName);
$imgName_w = $size[0];
$imgName_h = $size[1];
$gradientHeight = 50;
// Create new blank image with sizes.
$background = imagecreatetruecolor($imgName_w, $gradientHeight);
$gradientColor = "255 255 255"; //White
$gradparts = explode(" ",$gradientColor); // get the parts of the colour (RRR,GGG,BBB)
$dividerHeight = 0;
$gradient_y_startpoint = $dividerHeight;
$gdGradientColor=ImageColorAllocate($background,$gradparts[0],$gradparts[1],$gradparts[2]);
$newImage = imagecreateTrueColor($imgName_w, $imgName_h);
for ($x = 0; $x < $imgName_w; $x++) {
for ($y = 0; $y < $imgName_h; $y++) {
imagecopy($newImage, $imgImport, $x, $imgName_h - $y - 1, $x, $y, 1, 1);
}
}
// Add it to the blank background image
imagecopymerge ($background, $newImage, 0, 0, 0, 0, $imgName_w, $imgName_h, 100);
//create from a the image so we can use fade out.
$gradient_line = imagecreatetruecolor($imgName_w, 1);
// Next we draw a GD line into our gradient_line
imageline ($gradient_line, 0, 0, $imgName_w, 0, $gdGradientColor);
$i = 0;
$transparency = 60; //from 0 - 100
while ($i < $gradientHeight) { //create line by line changing as we go
imagecopymerge ($background, $gradient_line, 0,$gradient_y_startpoint, 0, 0, $imgName_w, 1, $transparency);
$i++;
$gradient_y_startpoint++;
if ($transparency == 100) {
$transparency = 100;
}
else { // this will determing the height of the reflection. The higher the number, the smaller the reflection. 1 being the lowest(highest reflection)
$transparency = $transparency + 1;
}
}
header("Content-type: image/jpeg");
// Set the thickness of the line we're about to draw
imagesetthickness ($background, $dividerHeight);
// Draw the line - me do not likey the liney
//imageline ($background, 0, 0, $imgName_w, 0, $gdGradientColor);
imagejpeg($background, '', 100); //100 being the quality of image 100 Max(Best)
imagedestroy($background);
imagedestroy(gradient_line);
imagedestroy(newImage);
?>
Could anyone help me? Why won't it work by passing an entire URL and what can I do to fix it?
Thanks!
Pirata