Datuve :: Forums :: Arhīvs :: Thumbnail maina krāsu

Datuve

Mana Datuve

Reģistrācija | Noteikumi | Paroles atjaunošana



Forums

Ieskaties


Raksti

Lietotāji online

Lietotāji online: 90

Reģistrētie lietotāji online: 0

Viesi online: 90

Datuve.lv video
Top.LV

Thumbnail maina krāsu

Ievietoja: hulavula @ 2006.08.22 16:36  

Paņēmu vienu php scriptu, lai varētu augšupielādēt bildes un attiecīgi, lai sataisītu arī thumbnailus... viss jau būtu labi, vienīgi thumbnaili parādās ... pat nezinu kā teikt, kaut kas līdzīgs SEPIA krāsai...

Koda gabals:

// Let's get the Thumbnail size
$size = GetImageSize( $images_dir."/".$filename );
if($size[0] > $size[1])
{
$thumbnail_width = 100;
$thumbnail_height = (int)(100 * $size[1] / $size[0]);
}
else
{
$thumbnail_width = (int)(100 * $size[0] / $size[1]);
$thumbnail_height = 100;
}

// Build Thumbnail with GD 1.x.x, you can use the other described methods too
$function_suffix = $gd_function_suffix[$filetype];
$function_to_read = "ImageCreateFrom".$function_suffix;
$function_to_write = "Image".$function_suffix;

// Read the source file
$source_handle = $function_to_read ( $images_dir."/".$filename );

if($source_handle)
{
// Let's create an blank image for the thumbnail
    $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height );

// Now we resize it
      ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] );
}

// Let's save the thumbnail
$function_to_write( $destination_handle, $images_dir."/tb_".$filename );
ImageDestroy($destination_handle );