Page 1 of 1

thumbnails

Posted: Sun Nov 26, 2006 3:07 pm
by corillo181
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php
// The file name you wish to get
$filename = 'images/pic.jpg';

// Content type
header('Content-type: image/jpeg');

//takes the with and height of file
list($width, $height) = getimagesize($filename);

$newWidth=120;

$newHeight=intval($height*$newWidth/$width);

$oldImage=ImageCreateFromJPEG("$filename");

$newImage=ImageCreateTrueColor($newWidth,$newHeight);

imagecopyresampled($newImage,$oldImage,0,0,0,0,$newWidth,$newHeight,$width,$height);

ImageJPEG($newImage,"TN"."jhon.jpg");
?>
i got this code, but i would like to know how can i make this so i can put it on mysql..


becuase the imageJPEG() function saves the picture and makes the picture show on the page i just want to keep the picture in a variable so i can insert it in the sql table i got set up..

if you need a better explanation please let me know..


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Nov 26, 2006 3:43 pm
by nickvd
Why not store the image on disk and insert the filename into the database... it will be MUCH quicker to access...

Posted: Sun Nov 26, 2006 4:05 pm
by corillo181
i know.. but i neeed to save the name into mysql so i cna link it to the bigger picture...

i dont want to save the actual picture in mysql i know about that..

just how do i take the name as a variable out of that code..

Posted: Mon Nov 27, 2006 10:38 am
by pickle
use either the $filename variable, or wherever 'jhon.jpg' comes from - not sure which is the desired final image name.