function openImage($src){ switch( exif_imagetype($src)){ case IMAGETYPE_PNG: $img = @imagecreatefrompng($src); break; case IMAGETYPE_GIF: $img = @imagecreatefromgif($src); break; case IMAGETYPE_JPEG: $img = @imagecreatefromjpeg($src); break; case IMAGETYPE_BMP: $img = @ImageCreateFromBMP($src); break; case IMAGETYPE_PSD: $img = @imagecreatefrompsd($src);//@ break; default: $img = false; break; } return $img; }
<?php include_once '../PSDReader.php'; header("Content-type: image/jpeg"); echo imagejpeg(imagecreatefrompsd('text_transparent_bg.psd'));
<?php include_once '../PSDReader.php'; header("Content-type: image/jpeg"); echo imagejpeg(imagecreatefrompsd('monkey_bw.psd'));
private function openImage($src) { if ($this->MemoryLimit) { $this->setMemoryForImage($src, $this->TweakFactor); } switch ($this->info['contenttype'] = exif_imagetype($src)) { case IMAGETYPE_PNG: $img = imagecreatefrompng($src); break; case IMAGETYPE_GIF: $img = $this->imagecreatefrom_gif($src); break; case IMAGETYPE_JPEG: $img = @imagecreatefromjpeg($src); break; case IMAGETYPE_BMP: $img = @ImageCreateFromBMP($src); break; case IMAGETYPE_PSD: $img = @imagecreatefrompsd($src); break; // case IMAGETYPE_ICO: // $img = imagecreatefrom_ico($src); // break; // case IMAGETYPE_ICO: // $img = imagecreatefrom_ico($src); // break; default: $img = false; break; } return $img; }
<?php include_once '../PSDReader.php'; header("Content-type: image/jpeg"); echo imagejpeg(imagecreatefrompsd('basic.psd'));
/** * Method to set the image to be resized * @param string $sourceFile Path of the Image to be resized */ function setImg($sourceFile) { // Check if File Exists if (file_exists($sourceFile)) { // Get Image Type $imagetype = $this->getImageType($sourceFile); // Default set to True $this->canCreateFromSouce = TRUE; // Set Image Type to Global Variable $this->filetype = $imagetype; switch ($imagetype) { // PHP can only create thumbnails from GIF, JPG, PNG, WBMP and XBM formats // For all others, it will return a 100x100 image that says, unable to create thumbnail case 'gif': $this->image = imagecreatefromgif($sourceFile); break; case 'jpg': $this->image = imagecreatefromjpeg($sourceFile); break; case 'png': $this->image = imagecreatefrompng($sourceFile); break; case 'wbmp': $this->image = imagecreatefromwbmp($sourceFile); break; case 'xbm': $this->image = imagecreatefromxbm($sourceFile); break; case 'bmp': $this->image = ImageCreateFromBMP($sourceFile); break; case 'psd': $this->image = imagecreatefrompsd($sourceFile); break; default: // Cannot create from source $this->canCreateFromSouce = FALSE; // Create Blank Image with White Background $this->image = imagecreatetruecolor(100, 100); $bgc = imagecolorallocate($this->image, 255, 255, 255); imagefilledrectangle($this->image, 0, 0, 100, 100, $bgc); break; } } else { return FALSE; } }
private function criaImagem() { switch ($this->extensao) { case 'gif': $this->img = imagecreatefromgif($this->origem); break; case 'jpg': $this->img = imagecreatefromjpeg($this->origem); break; case 'jpeg': $this->img = imagecreatefromjpeg($this->origem); break; case 'png': $this->img = imagecreatefrompng($this->origem); break; case 'bmp': // requer util.inc.php $this->img = imagecreatefrombmp($this->origem); break; case 'psd': // requer psd_support.php include_once "format_supports/psd_support.php"; $this->img = imagecreatefrompsd($this->origem); break; case 'tiff': // requer tiff_support.php include_once "format_supports/tiff_support.php"; $this->img = imagecreatefromtiff($this->origem); break; case 'pdf': // requer pdf_support.php include_once "format_supports/pdf_support.php"; $this->img = imagecreatefrompdf($this->origem); break; } return true; }