예제 #1
0
 function image($img_url, $img_type, $x, $y, $w, $h)
 {
     //debugpng
     if (DEBUGPNG) {
         print '[image:' . $img_url . '|' . $img_type . ']';
     }
     $img_type = mb_strtolower($img_type);
     switch ($img_type) {
         case "jpeg":
         case "jpg":
             //debugpng
             if (DEBUGPNG) {
                 print '!!!jpg!!!';
             }
             $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
             break;
         case "png":
             //debugpng
             if (DEBUGPNG) {
                 print '!!!png!!!';
             }
             $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
             break;
         case "gif":
             // Convert gifs to pngs
             //DEBUG_IMG_TEMP
             //if (0) {
             if (method_exists($this->_pdf, "addImagePng")) {
                 //debugpng
                 if (DEBUGPNG) {
                     print '!!!gif addImagePng!!!';
                 }
                 //If optimization to direct png creation from gd object is available,
                 //don't create temp file, but place gd object directly into the pdf
                 if (method_exists($this->_pdf, "image_iscached") && $this->_pdf->image_iscached($img_url)) {
                     //If same image has occured already before, no need to load because
                     //duplicate will anyway be eliminated.
                     $img = null;
                 } else {
                     $img = @imagecreatefromgif($img_url);
                     if (!$img) {
                         return;
                     }
                     imageinterlace($img, 0);
                 }
                 $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
             } else {
                 //debugpng
                 if (DEBUGPNG) {
                     print '!!!gif addPngFromFile!!!';
                 }
                 $img_url = $this->_convert_gif_to_png($img_url);
                 $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
             }
             break;
         default:
             //debugpng
             if (DEBUGPNG) {
                 print '!!!unknown!!!';
             }
             break;
     }
     return;
 }