Kon nergens een goede uitleg voor mijn probleem vinden, vrienden van mij, PHP experts weten ook geen oplossing voor dit probleem.. Ik heb een mooi script van http://www.phpfreaks.com gehaald om jpg plaatjes te resizen naar thumbnails, het werkt, alleen de kwaliteit van de thumbnails is heel slecht, lijkt wel 26 kleuren plaatje of zo..
Ik heb de GD library geinstalleerd, in phpinfo zegt ie enabled.. Zou moeten werken dus! Heeft iemand hier ervaring mee of weet wat de oplossing zou kunnen zijn?
Ik heb de GD library geinstalleerd, in phpinfo zegt ie enabled.. Zou moeten werken dus! Heeft iemand hier ervaring mee of weet wat de oplossing zou kunnen zijn?
code:
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
| <?
header("Content-type: image/jpeg");
header("Content-type: image/png");
$new_width=200; //Image width Change if needed
$new_height=150; //Image height Change if needed
$source_path="images/"; //Source File path
$destination_path="images/Thumb/"; //Destination file path
$db = mysql_connect("localhost", "","") or die("Cannot Connect"); // Database Connection
mysql_select_db("temp",$db) or die("Cannot open database"); //Database Name
$sql = mysql_query("SELECT * FROM images") or die("Query failed"); //Query
while ($row = mysql_fetch_array($sql))
{
$image_name = $row["Image_path"]; //Image path retrived
//Identifying Image type
$len = strlen($image_name);
$pos =strpos($image_name,".");
$type = substr($image_name,$pos + 1,$len);
if ( $type=="jpeg" || $type=="jpg")
{
thumb_jpeg ($image_name); //Call to jpeg function
}
else if($type="png" || $type="PNG")
{
thumb_png ($image_name); //Call to PNG function
}
echo ("Done........");
}
//JPEG function
function thumb_jpeg($image_name)
{
global $source_path;
global $destination_path;
global $new_width;
global $new_height;
$destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");
$srcimg=ImageCreateFromJPEG($source_path.$image_name) or die("Problem In opening Source Image");
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");
ImageJPG($destimg,$destination_path.$image_name) or die("Problem In saving");
}
//PNG function
function thumb_png($image_name)
{
global $source_path;
global $destination_path;
global $new_width;
global $new_height;
$destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");
$srcimg=ImageCreateFromPNG($source_path.$image_name) or die("Problem In opening Source Image");
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");
ImagePNG($destimg,$destination_path.$image_name) or die("Problem In saving");
}
?> |
[ Voor 70% gewijzigd door Verwijderd op 12-01-2004 13:10 ]