thumbnails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

thumbnails

Post 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]
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Why not store the image on disk and insert the filename into the database... it will be MUCH quicker to access...
corillo181
Forum Commoner
Posts: 76
Joined: Wed Apr 26, 2006 3:02 pm

Post 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..
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

use either the $filename variable, or wherever 'jhon.jpg' comes from - not sure which is the desired final image name.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply