картинки темнеют :'(

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
function module_image_resize($s_img)
{
// if not defined functions
if (!function_exists('imagecreatefromjpeg'))
return false;
if (!function_exists('imagecopyresized'))
return false;
// loading image
$s_im = imagecreatefromjpeg($s_img);
if ($s_im)
{
// get_x_y
$image_s_x = imagesx($s_im);
$image_s_y = imagesy($s_im);
if ($image_s_x > 320)
$image_d_x = 320;
else
$image_d_x = $image_s_x;
if ($image_s_y > 480)
$image_d_y = 480;
else
$image_d_y = $image_s_y;
$d_im = imagecreate($image_d_x, $image_d_y);
// if loaded
if ($d_im)
{
imagecopyresampled($d_im, $s_im, 0, 0, 0, 0, $image_d_x, $image_d_y, $image_s_x, $image_s_y);
imagejpeg($d_im, $s_img, 100);
imagedestroy($d_im);
return true;
}
else
{
return false;
}
}
}
?>