Witam mam problem z GD. Chce aby przy tworzeniu miniatur dodawały mi się do nich ramki( wyglądu polaroida) ale jakoś topornie mi to idzie. Proszę was o pomoc bo sam już nie wiem co mam robić. Kod zaczyna się od 29 linijki.
WYPIS functions.php
<?php
?>
<?php
/*
Upload an image and create the thumbnail. The thumbnail is stored
under the thumbnail sub-directory of $uploadDir.
Return the uploaded image name and the thumbnail also.
*/
function uploadImage($inputName, $uploadDir)
{
$image = $_FILES[$inputName];
$imagePath = '';
$thumbnailPath = '';
$ramka = "imgages/ramka.png";
// if a file is given
if (trim($image['tmp_name']) != '') {
// generate a random new file name to avoid name conflict
// then save the image under the new file name
if ($result) {
// create thumbnail
$image1 = imagecreatefrompng( $ramka );
$image2 = imagecreatefromjpeg( $image );
imagecopy( $image2, $ramka, 0, 0, 0, 0, 5, 10 );
imagejpeg( $image2 );
imagedestroy( $ramka );
imagedestroy( $image2 );
$image1 = imagecreatefrompng( $ramka );
$image2 = imagecreatefromjpeg( $image );
imagecopy( $image2, $ramka, 0, 0, 0, 0, 5, 10 );
imagejpeg( $image2 );
imagedestroy( $ramka );
imagedestroy( $image2 );
$result = createThumbnail($uploadDir . $imagePath, $uploadDir . 'thumbnail/' . $thumbnailPath, THUMBNAIL_WIDTH);
// create thumbnail failed, delete the image
if (!$result) {
unlink($uploadDir . $imagePath); $imagePath = $thumbnailPath = '';
} else {
$thumbnailPath = $result;
}
} else {
// the image cannot be uploaded
$imagePath = $thumbnailPath = '';
}
}
return array('image' => $imagePath, 'thumbnail' => $thumbnailPath); }
header( "Content-type: image/jpg" ); /*
Create a thumbnail of $srcFile and save it to $destFile.
The thumbnail will be $width pixels.
*/
function createThumbnail($srcFile, $destFile, $width, $quality = 75)
{
$thumbnail = '';
{
$thumbnail = copyImage($srcFile, $destFile, $w, $h, $quality);
}
// return the thumbnail file name on sucess or blank on fail
}
/*
Copy an image to a destination file. The destination
image size will be $w X $h pixels
*/
function copyImage($srcFile, $destFile, $w, $h, $quality = 75)
{
if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg")
{
$dest = imagecreatetruecolor($w, $h);
//imageantialias($dest, TRUE);
} elseif ($tmpDest['extension'] == "png") {
$dest = imagecreatetruecolor($w, $h);
//imageantialias($dest, TRUE);
} else {
return false;
}
switch($size[2])
{
case 1: //GIF
$src = imagecreatefromgif($srcFile);
break;
case 2: //JPEG
$src = imagecreatefromjpeg($srcFile);
break;
case 3: //PNG
$src = imagecreatefrompng($srcFile);
break;
default:
return false;
break;
}
imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]);
//imagettftext($image, 9, 0, 100, 85, $color_czerwony, "font.ttf", "test");
switch($size[2])
{
case 1:
case 2:
imagejpeg($dest,$destFile, $quality);
break;
case 3:
imagepng($dest,$destFile);
}
return $destFile;
}
...... itd
?>