Example #1
0
 /**
  * Returns a {@link \ZendPdf\Resource\Image\AbstractImage} object by file path.
  *
  * @param string $filePath Full path to the image file.
  * @return \ZendPdf\Resource\Image\AbstractImage
  * @throws \ZendPdf\Exception\ExceptionInterface
  */
 public static function imageWithPath($filePath)
 {
     /**
      * use old implementation
      * @todo switch to new implementation
      */
     return Resource\Image\ImageFactory::factory($filePath);
     /* Create a file parser data source object for this file. File path and
      * access permission checks are handled here.
      */
     $dataSource = new BinaryParser\DataSource\File($filePath);
     /* Attempt to determine the type of image. We can't always trust file
      * extensions, but try that first since it's fastest.
      */
     $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     /* If it turns out that the file is named improperly and we guess the
      * wrong type, we'll get null instead of an image object.
      */
     switch ($fileExtension) {
         case 'tif':
             //Fall through to next case;
         //Fall through to next case;
         case 'tiff':
             $image = self::_extractTiffImage($dataSource);
             break;
         case 'png':
             $image = self::_extractPngImage($dataSource);
             break;
         case 'jpg':
             //Fall through to next case;
         //Fall through to next case;
         case 'jpe':
             //Fall through to next case;
         //Fall through to next case;
         case 'jpeg':
             $image = self::_extractJpegImage($dataSource);
             break;
         default:
             throw new Exception\DomainException('Cannot create image resource. File extension not known or unsupported type.');
             break;
     }
     /* Done with the data source object.
      */
     $dataSource = null;
     if ($image !== null) {
         return $image;
     } else {
         /* The type of image could not be determined. Give up.
          */
         throw new Exception\DomainException("Cannot determine image type: {$filePath}");
     }
 }
/**
 * gets an image resource
 * 
 * @param PDF $pdf
 * @param string $imagetype
 * @param string $filename
 * @param string $stringparam
 * @param integer $intparam
 * @return AbstractImage
 */
function PDF_open_image_file(PDF $pdf, $imagetype, $filename, $stringparam = null, $intparam = 0)
{
    return ImageFactory::factory($filename);
}