phpDocumentor VFront
[ class tree: VFront ] [ index: VFront ] [ all elements ]

Source for file thumb.php

Documentation is available at thumb.php

  1. <?php
  2. /**
  3. * Genera i thumbnail (diapositive) per le immagini allegate.
  4. * Viene richiamato dal file {@link add.attach.php}
  5. @package VFront
  6. @author Mario Marcello Verona <marcelloverona@gmail.com>
  7. @copyright 2007 Mario Marcello Verona
  8. @version 0.90
  9. @license http://www.gnu.org/licenses/gpl.html GNU Public License
  10. */
  11.  
  12. require("./inc/conn.php");
  13.  
  14.  
  15. function printThumbnail($imgfile,$max_width=100,$max_height=100{
  16.        list($org_width,$org_height,$orgtypegetimagesize($imgfile);
  17.        $div_width $org_width $max_width;
  18.        $div_height $org_height $max_height;
  19.        if($div_width >= $div_height{
  20.            $new_width $max_width;
  21.            $new_height round($org_height $div_width);
  22.        }
  23.        else {
  24.            $new_height $max_height;
  25.            $new_width round($org_width $div_height);
  26.        }
  27.        switch($orgtype{
  28.            case 1$im imagecreatefromgif($imgfile)break;
  29.            case 2$im imagecreatefromjpeg($imgfile)break;
  30.            case 3$im imagecreatefrompng($imgfile)break;
  31.        }
  32.        if($im{
  33.            $tn imagecreatetruecolor($new_width,$new_height);
  34.            if($tn{
  35.                imagecopyresized($tn,$im,0,0,0,0,$new_width,$new_height,$org_width,$org_height);
  36.                switch($orgtype{
  37.                    case 1header("Content-Type: image/gif")imagegif($tn)break;
  38.                    case 2header("Content-Type: image/jpeg")imagejpeg($tn)break;
  39.                    case 3header("Content-Type: image/png")imagepng($tn)break;
  40.                }
  41.                imagedestroy($tn);
  42.            }
  43.        }
  44.    }
  45.    
  46.     
  47.    
  48.    $ID = (int) $_GET['id'];
  49.    
  50.    $IMG=_PATH_ATTACHMENT."/$ID.dat";
  51.    
  52.    if(is_file($IMG)){
  53.            printThumbnail($IMG,150,150);
  54.    }
  55.    
  56. ?>

Documentation generated on Sat, 22 Sep 2007 11:51:34 +0200 by phpDocumentor 1.4.0a2