18. april 2010 - 20:15
Der er
7 kommentarer og
1 løsning
Resize class
hej har fået fat i denne kode:
function createT_img($imgName, $sou, $mappen) {
//resize image to put it into db
$imagename = $imgName;
$source = $sou; //$_FILES['img1']['tmp_name'];
$target = $mappen."/".$imagename;
$map = $mappen;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = $mappen ."/sml/". $imagepath; //This is the new file you saving
$file = $mappen ."/". $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 200;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
return $imagepath;
}
denne køre meget fint, men mit problem er at jeg og vil have en trejde thumb... udover den med 200 width??? hvordan gør jeg det ?
18. april 2010 - 20:19
#1
Kopier denne her ind
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
Som
function createT_img($imgName, $sou, $mappen) {
//resize image to put it into db
$imagename = $imgName;
$source = $sou; //$_FILES['img1']['tmp_name'];
$target = $mappen."/".$imagename;
$map = $mappen;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = $mappen ."/sml/". $imagepath; //This is the new file you saving
$file = $mappen ."/". $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 200;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
return $imagepath;
}
18. april 2010 - 20:20
#2
DOH
Det vil bare overskrive den samme image med en 400px en istedet...
Take 2 nedenfor
18. april 2010 - 20:22
#3
function createT_img($imgName, $sou, $mappen) {
//resize image to put it into db
$imagename = $imgName;
$source = $sou; //$_FILES['img1']['tmp_name'];
$target = $mappen."/".$imagename;
$map = $mappen;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = $mappen ."/sml/". $imagepath; //This is the new file you saving
$file = $mappen ."/". $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 200;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save2 = $mappen ."/sml/400_". $imagepath; //This is the new file you saving
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save2, 100) ;
return $imagepath;
}
18. april 2010 - 20:24
#4
Nu du må du fandme spænde hjelmen! Det er det tredie spørgsmål du opretter om præcist det samme (
http://www.eksperten.dk/spm/906917 samt
http://www.eksperten.dk/spm/907324 ), uden at følge dine spørgsmål til dørs! Ikke alene er det et brud på de regler du har accepteret da du oprettede dig som bruger - det er også at pisse på de brugere som allerede har forsøgt at hjælpe dig herinde at du ignorerer deres bestræbelser!
18. april 2010 - 20:25
#5
Har sat dette ind:
$save2 = $mappen ."/sml/400_". $imagepath; //This is the new file you saving
$modwidth = 400;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save2, 100) ;
18. april 2010 - 20:44
#6
Repox - du har ikke forsøgt at hjælpe en skid, det eneste du har kommet med er de bla bla bla regler du snakker om, bare sige du ikke kan hjælpe og det er nok, og Mange tak til The_buzz for hjælpen.
18. april 2010 - 20:47
#7
omfg... du missede hele pointen..
18. april 2010 - 21:36
#8
<ole>
okidoky >> Hvad er det, der er så kompliceret for dig at forstå? Umiddelbart kunne det tyde på, det er det sociale aspekt i et forum som dette, du har vanskeligt ved at håndtere(?)
/mvh
</bole>
Vi tilbyder markedets bedste kurser inden for webudvikling