Ik ben een leek wat PHP betreft en heb het volgende scriptje ergens vandaan getoverd.
Nu heb ik alleen het probleem dat de kleuren heel vaag worden van de foto's... wie weet hoe dat komt??
PHP:
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
| <? $new_w = 100; $cfg_fullsizepics_path = "main"; $cfg_thumb_path = "thumb"; $filepath = "main"; $dir = dir($filepath); while($entry=$dir->read()) { if($entry == "." || $entry == "..") { continue; } $fp = @fopen("$filepath/$entry","r"); $photo_filename = "$entry"; $image_stats = GetImageSize($cfg_fullsizepics_path."/".$entry); $imagewidth = $image_stats[0]; $imageheight = $image_stats[1]; $img_type = $image_stats[2]; $ratio = ($imagewidth / $new_w); $new_h = round($imageheight / $ratio); if (!file_exists($cfg_thumb_path."/".$entry)) { if ($img_type=="2") { $src_img = imagecreatefromjpeg($cfg_fullsizepics_path."/".$entry); $dst_img = imagecreate($new_w,$new_h); imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); imagejpeg($dst_img, "$cfg_thumb_path"."/$entry"); } elseif ($img_type=="3") { $dst_img=ImageCreate($new_w,$new_h); $src_img=ImageCreateFrompng($cfg_fullsizepics_path."/".$entry); ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img)); Imagepng($dst_img, "$cfg_thumb_path"."/$entry"); } elseif ($img_type=="1") { $cfg_thumb_url=$cfg_fullsizepics_url; } } echo "$entry"; echo " "; } ?> |
Nu heb ik alleen het probleem dat de kleuren heel vaag worden van de foto's... wie weet hoe dat komt??