コード例 #1
0
 function setImage($image, $imageType = '')
 {
     $this->setImageInfo($image);
     if ($this->imageType == 'unknown') {
         $this->imageType = $imageType;
         if (empty($this->imageType) || $this->imageType == 'unknown') {
             die("Specify imageType to scale from");
         }
     }
     if ($this->imageType == 'gif') {
         $this->image = imagecreatefromgif($image);
     } else {
         if ($this->imageType == 'jpg' || $this->imageType == 'jpeg') {
             $this->image = imagecreatefromjpeg($image);
         } else {
             if ($this->imageType == 'png') {
                 $this->image = imagecreatefrompng($image);
             } else {
                 if ($this->imageType == 'gd') {
                     $this->image = imagecreatefromgd($image);
                 } else {
                     die("Unsupported source image type: {$imageType}");
                 }
             }
         }
     }
 }
コード例 #2
0
 /**
  * Read image via imagecreatefromgd()
  *
  * @param   string uri
  * @return  resource
  * @throws  img.ImagingException
  */
 protected function readImage0($uri)
 {
     if (FALSE === ($r = imagecreatefromgd($uri))) {
         $e = new ImagingException('Cannot read image');
         xp::gc(__FILE__);
         throw $e;
     }
     return $r;
 }
コード例 #3
0
 /**
  * Read image
  *
  * @param   string uri
  * @return  resource
  * @throws  img.ImagingException
  */
 public function readImageFromUri($uri)
 {
     if (FALSE === ($r = imagecreatefromgd($uri))) {
         $e = new ImagingException('Cannot read image from "' . $uri . '"');
         xp::gc(__FILE__);
         throw $e;
     }
     return $r;
 }
コード例 #4
0
ファイル: Img.php プロジェクト: bpteam/php-ocr
 protected static function openUnknown($img)
 {
     if ($tmpImg2 = imagecreatefromstring($img)) {
         $wight = imagesx($tmpImg2);
         $height = imagesy($tmpImg2);
         $tmpImg = imagecreatetruecolor($wight, $height);
         $white = imagecolorallocate($tmpImg, 255, 255, 255);
         imagefill($tmpImg, 0, 0, $white);
         imagecopy($tmpImg, $tmpImg2, 0, 0, 0, 0, $wight, $height);
         imagedestroy($tmpImg2);
     } else {
         $tmpImg = imagecreatefromgd($img);
     }
     return $tmpImg;
 }
コード例 #5
0
ファイル: imgtools_class.php プロジェクト: rosko/Tempo-CMS
 public function loadImage($file)
 {
     /*
     	Open the image and create the resource
     */
     // Check if the GD extension is loaded
     if (!extension_loaded('gd')) {
         if (!dl('gd.' . PHP_SHLIB_SUFFIX)) {
             $this->lastError = 'GD is not loaded';
             return false;
         }
     }
     if (is_string($file) === true && is_file($file) === true && file_exists($file) === true && is_readable($file) === true) {
         $file = realpath($file);
         $imgSize = getimagesize($file);
         if ($imgSize !== false) {
             // Get the image from file
             if ($imgSize['mime'] === 'image/jpeg') {
                 $resource = imagecreatefromjpeg($file);
             } else {
                 if ($imgSize['mime'] === 'image/gif') {
                     $resource = imagecreatefromgif($file);
                 } else {
                     if ($imgSize['mime'] === 'image/png') {
                         $resource = imagecreatefrompng($file);
                     } else {
                         if ($imgSize['mime'] === 'image/bmp') {
                             $resource = imagecreatefromgd($file);
                         } else {
                             $this->lastError = 'Not supported format to load';
                             return false;
                         }
                     }
                 }
             }
             $this->imgResource = $resource;
             $this->imgFile = $file;
             $this->imgSize = $imgSize;
             $this->ready = true;
             return true;
         }
         $this->lastError = 'File is not image';
         return false;
     }
     $this->lastError = 'File load problem (not exist/not file/not readable)';
     return false;
 }
コード例 #6
0
ファイル: File.php プロジェクト: gtyd/jira
 /**
  * 根据原始文件的扩展名,返回从原始文件创建的一个画布
  * @return resource 返回从原始文件取得的一个图像
  */
 private function _from()
 {
     switch ($this->src_img_ext) {
         case "gd2":
             return imagecreatefromgd2($this->src_img);
         case "gd":
             return imagecreatefromgd($this->src_img);
         case "gif":
             return imagecreatefromgif($this->src_img);
         case "jpeg":
             return imagecreatefromjpeg($this->src_img);
         case "jpg":
             return imagecreatefromjpeg($this->src_img);
         case "png":
             return imagecreatefrompng($this->src_img);
         default:
             return FALSE;
     }
 }
