24. maj 2009 - 21:02Der er
5 kommentarer og 1 løsning
Resize picture
Har fået denne kode, men der sker ingen ting. Jeg for ingen fejl koder, eller noget som tyder på noget forkert. Men der kommer heller ikke noget billed:
$mappe = billed/mave/ $newfilename = ugeXX_1.jpg Mappe/Filnavn efter udførelse: "billed/mave/ugeXX_1b.jpg"
function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual) {
/* Get the dimensions of the source picture */ $picsize=getimagesize("$sourcefile"); $source_x = $picsize[0]; $source_y = $picsize[1]; $source_id = imageCreateFromJPEG("$sourcefile");
/* Create a new image object (not neccessarily true colour) */ $target_id=imagecreatetruecolor($dest_x, $dest_y);
/* Resize the original picture and copy it into the just created image object. Because of the lack of space I had to wrap the parameters to several lines. I recommend putting them in one line in order keep your code clean and readable */ $target_pic=imagecopyresampled($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
/* Create a jpeg with the quality of "$jpegqual" out of the image object "$target_pic". This will be saved as $targetfile */ imagejpeg ($target_id,"$targetfile",$jpegqual); return true; } ?>
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
Slettet bruger
26. maj 2009 - 19:56#1
Der var et par "stavefejl", men ellers er koden helt fin. Her kommer en rettet version:
function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual) {
/* Get the dimensions of the source picture */ $picsize=getimagesize("$sourcefile"); $source_x = $picsize[0]; $source_y = $picsize[1]; $source_id = imageCreateFromJPEG("$sourcefile");
/* Create a new image object (not neccessarily true colour) */ $target_id=imagecreatetruecolor($dest_x, $dest_y);
/* Resize the original picture and copy it into the just created image object. Because of the lack of space I had to wrap the parameters to several lines. I recommend putting them in one line in order keep your code clean and readable */ $target_pic=imagecopyresampled($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
/* Create a jpeg with the quality of "$jpegqual" out of the image object "$target_pic". This will be saved as $targetfile */ imagejpeg ($target_id,"$targetfile",$jpegqual); return true; }
Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 12288 bytes) in /customers/tbf-web.dk/tbf-web.dk/httpd.www/billed/maveresize_b.php on line 15
Jeg er glad for at du har fået det til at virke. Tilykke med det.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.