Announcement

Collapse
No announcement yet.

PHP and GD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP and GD

    How would one use the built in image functions in PHP to create a thumb with GD? I'd like to create thumbs from attached images with the tn_ prefix so I could insert them in database for easy retrieval.

  • #2
    I don't think that is possible, but I could be wrong!
    I solved this problem by using a command line image manipulator like ImageMagik.
    If you need some examples how to use it, just tell me.

    Comment


    • #3
      I have imagemagick installed, but someone told me that was not possible to do. How did you do it with imagemagick, create a thumb from attachment?

      Comment


      • #4
        That's easy:

        PHP Code:
        system($imgmagickpath."mogrify.exe -geometry 160x160 -quality 90 ".$uplfile['tmp_name']); 
        You can specify a filename after the tempfilename to create a new file, but if you want to insert it into a DB you might just want to read the file into DB, then transform it and just read it in again.

        Comment


        • #5
          let us try something else

          the attachment is inserted in database. How can I also save it in a folder as postid.jpg?

          Comment


          • #6
            The Uploaded file is at first stored as a file, so you just copy it and rename it.

            Comment


            • #7
              Here's a clip from my own image index page that I wrote. It's not from vBulletin, but it gives you a start on how to do it.
              PHP Code:
                 $imagelist GetFileList();
                 while ( list(
              $i,$image) = each ($imagelist) )
                 {
                     
              // Check the thumb exists
                     
              if (!file_exists($thumb_dir."/".$image) )
                     {
                         
              $im ImageCreateFromJPEG($image);
                         
              $width  ImageSX($im);
                         
              $height ImageSY($im);
                         
              $thumb_width = ($thumb_height $height) * $width;
                         
              $im2 ImageCreate($thumb_width,$thumb_height);
                         
              ImageCopyResized($im2,$im,0,0,0,0,$thumb_width,$thumb_height,$width,$height);
                         
              ImageJpeg($im2$thumb_dir."/".$image80);
                     }
                    
              $image CleanFilename($image);
                 } 
              You can see how the thumbs turnout.
              http://www.higginstribe.com/gallery/devin-2002-03-03/
              Mark Higgins

              Comment

              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
              Working...
              X