Jump to content

PHP/Mysql image problem

- - - - -

  • Please log in to reply
1 reply to this topic

#1
evas

evas

    Newbie

  • Members
  • Pip
  • 1 posts
hello there! This is quite big so i get onto it right away :cool: i want to check how many images are stored in my mysql table and put a small thumbnail of each one to my page(and get it normal size when i click on to it),plus some info about it (date added) and a button which when i click it i would pop up a window with comments on it.
how to make the thumbnails of my picture ? thnx in advanceAttached File  Untitled-1.png   185.75K   45 downloads

#2
da beast

da beast

    Newbie

  • Members
  • PipPip
  • 25 posts
Uses the PHP GD2 library

function make_thumb($src,$dest,$desired_width)

{


  /* read the source image */

  $source_image = imagecreatefromjpeg($src);

  $width = imagesx($source_image);

  $height = imagesy($source_image);

  

  /* find the "desired height" of this thumbnail, relative to the desired width  */

  $desired_height = floor($height*($desired_width/$width));

  

  /* create a new, "virtual" image */

  $virtual_image = imagecreatetruecolor($desired_width,$desired_height);

  

  /* copy source image at a resized size */

  imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);

  

  /* create the physical thumbnail image to its destination */

  imagejpeg($virtual_image,$dest);

}





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users