Mike42\Escpos\EscposImage::loadImageData PHP Method

loadImageData() protected method

Load an image from disk. This default implementation always gives a zero-sized image.
protected loadImageData ( string $filename = null )
$filename string Filename to load from.
    protected function loadImageData($filename = null)
    {
        // Load image in to string of 1's and 0's, also set width & height
        $this->setImgWidth(0);
        $this->setImgHeight(0);
        $this->setImgData("");
    }

Usage Example

Beispiel #1
0
 /**
  * Load an image from disk, into memory, using GD.
  *
  * @param string $filename The filename to load from
  * @throws Exception if the image format is not supported,
  *  or the file cannot be opened.
  */
 protected function loadImageData($filename = null)
 {
     if ($filename === null) {
         /* Set to blank image */
         return parent::loadImageData($filename);
     }
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     switch ($ext) {
         case "png":
             $im = @imagecreatefrompng($filename);
             break;
         case "jpg":
             $im = @imagecreatefromjpeg($filename);
             break;
         case "gif":
             $im = @imagecreatefromgif($filename);
             break;
         default:
             throw new Exception("Image format not supported in GD");
     }
     $this->readImageFromGdResource($im);
 }
All Usage Examples Of Mike42\Escpos\EscposImage::loadImageData