Please i need help with this code

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

    Please i need help with this code

    Hi everyone, i need help with this sniplet.

    did a lot of modding etc, just can't get my head around resizing the images.
    Got them to output successfully.

    Please help me in resizing pics?

    $height = "100"; //pixels
    $width = "100"; //pixels

    Code:
    <?php
    include("../includes/connect.php");
    /*** some basic sanity checks ***/
    if(filter_has_var(INPUT_GET, "image_id") !== false && filter_input(INPUT_GET, 'image_id', FILTER_VALIDATE_INT) !== false)
        {
        /*** assign the image id ***/
        $image_id = filter_input(INPUT_GET, "image_id", FILTER_SANITIZE_NUMBER_INT);
        try     {
            /*** connect to the database ***/
            $dbh = new PDO("mysql:host=".$dbhost.";dbname=".$dbname."", "".$dbuser."", "".$dbpass."");
    
            /*** set the PDO error mode to exception ***/
            $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
            /*** The sql statement ***/
            $sql = "SELECT image, image_type FROM products WHERE serial=$image_id";
    
            /*** prepare the sql ***/
            $stmt = $dbh->prepare($sql);
    
            /*** exceute the query ***/
            $stmt->execute(); 
    
            /*** set the fetch mode to associative array ***/
            $stmt->setFetchMode(PDO::FETCH_ASSOC);
    
            /*** set the header for the image ***/
            $array = $stmt->fetch();
    
            /*** check we have a single image and type ***/
            if(sizeof($array) == 2)
                {
                /*** set the headers and display the image ***/
                header("Content-type: ".$array['image_type']);
    
                /*** output the image ***/
                echo $array['image'];
                }
            else
                {
                throw new Exception("<img src=\"../images/demo.png\">");
                }
            }
        catch(PDOException $e)
            {
            echo $e->getMessage();
            }
        catch(Exception $e)
            {
            echo $e->getMessage();
            }
            }
      else
            {
            echo '<img src="../images/demo.png">';
            }
    ?>

    #2
    Consider using this class. http://www.mywebmymail.com/?q=conten...humbnail-class

    Im using it for awhile now for pretty much anything with images.
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    Comment


      #3
      Originally posted by arnage View Post
      Consider using this class. http://www.mywebmymail.com/?q=conten...humbnail-class

      Im using it for awhile now for pretty much anything with images.
      +1

      ........

      Comment


        #4
        Im even using single thumb file for multiple galleries.

        PHP Code:
        <?php

        if (isset($_GET['thumb'], $_GET['gallery'])) {

            
        $dir str_replace(chr(92), chr(47), getcwd()) . '/gallery/' $_GET['gallery'] . '/';

            if (
        is_dir($dir)) {

                include_once(
        'system/easyphpthumbnail.class.php');

                
        $thumb = new easyphpthumbnail;

                if (
        $_GET['gallery'] == 'amsterdam') {

                    
        $thumb -> Thumbwidth 710;
                    
        $thumb -> Thumbheight 470;
                    
        $thumb -> Framewidth 3;
                    
        $thumb -> Framecolor '#FFFFFF';
                    
        $thumb -> Backgroundcolor '#D0DEEE';
                    
        $thumb -> Shadow true;
                    
        $thumb -> Copyrighttext 'Amsterdam';
                    
        $thumb -> Copyrightposition '50% 90%';
                    
        $thumb -> Copyrightfonttype 'fonts/amsfont.ttf';
                    
        $thumb -> Copyrightfontsize 20;
                    
        $thumb -> Copyrighttextcolor '#FFFFFF';

                } elseif (
        $_GET['gallery'] == 'dekoracijezasvadbe') {

                    
        $thumb -> Thumbsize 200;
                    
        $thumb -> Clipcorner = array(2,15,0,0,1,1,0);

                } elseif (
        $_GET['gallery'] == '4zoom-clubbing/photos') {

                    
        $thumb -> Thumbwidth 243;
                    
        $thumb -> Thumbheight 150;
                    
        $thumb -> Framewidth 2;
                    
        $thumb -> Framecolor '#FFFFFF';
                    
        $thumb -> Backgroundcolor '#D0DEEE';
                    
        $thumb -> Shadow true;

                } elseif (
        $_GET['gallery'] == 'jela') {

                    
        $thumb -> Thumbwidth 490;
                    
        $thumb -> Thumbheight 440;
                    
        $thumb -> Shadow true;

                }

                
        $thumb -> Createthumb($dir basename($_GET['thumb']));

            } else exit;

        }

        ?>
        <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

        Comment


          #5
          Thank you.
          I will give it a try.

          Comment


            #6
            You are welcome.
            If you need help with it feel free to ask in the topic... http://coding-talk.com/forum/main-fo...humbnail-class
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment

            Working...
            X