Frågan#1
Hej,
jag har hittat ett script som gör thumbnails av en bild. Då bilderna som ska göras till thumbnail är i olika pixel storlekar så skulle jag vilja att storleken ändras efter ett fast höjd. Som ni ser är klockan mitt i natt och mina kunskaper är få inom detta område så hur gör jag.
Någon stans i denna kod gör man det nog...
// Ändra storleken om bilden är större än $new_img_width_large
if ($new_img_width_large < $img_x_y_size[0])
{
$new_img_height_large = ceil(($new_img_width_large / $img_x_y_size[0]) * $img_x_y_size[1]);
$new_img_height_small = ceil(($new_img_width_small / $img_x_y_size[0]) * $img_x_y_size[1]);
// Gör om bildens storlek
$new_image_large = imagecreatetruecolor($new_img_width_large, $new_img_height_large);
$new_image_small = imagecreatetruecolor($new_img_width_small, $new_img_height_small);
// Kontrollera vilken bildtyp det är (1=gif , 2=jpg , 3=png)
switch($img_x_y_size[2])
{
case 1:
$image = imagecreatefromgif($uploaded_img_location);
break;
case 2:
$image = imagecreatefromjpeg($uploaded_img_location);
break;
case 3:
$image = imagecreatefrompng($uploaded_img_location);
break;
}
imagecopyresampled($new_image_large, $image, 0, 0, 0, 0, $new_img_width_large, $new_img_height_large, $img_x_y_size[0], $img_x_y_size[1]);
imagecopyresampled($new_image_small, $image, 0, 0, 0, 0, $new_img_width_small, $new_img_height_small, $img_x_y_size[0], $img_x_y_size[1]);
Tack på förhand