Jump to content


Searching for code

  • Please log in to reply
2 replies to this topic

#1 Wstar

  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 20 October 2006 - 06:05 PM

I've been all over the net trying to find what I need.  Everything didn't work.

I'm trying to store images in a Mysql database.
Once its store, i need to display it.  All this I can do, but.

I'm having problems resizing the image before its displayed.  Every bit of code I get that relates to resizing an image it ask for a directory where the image is located.  What is the directory if i'm storing them on database?

I'm very comfused.  If anyone has or knows where I can get the code to do this, PLEASE LET ME KNOW!

#2 jvrothjr

  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 20 October 2006 - 06:50 PM

I resize my images when they are uploaded and store both the full size and the thumbnail in the DB.
I use the thumbnail to display and once they select the thumb nail the full size is downloaded.

when the upload the file via php page there is a true file that is set to a variable and loaded into the DB just resize at that point before it is dumped to the DB

function thumb_jpeg($image_name,$source_path,$destination_path){
//Create Thumbnail
    $new_width=150;  //Image width Change if needed
    $new_height=150;  //Image height Change if needed
    $destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image");
    $srcimg=ImageCreateFromjpeg($source_path.$image_name) or die("Problem In opening Source Image");
    ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing");
    Imagejpeg($destimg,$destination_path.$image_name) or die("Problem In saving");

If you understand everything you know nothing!


#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 October 2006 - 08:10 PM

If you're storing them in the DB, which is a questionable practice, then there is no "path"... you need to serve this images directly.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users