コード例 #7
0
function open_image($file)
{
    $im = @imagecreatefromjpeg($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgif($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefrompng($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgd($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromgd2($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromwbmp($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromxbm($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromxpm($file);
    if ($im !== false) {
        return $im;
    }
    $im = @imagecreatefromstring(file_get_contents($file));
    if ($im !== false) {
        return $im;
    }
    return false;
}
コード例 #8
0
ファイル: GDImage.php プロジェクト: vulcandth/steamprofile
 public function loadGD($sFile)
 {
     $this->rImage = imagecreatefromgd($sFile);
 }
コード例 #9
0
ファイル: bmp_converter.php プロジェクト: bmad4ever/LTW
function imagecreatefrombmp($filename)
{
    $tmp_name = tempnam("/tmp", "GD");
    if (ConvertBMP2GD($filename, $tmp_name)) {
        $img = imagecreatefromgd($tmp_name);
        unlink($tmp_name);
        return $img;
    }
    return false;
}
コード例 #10
0
     $n = count($exts) - 1;
     $suffix = $exts[$n];
 }
 //print "suffix: '$suffix'<br />";
 mysqltest();
 if ($suffix == "jpeg" || $suffix == "jpg" || $suffix == "jif" || $suffix == "jpe") {
     $im = @imagecreatefromjpeg($localtempfile);
 } else {
     if ($suffix == "png") {
         $im = @imagecreatefrompng($localtempfile);
     } else {
         if ($suffix == "gif") {
             $im = @imagecreatefromgif($localtempfile);
         } else {
             if ($suffix == "gd") {
                 $im = @imagecreatefromgd($localtempfile);
             } else {
                 if ($suffix == "gd2") {
                     $im = @imagecreatefromgd2($localtempfile);
                 } else {
                     if ($suffix == "wbmp") {
                         $im = @imagecreatefromwbmp($localtempfile);
                     }
                 }
             }
         }
     }
 }
 mysqltest();
 if (!$im) {
     $output = "." . $thumb_folder . "/dummy.png";
コード例 #11
0
ファイル: incResize.php プロジェクト: voguegroup/moxhullmc
 function imagecreatefrombmp($filename)
 {
     //Create image from BMP
     $this->debug("Execute function: <b>imagecreatefrombmp</b><br/>");
     $tmp_name = tempnam("/tmp", "GD");
     $this->debug("Filename: <b>" . $filename . "</b><br/>");
     $this->debug("Tempfilename: <b>" . $tmp_name . "</b><br/>");
     if ($this->ConvertBMP2GD($filename, $tmp_name)) {
         $img = imagecreatefromgd($tmp_name);
         unlink($tmp_name);
         $this->debug("ConvertBMP2GD successful execution");
         return $img;
     }
     $this->debug("<font color=\"#FF0000\"><b>ConvertBMP2GD</b></font> failed!");
     return false;
 }
コード例 #12
0
ファイル: ImageTile.php プロジェクト: neymanna/fusionforge
     if (function_exists("imagecreatefromxbm")) {
         $img = @imagecreatefromxbm($file);
     } else {
         show_plain($file);
     }
     break;
 case 'xpm':
     if (function_exists("imagecreatefromxpm")) {
         $img = @imagecreatefromxpm($file);
     } else {
         show_plain($file);
     }
     break;
 case 'gd':
     if (function_exists("imagecreatefromgd")) {
         $img = @imagecreatefromgd($file);
     } else {
         show_plain($file);
     }
     break;
 case 'gd2':
     if (function_exists("imagecreatefromgd2")) {
         $img = @imagecreatefromgd2($file);
     } else {
         show_plain($file);
     }
     break;
 default:
     //we are not stupid...
     header("Content-type: text/html");
     echo "<html><head></head><body>Not an image</body></html>";
コード例 #13
0
ファイル: jpg2gd.php プロジェクト: badlamer/hhvm
<?php

$cwd = dirname(__FILE__);
echo "JPEG to GD1 conversion: ";
echo imagegd(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd1") ? 'ok' : 'failed';
echo "\n";
echo "JPEG to GD2 conversion: ";
echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd2") ? 'ok' : 'failed';
echo "\n";
echo "GD1 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed';
echo "\n";
echo "GD2 to JPEG conversion: ";
echo imagejpeg(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed';
echo "\n";
@unlink($cwd . "/test.gd1");
@unlink($cwd . "/test.gd2");
@unlink($cwd . "/test_gd1.jpeg");
@unlink($cwd . "/test_gd2.jpeg");
コード例 #14
0
ファイル: Gd.php プロジェクト: 3116246/haolinju
 private function load($path, $type)
 {
     $image = null;
     // jpeg
     if (function_exists('imagecreatefromjpeg') && ($type == 'image/jpg' || $type == 'image/jpeg' || $type == 'image/pjpeg')) {
         $image = @imagecreatefromjpeg($path);
         if ($image !== false) {
             return $image;
         }
     }
     // png
     if (function_exists('imagecreatefrompng') && ($type == 'image/png' || $type == 'image/x-png')) {
         $image = @imagecreatefrompng($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gif
     if (function_exists('imagecreatefromgif') && $type == 'image/gif') {
         $image = @imagecreatefromgif($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gd
     if (function_exists('imagecreatefromgd')) {
         $image = imagecreatefromgd($path);
         if ($image !== false) {
             return $image;
         }
     }
     // gd2
     if (function_exists('imagecreatefromgd2')) {
         $image = @imagecreatefromgd2($path);
         if ($image !== false) {
             return $image;
         }
     }
     // bmp
     if (function_exists('imagecreatefromwbmp')) {
         $image = @imagecreatefromwbmp($path);
         if ($image !== false) {
             return $image;
         }
     }
     return $image;
 }
コード例 #15
0
ファイル: avatar.php プロジェクト: bizanto/Hooked
 /**
  * Open image file
  */
 function _openImage($file)
 {
     # JPEG:
     $im = @imagecreatefromjpeg($file);
     if ($im !== false) {
         return $im;
     }
     # GIF:
     $im = @imagecreatefromgif($file);
     if ($im !== false) {
         return $im;
     }
     # PNG:
     $im = @imagecreatefrompng($file);
     if ($im !== false) {
         return $im;
     }
     # GD File:
     $im = @imagecreatefromgd($file);
     if ($im !== false) {
         return $im;
     }
     # GD2 File:
     $im = @imagecreatefromgd2($file);
     if ($im !== false) {
         return $im;
     }
     # WBMP:
     $im = @imagecreatefromwbmp($file);
     if ($im !== false) {
         return $im;
     }
     # XBM:
     $im = @imagecreatefromxbm($file);
     if ($im !== false) {
         return $im;
     }
     # XPM:
     $im = @imagecreatefromxpm($file);
     if ($im !== false) {
         return $im;
     }
     # Try and load from string:
     $im = @imagecreatefromstring(file_get_contents($file));
     if ($im !== false) {
         return $im;
     }
 }
コード例 #16
0
ファイル: crafted_gd2.php プロジェクト: badlamer/hhvm
<?php

imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2');
コード例 #17
0
ファイル: eden.php プロジェクト: rafamaxber/Arkay-sync
if(!class_exists('Eden_Image')){class Eden_Image extends Eden_Class{protected $_resource=NULL;protected $_width=0;protected $_height=0;public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($data,$type=NULL,$path=true,$quality=75){Eden_Image_Error::i()->argument(1,'string')->argument(2,'string','null')->argument(3,'bool')->argument(4,'int');$this->_type=$type;$this->_quality=$quality;$this->_resource=$this->_getResource($data,$path);list($this->_width,$this->_height)=$this->getDimensions();}public function __destruct(){if($this->_resource){imagedestroy($this->_resource);}}public function __toString(){ob_start();switch($this->_type){case 'gif': imagegif($this->_resource);break;case 'png': $quality=(100 - $this->_quality) / 10;if($quality > 9){$quality=9;}imagepng($this->_resource,NULL,$quality);break;case 'bmp': case 'wbmp': imagewbmp($this->_resource,NULL,$this->_quality);break;case 'jpg': case 'jpeg': case 'pjpeg': default: imagejpeg($this->_resource,NULL,$this->_quality);break;}return ob_get_clean();}public function blur(){imagefilter($this->_resource,IMG_FILTER_SELECTIVE_BLUR);return $this;}public function brightness($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_BRIGHTNESS,$level);return $this;}public function colorize($red,$blue,$green,$alpha=0){Eden_Image_Error::i()->argument(1,'numeric')->argument(2,'numeric')->argument(3,'numeric')->argument(4,'numeric');imagefilter($this->_resource,IMG_FILTER_COLORIZE,$red,$blue,$green,$alpha);return $this;}public function contrast($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_CONTRAST,$level);return $this;}public function crop($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$crop=imagecreatetruecolor($width,$height);$xPosition=0;$yPosition=0;if($width > $orgWidth || $height > $orgHeight){$newWidth=$width;$newHeight=$height;if($height > $width){$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);if($newHeight > $height){$height=$newHeight;$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);$rWidth=$this->_getWidthAspectRatio($newWidth,$newHeight,$orgHeight);$xPosition=($orgWidth / 2) - ($rWidth / 2);}else{$rHeight=$this->_getHeightAspectRatio($newWidth,$newHeight,$orgWidth);$yPosition=($orgHeight / 2) - ($rHeight / 2);}}else{$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);if($newWidth > $width){$width=$newWidth;$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);$rHeight=$this->_getHeightAspectRatio($newWidth,$newHeight,$orgWidth);$yPosition=($orgHeight / 2) - ($rHeight / 2);}else{$rWidth=$this->_getWidthAspectRatio($newWidth,$newHeight,$orgHeight);$xPosition=($orgWidth / 2) - ($rWidth / 2);}}}else{if($width < $orgWidth){$xPosition=($orgWidth / 2) - ($width / 2);$width=$orgWidth;}if($height < $orgHeight){$yPosition=($orgHeight / 2) - ($height / 2);$height=$orgHeight;}}imagecopyresampled($crop,$this->_resource,0,0,$xPosition,$yPosition,$width,$height,$orgWidth,$orgHeight);imagedestroy($this->_resource);$this->_resource=$crop;return $this;}public function edgedetect(){imagefilter($this->_resource,IMG_FILTER_EDGEDETECT);return $this;}public function emboss(){imagefilter($this->_resource,IMG_FILTER_EMBOSS);return $this;}public function gaussianBlur(){imagefilter($this->_resource,IMG_FILTER_GAUSSIAN_BLUR);return $this;}public function getDimensions(){return array(imagesx($this->_resource),imagesy($this->_resource));}public function getResource(){return $this->_resource;}public function greyscale(){imagefilter($this->_resource,IMG_FILTER_GRAYSCALE);return $this;}public function invert($vertical=false){Eden_Image_Error::i()->argument(1,'bool');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);$invert=imagecreatetruecolor($orgWidth,$orgHeight);if($vertical){imagecopyresampled($invert,$this->_resource,0,0,0,($orgHeight-1),$orgWidth,$orgHeight,$orgWidth,0-$orgHeight);}else{imagecopyresampled($invert,$this->_resource,0,0,($orgWidth-1),0,$orgWidth,$orgHeight,0-$orgWidth,$orgHeight);}imagedestroy($this->_resource);$this->_resource=$invert;return $this;}public function meanRemoval(){imagefilter($this->_resource,IMG_FILTER_MEAN_REMOVAL);return $this;}public function negative(){imagefilter($this->_resource,IMG_FILTER_NEGATE);return $this;}public function resize($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$newWidth=$width;$newHeight=$height;if($height < $width){$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);if($newWidth < $width){$width=$newWidth;$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);}}else{$height=$this->_getHeightAspectRatio($orgWidth,$orgHeight,$width);if($newHeight < $height){$height=$newHeight;$width=$this->_getWidthAspectRatio($orgWidth,$orgHeight,$height);}}return $this->scale($width,$height);}public function rotate($degree,$background=0){Eden_Image_Error::i()->argument(1,'numeric')->argument(2,'numeric');$rotate=imagerotate($this->_resource,$degree,$background);imagedestroy($this->_resource);$this->_resource=$rotate;return $this;}public function scale($width=NULL,$height=NULL){Eden_Image_Error::i()->argument(1,'numeric','null')->argument(2,'numeric','null');$orgWidth=imagesx($this->_resource);$orgHeight=imagesy($this->_resource);if(is_null($width)){$width=$orgWidth;}if(is_null($height)){$height=$orgHeight;}if($width==$orgWidth && $height==$orgHeight){return $this;}$scale=imagecreatetruecolor($width,$height);imagecopyresampled($scale,$this->_resource,0,0,0,0,$width,$height,$orgWidth,$orgHeight);imagedestroy($this->_resource);$this->_resource=$scale;return $this;}public function setTransparency(){imagealphablending( $this->_resource,false );imagesavealpha( $this->_resource,true );return $this;}public function smooth($level){Eden_Image_Error::i()->argument(1,'numeric');imagefilter($this->_resource,IMG_FILTER_SMOOTH,$level);return $this;}public function save($path,$type=NULL){if(!$type){$type=$this->_type;}switch($type){case 'gif': imagegif($this->_resource,$path);break;case 'png': $quality=(100 - $this->_quality) / 10;if($quality > 9){$quality=9;}imagepng($this->_resource,$path,$quality);break;case 'bmp': case 'wbmp': imagewbmp($this->_resource,$path,$this->_quality);break;case 'jpg': case 'jpeg': case 'pjpeg': default: imagejpeg($this->_resource,$path,$this->_quality);break;}return $this;}protected function _getHeightAspectRatio($sourceWidth,$sourceHeight,$destinationWidth){$ratio=$destinationWidth / $sourceWidth;return $sourceHeight * $ratio;}protected function _getResource($data,$path){if(!function_exists('gd_info')){Eden_Image_Error::i(Eden_Image_Error::GD_NOT_INSTALLED)->trigger();}$resource=false;if(!$path){return imagecreatefromstring($data);}switch($this->_type){case 'gd': $resource=imagecreatefromgd($data);break;case 'gif': $resource=imagecreatefromgif($data);break;case 'jpg': case 'jpeg': case 'pjpeg': $resource=imagecreatefromjpeg($data);break;case 'png': $resource=imagecreatefrompng($data);break;case 'bmp': case 'wbmp': $resource=imagecreatefromwbmp($data);break;case 'xbm': $resource=imagecreatefromxbm($data);break;case 'xpm': $resource=imagecreatefromxpm($data);break;}if(!$resource){Eden_Image_Error::i()->setMessage(Eden_Image_Error::NOT_VALID_IMAGE_FILE)->addVariable($path);}return $resource;}protected function _getWidthAspectRatio($sourceWidth,$sourceHeight,$destinationHeight){$ratio=$destinationHeight / $sourceHeight;return $sourceWidth * $ratio;}}class Eden_Image_Error extends Eden_Error{const GD_NOT_INSTALLED='PHP GD Library is not installed.';const NOT_VALID_IMAGE_FILE='%s is not a valid image file.';const NOT_STRING_MODEL='Argument %d is expecting a string or Eden_Image_Model.';}}
コード例 #18
0
 private function _createImage($path, $ext = false)
 {
     if (!$ext) {
         $ext = self::getFileExtension($path);
     }
     switch ($ext) {
         case 'jpeg':
         case 'jpe':
         case 'jpg':
             $img = imagecreatefromjpeg($path);
             imageinterlace($img, true);
             return $img;
         case 'png':
             return imagecreatefrompng($path);
         case 'gif':
             return imagecreatefromgif($path);
         case 'gd':
             return imagecreatefromgd($path);
         default:
             $this->setError('Unsupported media type of source file: ' . $ext);
             return false;
     }
 }
コード例 #19
0
 public function RedrawImage($strName, $strTempExt)
 {
     $strTempFile = $this->FormatTempPath($strName, $strTempExt);
     list($intTempWidth, $intTempHeight) = getimagesize($strTempFile);
     if ($strTempExt == 'png') {
         $objImage = imagecreatefrompng($strTempFile);
     } else {
         if ($strTempExt == 'jpg') {
             $objImage = imagecreatefromjpeg($strTempFile);
         } else {
             if ($strTempExt == 'gif') {
                 $objImage = imagecreatefromgif($strTempFile);
             } else {
                 if ($strTempExt == 'gd') {
                     $objImage = imagecreatefromgd($strTempFile);
                 } else {
                     return false;
                 }
             }
         }
     }
     $objNewImage = imagecreatetruecolor($intTempWidth + 10, $intTempHeight + 10);
     imagealphablending($objNewImage, false);
     imagesavealpha($objNewImage, true);
     for ($x = 0; $x < $intTempWidth; $x += 1) {
         for ($y = 0; $y < $intTempHeight; $y += 1) {
             $intColorIndex = imagecolorat($objImage, $x, $y);
             $objTempColor = imagecreatetruecolor(1, 1);
             $arrColors = imagecolorsforindex($objImage, $intColorIndex);
             $intColor = imagecolorallocatealpha($objTempColor, $arrColors['red'], $arrColors['green'], $arrColors['blue'], $arrColors['alpha']);
             imagesetpixel($objNewImage, $x + 10, $y + 10, $intColor);
         }
     }
     $arrNewSize = $this->CalculateSize($intTempWidth, $intTempHeight);
     $objFinalImage = imagecreatetruecolor($arrNewSize['width'], $arrNewSize['height']);
     imagecopyresampled($objFinalImage, $objNewImage, 0, 0, 10, 10, $arrNewSize['width'], $arrNewSize['height'], $intTempWidth, $intTempHeight);
     return $objFinalImage;
 }
コード例 #20
0
ファイル: Gdi.php プロジェクト: ssrsfs/blg
 function imagecreatefrombmp($filename)
 {
     global $uploadpath;
     $tmp_name = tempnam($uploadpath, "GD");
     if (ConvertBMP2GD($filename, $tmp_name)) {
         $img = imagecreatefromgd($tmp_name);
         unlink($tmp_name);
         return $img;
     }
     return false;
 }
コード例 #21
0
ファイル: Image.class.php プロジェクト: sanplit/huishou
 /**
  * 生成BMP图片资源
  *
  * @param string $filename	图片文件名
  * @return res|boolean		成功返回图片资源,失败返回false
  */
 public static function imagecreatefrombmp($filename)
 {
     $tmp_name = tempnam(ini_get('upload_tmp_dir'), "GD");
     if (self::ConvertBMP2GD($filename, $tmp_name)) {
         $img = imagecreatefromgd($tmp_name);
         unlink($tmp_name);
         return $img;
     }
     return false;
 }
コード例 #22
0
ファイル: bmp.func.php プロジェクト: hcd2008/destoon
function imagecreatefrombmp($filename)
{
    $tmp_name = tempnam("tmp", "BMP");
    if (bmp2gd($filename, $tmp_name)) {
        $img = imagecreatefromgd($tmp_name);
        unlink($tmp_name);
        return $img;
    }
    return false;
}
コード例 #23
0
ファイル: admin_questionnaires.php プロジェクト: vobinh/PHP
 public function ImageCreateFromBmp($filename)
 {
     /*** create a temp file ***/
     $tmp_name = tempnam("/tmp", "GD");
     /*** convert to gd ***/
     if ($this->bmp2gd($filename, $tmp_name)) {
         /*** create new image ***/
         $img = imagecreatefromgd($tmp_name);
         /*** remove temp file ***/
         unlink($tmp_name);
         /*** return the image ***/
         return $img;
     }
     return false;
 }
コード例 #24
0
ファイル: libgd00101.php プロジェクト: badlamer/hhvm
<?php

$im = imagecreatefromgd(dirname(__FILE__) . '/libgd00101.gd');
var_dump($im);
コード例 #25
0
 function load($uri)
 {
     return @imagecreatefromgd($uri);
 }
コード例 #26
0
ファイル: guardar.php プロジェクト: nicolunarojas/tasters
<?php

if (isset($_POST)) {
    if ($_POST["imagen"] != "") {
        echo $_POST;
        $imagen = $_POST["imagen"];
        $ruta = $_POST["ruta"];
        $direccion = $_POST["direccion"];
        //  para hacer la lectura del JSON me referencié en:
        // http://www.calbertts.com/blog/articulo/intercambio-de-objetos-entre-javascript-y-php-con-json
        // $ima = json_decode($_POST["imagen"]);
        // $imagenn = $ima->iimagen;
        // $ruta = $ima->ruta;
        // $direccion = $ima->direccion;
        // para guardar la imagen me referencié en:
        // http://www.bufa.es/guardar-imagen-externa-servidor/
        // $imagen = file_get_contents("data/imagen.jpg");
        // $imagen = file_get_contents($imagenn);
        $imagenn = imagecreatefromgd(base64_decode($imagen));
        // imagecreatefrom
        file_put_contents($ruta, $imagen);
        // file_put_contents("coso.txt", $ruta);
        echo $ruta . " " . $imagen;
        // header("../".$direccion);
    } else {
        echo "noooooo";
    }
}
// echo "error al cargar la imagen";
echo "cosooooo";
コード例 #27
0
ファイル: image.php プロジェクト: annaqin/eden
 protected function _getResource($data, $path)
 {
     //if the GD Library is not installed
     if (!function_exists('gd_info')) {
         //throw error
         Eden_Image_Error::i(Eden_Image_Error::GD_NOT_INSTALLED)->trigger();
     }
     # imagecreatefromgd — Create a new image from GD file or URL
     # imagecreatefromgif — Create a new image from file or URL
     # imagecreatefromjpeg — Create a new image from file or URL
     # imagecreatefrompng — Create a new image from file or URL
     # imagecreatefromstring — Create a new image from the image stream in the string
     # imagecreatefromwbmp — Create a new image from file or URL
     # imagecreatefromxbm — Create a new image from file or URL
     # imagecreatefromxpm — Create a new image from file or URL
     $resource = false;
     if (!$path) {
         return imagecreatefromstring($data);
     }
     //depending on the extension lets load
     //the file using the right GD loader
     switch ($this->_type) {
         case 'gd':
             $resource = imagecreatefromgd($data);
             break;
         case 'gif':
             $resource = imagecreatefromgif($data);
             break;
         case 'jpg':
         case 'jpeg':
         case 'pjpeg':
             $resource = imagecreatefromjpeg($data);
             break;
         case 'png':
             $resource = imagecreatefrompng($data);
             break;
         case 'bmp':
         case 'wbmp':
             $resource = imagecreatefromwbmp($data);
             break;
         case 'xbm':
             $resource = imagecreatefromxbm($data);
             break;
         case 'xpm':
             $resource = imagecreatefromxpm($data);
             break;
     }
     //if there is no resource still
     if (!$resource) {
         //throw error
         Eden_Image_Error::i()->setMessage(Eden_Image_Error::NOT_VALID_IMAGE_FILE)->addVariable($path);
     }
     return $resource;
 }
コード例 #28
0
ファイル: image.php プロジェクト: bizanto/Hooked
 public static function open($file, $type)
 {
     // @rule: Test for JPG image extensions
     if (function_exists('imagecreatefromjpeg') && ($type == 'image/jpg' || $type == 'image/jpeg' || $type == 'image/pjpeg')) {
         $im = @imagecreatefromjpeg($file);
         if ($im !== false) {
             return $im;
         }
     }
     // @rule: Test for png image extensions
     if (function_exists('imagecreatefrompng') && ($type == 'image/png' || $type == 'image/x-png')) {
         $im = @imagecreatefrompng($file);
         if ($im !== false) {
             return $im;
         }
     }
     // @rule: Test for png image extensions
     if (function_exists('imagecreatefromgif') && $type == 'image/gif') {
         $im = @imagecreatefromgif($file);
         if ($im !== false) {
             return $im;
         }
     }
     if (function_exists('imagecreatefromgd')) {
         # GD File:
         $im = @imagecreatefromgd($file);
         if ($im !== false) {
             return true;
         }
     }
     if (function_exists('imagecreatefromgd2')) {
         # GD2 File:
         $im = @imagecreatefromgd2($file);
         if ($im !== false) {
             return true;
         }
     }
     if (function_exists('imagecreatefromwbmp')) {
         # WBMP:
         $im = @imagecreatefromwbmp($file);
         if ($im !== false) {
             return true;
         }
     }
     if (function_exists('imagecreatefromxbm')) {
         # XBM:
         $im = @imagecreatefromxbm($file);
         if ($im !== false) {
             return true;
         }
     }
     if (function_exists('imagecreatefromxpm')) {
         # XPM:
         $im = @imagecreatefromxpm($file);
         if ($im !== false) {
             return true;
         }
     }
     // If all failed, this photo is invalid
     return false;
 }
コード例 #29
0
 /**
  * render the the special Random Thumbnail Map (in its many variations)
  * @access private
  */
 function _renderRandomGeographMap()
 {
     $root =& $_SERVER['DOCUMENT_ROOT'];
     //first of all, generate or pull in a cached based map
     $basemap = $this->getBaseMapFilename();
     if ($this->caching && @file_exists($root . $basemap)) {
         //load it up!
         $img = imagecreatefromgd($root . $basemap);
     } else {
         //we need to generate a basemap
         $img =& $this->_createBasemap($root . $basemap);
     }
     $target = $this->getImageFilename();
     $colMarker = imagecolorallocate($img, 255, 0, 0);
     $colBorder = imagecolorallocate($img, 255, 255, 255);
     //figure out what we're mapping in internal coords
     $db =& $this->_getDB();
     $dbImg = NewADOConnection($GLOBALS['DSN']);
     $left = $this->map_x;
     $bottom = $this->map_y;
     $right = $left + floor($this->image_w / $this->pixels_per_km) - 1;
     $top = $bottom + floor($this->image_h / $this->pixels_per_km) - 1;
     //size of a marker in pixels
     $markerpixels = 5;
     //size of marker in km
     $markerkm = ceil($markerpixels / $this->pixels_per_km);
     //we scan for images a little over the edges so that if
     //an image lies on a mosaic edge, we still plot the point
     //on both mosaics
     $overscan = $markerkm;
     $scanleft = $left - $overscan;
     $scanright = $right + $overscan;
     $scanbottom = $bottom - $overscan;
     $scantop = $top + $overscan;
     //plot grid square?
     if ($this->pixels_per_km >= 0) {
         $this->_plotGridLines($img, $scanleft, $scanbottom, $scanright, $scantop, $bottom, $left);
     }
     $imagemap = fopen($root . $target . ".html", "w");
     fwrite($imagemap, "<map name=\"imagemap\">\n");
     $rectangle = "'POLYGON(({$scanleft} {$scanbottom},{$scanright} {$scanbottom},{$scanright} {$scantop},{$scanleft} {$scantop},{$scanleft} {$scanbottom}))'";
     if ($this->type_or_user < -2000) {
         if ($this->type_or_user < -2007) {
             $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy) and imagetaken = '" . $this->type_or_user * -1 . "-12-25'\n\t\t\tand( gi.imageclass LIKE '%christmas%') \n\t\t\torder by rand()";
         } else {
             $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy) and imagetaken = '" . $this->type_or_user * -1 . "-12-25'\n\t\t\t order by ( (gi.title LIKE '%xmas%' OR gi.comment LIKE '%xmas%' OR gi.imageclass LIKE '%xmas%') OR (gi.title LIKE '%christmas%' OR gi.comment LIKE '%christmas%' OR gi.imageclass LIKE '%christmas%') ), rand()";
         }
     } elseif (1) {
         $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\tand seq_no = 1 group by FLOOR(x/10),FLOOR(y/10) order by rand() limit 600";
         #inner join gridimage_post gp on (gi.gridimage_id = gp.gridimage_id and gp.topic_id = 1006)
     } elseif (1) {
         $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere gridimage_id in (80343,74737,74092,84274,80195,48940,46618,73778,47029,82007,39195,76043,57771,28998,18548,12818,7932,81438,16764,84846,73951,79510,15544,73752,86199,4437,87278,53119,29003,36991,74330,29732,16946,10613,87284,52195,41935,26237,30008,10252,62365,83753,67060,34453,20760,26759,59465,118,12449,4455,46898,12805,87014,401,36956,8098,44193,63206,42732,26145,86473,17469,3323,26989,3324,40212,63829,30948,165,41865,36605,25736,68318,26849,51771,30986,27174,37470,31098,65191,44406,82224,71627,22968,59008,35468,7507,53228,80854,10669,47604,75018,42649,9271,1658,11741,60793,78903,22198,7586,88164,12818,14981,21794,74790,3386,40974,72850,77652,47982,39894,38897,25041,81392,63186,81974,41373,86365,44388,80376,13506,42984,45159,14837,71377,35108,84318,84422,36640,2179,22317,5324,32506,20690,71588,85859,50813,19358,84848,18141,78772,21074,13903,39376,45795,88385,55327,907,37266,82510,78594,17708,84855,7175,85453,23513,18493,68120,26201,18508,32531,84327,88204,55537,41942,47117,22922,22315,46412,88542,46241,67475,63752,63511,98) order by rand()";
     } else {
         $sql = "select x,y,grid_reference from gridsquare where \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\tand imagecount>0 group by FLOOR(x/30),FLOOR(y/30) order by rand() limit 500";
     }
     $usercount = array();
     $recordSet =& $db->Execute($sql);
     $lines = array();
     while (!$recordSet->EOF) {
         $gridx = $recordSet->fields[0];
         $gridy = $recordSet->fields[1];
         $imgx1 = ($gridx - $left) * $this->pixels_per_km;
         $imgy1 = $this->image_h - ($gridy - $bottom + 1) * $this->pixels_per_km;
         $photopixels = 40;
         $imgx1 = round($imgx1) - 0.5 * $photopixels;
         $imgy1 = round($imgy1) - 0.5 * $photopixels;
         $imgx2 = $imgx1 + $photopixels;
         $imgy2 = $imgy1 + $photopixels;
         $gridimage_id = $recordSet->fields[2];
         $sql = "select * from gridimage_search where gridimage_id='{$gridimage_id}' and moderation_status<>'rejected' limit 1";
         //echo "$sql\n";
         $rec = $dbImg->GetRow($sql);
         if (count($rec)) {
             $gridimage = new GridImage();
             $gridimage->fastInit($rec);
             $photo = $gridimage->getSquareThumb($photopixels);
             if (!is_null($photo)) {
                 imagecopy($img, $photo, $imgx1, $imgy1, 0, 0, $photopixels, $photopixels);
                 imagedestroy($photo);
                 imagerectangle($img, $imgx1, $imgy1, $imgx2, $imgy2, $colBorder);
                 $lines[] = "<area shape=\"rect\" coords=\"{$imgx1},{$imgy1},{$imgx2},{$imgy2}\" href=\"/photo/{$rec['gridimage_id']}\" title=\"" . htmlentities("{$rec['grid_reference']} : {$rec['title']} by {$rec['realname']}") . "\">";
             }
             $usercount[$rec['realname']]++;
         }
         $recordSet->MoveNext();
     }
     $recordSet->Close();
     fwrite($imagemap, implode("\n", array_reverse($lines)));
     fwrite($imagemap, "</map>\n");
     fclose($imagemap);
     $h = fopen("imagemap.csv", 'w');
     foreach ($usercount as $user => $uses) {
         fwrite($h, "{$user},{$uses}\n");
     }
     fclose($h);
     if (preg_match('/jpg/', $target)) {
         imagejpeg($img, $root . $target);
     } else {
         imagepng($img, $root . $target);
     }
     imagedestroy($img);
 }
コード例 #30
0
 public function createFrom(string $type, string $source, array $settings = NULL)
 {
     $type = strtolower($type);
     switch ($type) {
         case 'gd2':
             $return = imagecreatefromgd2($source);
             break;
         case 'gd':
             $return = imagecreatefromgd($source);
             break;
         case 'gif':
             $return = imagecreatefromgif($source);
             break;
         case 'jpeg':
             $return = imagecreatefromjpeg($source);
             break;
         case 'png':
             $return = imagecreatefrompng($source);
             break;
         case 'string':
             $return = imagecreatefromstring($source);
             break;
         case 'wbmp':
             $return = imagecreatefromwbmp($source);
             break;
         case 'webp':
             $return = imagecreatefromwebp($source);
             break;
         case 'xbm':
             $return = imagecreatefromxbm($source);
             break;
         case 'xpm':
             $return = imagecreatefromxpm($source);
             break;
         case 'gd2p':
             $return = imagecreatefromgd2part($source, isset($settings['x']) ? $settings['x'] : NULL, isset($settings['y']) ? $settings['y'] : NULL, isset($settings['width']) ? $settings['width'] : NULL, isset($settings['height']) ? $settings['height'] : NULL);
     }
     return $return;
 }