Ik heb het volgende probleem:
als ik de onderstaande code uitvoer loopt het script vast op het stuk waar $img1 begint.
het vreemde is dat als ik bij de image en image_groot i.p.v. $img1 en $img2 gewoon ook $userfile gebruik en de ImageResize functie niet gebruik dan stopt hij dus wel gewoon 3 x een oid object in de database
maar zoals het hierboven staat dan doet hij alleen original_image erin stoppen en met de rest doet hij niks
iemand suggesties?
voor de duidelijkheid, hieronder staat het ImageResize script
als ik de onderstaande code uitvoer loopt het script vast op het stuk waar $img1 begint.
PHP:
1
2
3
4
5
6
7
8
| // dit stopt de originele foto in de database (dit gedeelte werkt) $db->UpdateBlobFile('produkt','original_image', $userfile, 'produkt_id='.$produkt_id, 'BLOB'); //waarom kun je hier niet opnieuw $userfile aanroepen $img1 = ImageResize('jpg', $userfile, 50, 50); $img2 = ImageResize('jpg', $userfile, 300, 300); $db->UpdateBlobFile('produkt','image', $img1, 'produkt_id='.$produkt_id, 'BLOB'); $db->UpdateBlobFile('produkt','image_groot', $img2, 'produkt_id='.$produkt_id, 'BLOB'); |
het vreemde is dat als ik bij de image en image_groot i.p.v. $img1 en $img2 gewoon ook $userfile gebruik en de ImageResize functie niet gebruik dan stopt hij dus wel gewoon 3 x een oid object in de database
maar zoals het hierboven staat dan doet hij alleen original_image erin stoppen en met de rest doet hij niks
iemand suggesties?
voor de duidelijkheid, hieronder staat het ImageResize script
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
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
78
79
| <?php function ImageResize($ext, $image, $maxwidth, $maxheight) { //save output to a buffer ob_start(); //Open the file to resize $Extension = strtoUpper($ext); if ( ($Extension == "JPG") || ($Extension == "JPEG") ) $srcImage = ImageCreateFromJpeg( $image ); else if ($Extension == "PNG") $srcImage = ImageCreateFromPng( $image ); else if ($Extension == "GIF") $srcImage = ImageCreateFromGif( $image ); else if ($Extension == "BMP") $srcImage = ImageCreateFromWbmp( $image ); else { echo "image type not supported<br>". "<a href=\"upload.php\">back</a>"; exit; } //obtain the original image Height and Width $srcWidth = ImageSX( $srcImage ); $srcHeight = ImageSY( $srcImage ); // the follwing portion of code checks to see if // the width > height or if width < height // if so it adjust accordingly to make sure the image // stays smaller then the $newWidth and $newHeight /*if( $srcWidth < $srcHeight ){ $destWidth = $newWidth * $srcWidth/$srcHeight; $destHeight = $newHeight; }else{ $destWidth = $newWidth; $destHeight = $newHeight * $srcHeight/$srcWidth; } */ // stay inside the bounds $destWidth = min ($maxwidth, $srcWidth); $destHeight = min ($maxheight, $srcHeight); $prop = $srcWidth / $srcHeight; if ($prop > 1) // landscape $destHeight = $srcHeight * $maxwidth / $srcWidth; elseif ($prop < 1) // portrait $destWidth = $srcWidth * $maxheight / $srcHeight; // echo "*".$maxwidth . "-". $srcWidth."*"; // exit; // imagecreate // creating the destination image with the new Width and Height $destImage = ImageCreateTrueColor( $destWidth, $destHeight); //copy the srcImage to the destImage ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); //create the image ImageJpeg( $destImage ); //fre the memory used for the images ImageDestroy( $srcImage ); ImageDestroy( $destImage ); //copy output buffer to string $resizedImage = ob_get_contents(); //clear output buffer that was saved ob_end_clean(); return $resizedImage; } ?> |
[ Voor 60% gewijzigd door Verwijderd op 22-08-2005 15:11 ]