当前位置: 首页>>代码示例>>PHP>>正文


PHP imageCreateFromString函数代码示例

本文整理汇总了PHP中imageCreateFromString函数的典型用法代码示例。如果您正苦于以下问题:PHP imageCreateFromString函数的具体用法?PHP imageCreateFromString怎么用?PHP imageCreateFromString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imageCreateFromString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_thumbnail

function generate_thumbnail($file, $mime)
{
    global $config;
    gd_capabilities();
    list($file_type, $exact_type) = explode("/", $mime);
    if (_JB_GD_INSTALLED && ($file_type = "image")) {
        if ($exact_type != "gif" && $exact_type != "png" && $exact_type != "jpeg") {
            return false;
        }
        if ($exact_type == "gif" && !_JB_GD_GIF) {
            return false;
        }
        if ($exact_type == "png" && !_JB_GD_PNG) {
            return false;
        }
        if ($exact_type == "jpeg" && !_JB_GD_JPG) {
            return false;
        }
        // Load up the original and get size
        //  NOTE: use imageCreateFromString to avoid to have to check what type of image it is
        $original = imageCreateFromString(file_get_contents($file));
        $original_w = imagesX($original);
        $original_h = imagesY($original);
        // Only if the image is really too big, resize it
        // NOTE: if image is smaller than target size, don't do anything.
        //  We *could* copy the original to filename_thumb, but since it's the same
        //  it would be a waste of precious resources
        if ($original_w > $config['uploader']['thumb_w'] || $original_h > $config['uploader']['thumb_h']) {
            // If original is wider than it's high, resize the width and vice versa
            // NOTE: '>=' cause otherwise it's possible that $scale isn't computed
            if ($original_w >= $original_h) {
                $scaled_w = $config['uploader']['thumb_w'];
                // Figure out how much smaller that target is than original
                //  and apply it to height
                $scale = $config['uploader']['thumb_w'] / $original_w;
                $scaled_h = ceil($original_h * $scale);
            } elseif ($original_w <= $original_h) {
                $scaled_h = $config['uploader']['thumb_h'];
                $scale = $config['uploader']['thumb_h'] / $original_h;
                $scaled_w = ceil($original_w * $scale);
            }
        } else {
            // Break out of if($file_type = image) since no resize is possible
            return false;
        }
        // Scale the image
        $scaled = imageCreateTrueColor($scaled_w, $scaled_h);
        imageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
        // Store thumbs in jpeg, hope no one minds the 100% quality lol
        imageJpeg($scaled, $file . "_thumb", 100);
        // Let's be nice to our server
        imagedestroy($scaled);
        imagedestroy($original);
        return true;
    }
}
开发者ID:victorjacobs,项目名称:jetbird,代码行数:56,代码来源:image.functions.php

示例2: __construct

 public function __construct($handle)
 {
     $mimeType = Type::guessType($handle);
     if (!isset($this->_formatMap[$mimeType])) {
         throw new OutOfBoundsException("Could not map MIME-type `{$mimeType}` to format.");
     }
     $this->_format = $this->_formatMap[$mimeType];
     $this->_object = imageCreateFromString(stream_get_contents($handle));
     if (!$this->_isResource($this->_object)) {
         throw new Exception("Was not able to create image from handle.");
     }
     if (imageIsTrueColor($this->_object)) {
         imageAlphaBlending($this->_object, false);
         imageSaveAlpha($this->_object, true);
     }
 }
开发者ID:edukondaluetg,项目名称:mm,代码行数:16,代码来源:Gd.php

示例3: Cartoonfy

 function Cartoonfy($p_image, $p_triplevel, $p_diffspace)
 {
     $this->triplevel = (int) (2000.0 + 5000.0 * $p_triplevel);
     $this->diffspace = (int) ($p_diffspace * 32.0);
     $this->i0 = imageCreateFromString(file_get_contents($p_image));
     if ($this->i0) {
         $this->i1 = imageCreateTrueColor(imageSx($this->i0), imageSy($this->i0));
         for ($x = (int) $this->diffspace; $x < imageSx($this->i0) - (1 + (int) $this->diffspace); $x++) {
             for ($y = (int) $this->diffspace; $y < imageSy($this->i0) - (1 + (int) $this->diffspace); $y++) {
                 $t = Cartoonfy::GetMaxContrast($x, $y);
                 if ($t > $this->triplevel) {
                     imageSetPixel($this->i1, $x, $y, 0);
                 } else {
                     imageSetPixel($this->i1, $x, $y, Cartoonfy::FlattenColor(imageColorAt($this->i0, $x, $y)));
                 }
             }
             //usleep(1000);
         }
         imageDestroy($this->i0);
     } else {
         print "<b>" . $p_image . "</b> is not supported image format!";
         exit;
     }
 }
开发者ID:BGCX067,项目名称:facebookpiccartoonizer-svn-to-git,代码行数:24,代码来源:Cartoonfy.class.php

示例4: imageResample

 /**
  * Resamples (convert/resize) an image file. You can specify a new width, height and type
  * @param string $file Image path and file name
  * @param int $w Width
  * @param int $h Height
  * @param string $type Supported image types: gif,png,jpg,bmp,xbmp,wbmp. Defaults to jpg
  * @return boolean
  */
 public static function imageResample($file, $w, $h, $type = null)
 {
     if (!function_exists('imagecreatefromstring')) {
         Raxan::log('Function imagecreatefromstring does not exists - The GD image processing library is required.', 'warn', 'Raxan::imageResample');
         return false;
     }
     $info = @getImageSize($file);
     if ($info) {
         // maintain aspect ratio
         if ($h == 0) {
             $h = $info[1] * ($w / $info[0]);
         }
         if ($w == 0) {
             $w = $info[0] * ($h / $info[1]);
         }
         if ($w == 0 && $h == 0) {
             $w = $info[0];
             $h = $info[1];
         }
         // resize/resample image
         $img = @imageCreateFromString(file_get_contents($file));
         if (!$img) {
             return false;
         }
         $newImg = function_exists('imagecreatetruecolor') ? imageCreateTrueColor($w, $h) : imageCreate($w, $h);
         if (function_exists('imagecopyresampled')) {
             imageCopyResampled($newImg, $img, 0, 0, 0, 0, $w, $h, $info[0], $info[1]);
         } else {
             imageCopyResized($newImg, $img, 0, 0, 0, 0, $w, $h, $info[0], $info[1]);
         }
         imagedestroy($img);
         $type = !$type ? $info[2] : strtolower(trim($type));
         if ($type == 1 || $type == 'gif') {
             $f = 'imagegif';
         } else {
             if ($type == 3 || $type == 'png') {
                 $f = 'imagepng';
             } else {
                 if ($type == 6 || $type == 16 || $type == 'bmp' || $type == 'xbmp') {
                     $f = 'imagexbm';
                 } else {
                     if ($type == 15 || $type == 'wbmp') {
                         $f = 'image2wbmp';
                     } else {
                         $f = 'imagejpeg';
                     }
                 }
             }
         }
         if (function_exists($f)) {
             $f($newImg, $file);
         }
         imagedestroy($newImg);
         return true;
     }
     return false;
 }
开发者ID:enriqueism,项目名称:raxan,代码行数:65,代码来源:raxan.php

示例5: appendSourceInfo

 /**
  * Appends information about the source image to the thumbnail.
  * 
  * @param	string		$thumbnail
  * @return	string
  */
 protected function appendSourceInfo($thumbnail)
 {
     if (!function_exists('imageCreateFromString') || !function_exists('imageCreateTrueColor')) {
         return $thumbnail;
     }
     $imageSrc = imageCreateFromString($thumbnail);
     // get image size
     $width = imageSX($imageSrc);
     $height = imageSY($imageSrc);
     // increase height
     $heightDst = $height + self::$sourceInfoLineHeight * 2;
     // create new image
     $imageDst = imageCreateTrueColor($width, $heightDst);
     imageAlphaBlending($imageDst, false);
     // set background color
     $background = imageColorAllocate($imageDst, 102, 102, 102);
     imageFill($imageDst, 0, 0, $background);
     // copy image
     imageCopy($imageDst, $imageSrc, 0, 0, 0, 0, $width, $height);
     imageSaveAlpha($imageDst, true);
     // get font size
     $font = 2;
     $fontWidth = imageFontWidth($font);
     $fontHeight = imageFontHeight($font);
     $fontColor = imageColorAllocate($imageDst, 255, 255, 255);
     // write source info
     $line1 = $this->sourceName;
     // imageString supports only ISO-8859-1 encoded strings
     if (CHARSET != 'ISO-8859-1') {
         $line1 = StringUtil::convertEncoding(CHARSET, 'ISO-8859-1', $line1);
     }
     // truncate text if necessary
     $maxChars = floor($width / $fontWidth);
     if (strlen($line1) > $maxChars) {
         $line1 = $this->truncateSourceName($line1, $maxChars);
     }
     $line2 = $this->sourceWidth . 'x' . $this->sourceHeight . ' ' . FileUtil::formatFilesize($this->sourceSize);
     // write line 1
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line1) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line1) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line1, $fontColor);
     // write line 2
     // calculate text position
     $textX = 0;
     $textY = 0;
     if ($fontHeight < self::$sourceInfoLineHeight) {
         $textY = self::$sourceInfoLineHeight + intval(round((self::$sourceInfoLineHeight - $fontHeight) / 2));
     }
     if (strlen($line2) * $fontWidth < $width) {
         $textX = intval(round(($width - strlen($line2) * $fontWidth) / 2));
     }
     imageString($imageDst, $font, $textX, $height + $textY, $line2, $fontColor);
     // output image
     ob_start();
     if ($this->imageType == 1 && function_exists('imageGIF')) {
         @imageGIF($imageDst);
         $this->mimeType = 'image/gif';
     } else {
         if (($this->imageType == 1 || $this->imageType == 3) && function_exists('imagePNG')) {
             @imagePNG($imageDst);
             $this->mimeType = 'image/png';
         } else {
             if (function_exists('imageJPEG')) {
                 @imageJPEG($imageDst, null, 90);
                 $this->mimeType = 'image/jpeg';
             } else {
                 return false;
             }
         }
     }
     @imageDestroy($imageDst);
     $thumbnail = ob_get_contents();
     ob_end_clean();
     return $thumbnail;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:88,代码来源:Thumbnail.class.php

示例6: _resize

 /**
  * Load the image and resize it using the assigned strategy.
  * @param  string   $filename Filename of the input file.
  * @return resource GD image resource.
  */
 protected function _resize($filename)
 {
     $image = imageCreateFromString(file_get_contents($filename));
     if (false === $image) {
         throw new Zend_Filter_Exception('Can\'t load image: ' . $filename);
     }
     $resized = $this->getStrategy()->resize($image, $this->getWidth(), $this->getHeight());
     return $resized;
 }
开发者ID:luismayta,项目名称:zrt,代码行数:14,代码来源:ImageSize.php

示例7: function

                                'pro_title' : pro_title,
								'Edi':edit
								
                            },
                            success: function(response){
								window.location.href = 'campaign_dash.php';
                                return false;
                            
     
                  <?php 
//$promotion_no="23";
$Img = 'upload/file_' . $promotion_no . '.png';
if ($_POST['file'] != "") {
    //@header('Content-Type: application/json');
    $file = base64_decode(str_replace('data:image/png;base64,', '', $_POST['file']));
    $im = imageCreateFromString($file);
    if ($im) {
        $save = imagepng($im, 'upload/file_' . $promotion_no . '.png');
        // if(isset($_post['saveme'])){
        $qry = "INSERT INTO promotion VALUES ('','{$parentemail}','{$save_div}','{$Img}','','{$promotion_no}','{$pro_title}','{$pro_id}')";
        $res = mysqli_query($conn, $qry);
        //}
        // echo $pro_title=$_POST['pro_title'];
        echo json_encode(array('file' => true));
    } else {
        echo json_encode(array('error' => 'Could not parse image string.'));
    }
    //exit();
}
?>
	
开发者ID:VulcanInfotech,项目名称:Pyxymail,代码行数:30,代码来源:upload_sumit.php

示例8: add_watermark

 function add_watermark($image_path, $watermark_path, $type = 'show')
 {
     $this->image_data = $type == 'return' ? array('mime' => $this->getFileType($image_path, 'mime')) : getImageSize($image_path);
     $this->image = $type == 'return' ? imageCreateFromString($image_path) : $this->ImageCreateFromType($image_path, $this->image_data['mime']);
     ImageAlphaBlending($this->image, true);
     $this->watermark_data = getimagesize($watermark_path);
     $this->watermark = $this->ImageCreateFromType($watermark_path, $this->watermark_data['mime']);
     $image_width = ImageSX($this->image);
     $image_height = ImageSY($this->image);
     $watermark_width = ImageSX($this->watermark);
     $watermark_height = ImageSY($this->watermark);
     $full_offset_x = $image_width - $watermark_width;
     $full_offset_y = $image_height - $watermark_height;
     $half_offset_x = ($image_width - $watermark_width) / 2;
     $half_offset_y = ($image_height - $watermark_height) / 2;
     if ($this->watermark_random_position == 'yes') {
         $random_full_offset_x = $full_offset_x - 40;
         $random_full_offset_y = $full_offset_y - 40;
         $x = rand(20, $random_full_offset_x);
         $y = rand(20, $random_full_offset_y);
     } else {
         $offset = $this->offset;
         switch ($this->align_to) {
             case 'lt':
                 $x = $offset['x'];
                 $y = $offset['y'];
                 break;
             case 'ct':
                 $x = $half_offset_x + $offset['x'];
                 $y = $offset['y'];
                 break;
             case 'rt':
                 $x = $offset['x'] + $full_offset_x;
                 $y = $offset['y'];
                 break;
             case 'lc':
                 $x = $offset['x'];
                 $y = $offset['y'] + $half_offset_y;
                 break;
             case 'cc':
                 $x = $offset['x'] + $half_offset_x;
                 $y = $offset['y'] + $half_offset_y;
                 break;
             case 'rc':
                 $x = $offset['x'] + $full_offset_x;
                 $y = $offset['y'] + $half_offset_y;
                 break;
             case 'lb':
                 $x = $offset['x'];
                 $y = $offset['y'] + $full_offset_y;
                 break;
             case 'cb':
                 $x = $offset['x'] + $half_offset_x;
                 $y = $offset['y'] + $full_offset_y;
                 break;
             case 'rb':
                 $x = $offset['x'] + $full_offset_x;
                 $y = $offset['y'] + $full_offset_y;
                 break;
         }
     }
     $temp = imagecreatetruecolor($watermark_width, $watermark_height);
     imagecopy($temp, $this->image, 0, 0, $x, $y, $watermark_width, $watermark_height);
     imagecopy($temp, $this->watermark, 0, 0, 0, 0, $watermark_width, $watermark_height);
     imagecopymerge($this->image, $temp, $x, $y, 0, 0, $watermark_width, $watermark_height, $this->watermark_opacity);
     $this->is_added_watermark = true;
     switch ($type) {
         case 'show':
             $this->show_image();
             break;
         case 'save':
             $this->show_image('string');
             break;
         case 'return':
             return $this->return_image();
             break;
     }
 }
开发者ID:ryandong82,项目名称:colorfulladysite,代码行数:78,代码来源:auto-save-images.php

示例9: checkImage

 /**
  * Validate image.
  *
  * @param string $image string representing image, for example, result of base64_decode()
  *
  * @throws APIException if image size is 1MB or greater.
  * @throws APIException if file format is unsupported, GD can not create image from given string
  */
 protected function checkImage($image)
 {
     // check size
     if (strlen($image) > ZBX_MAX_IMAGE_SIZE) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Image size must be less than 1MB.'));
     }
     // check file format
     if (@imageCreateFromString($image) === false) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('File format is unsupported.'));
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:19,代码来源:CImage.php

示例10: initFromString

 /**
  * Initialize a layer from a string (obtains with file_get_contents, cURL...)
  * 
  * This not recommanded to initialize JPEG string with this method, GD displays bugs !
  * 
  * @param string $imageString
  * 
  * @return ImageWorkshopLayer
  */
 public static function initFromString($imageString)
 {
     return new ImageWorkshopLayer(imageCreateFromString($imageString));
 }
开发者ID:Yatko,项目名称:Gifteng,代码行数:13,代码来源:ImageWorkshop.php

示例11: shareImage

function shareImage()
{
    global $cfg, $db;
    if ($cfg['image_share_mode'] == 'played') {
        $query = mysql_query('SELECT image, artist, album, filesize, filemtime, album.album_id
			FROM counter, album, bitmap
			WHERE counter.flag <= 1
			AND counter.album_id = album.album_id
			AND counter.album_id = bitmap.album_id
			ORDER BY counter.time DESC
			LIMIT 1');
        $bitmap = mysql_fetch_assoc($query);
        $text = 'Recently played:';
    } else {
        $query = mysql_query('SELECT image, artist, album, filesize, filemtime, album.album_id
			FROM album, bitmap 
			WHERE album.album_id = bitmap.album_id 
			ORDER BY album_add_time DESC
			LIMIT 1');
        $bitmap = mysql_fetch_assoc($query);
        $text = 'New album:';
        $cfg['image_share_mode'] = 'new';
    }
    $etag = '"' . md5($bitmap['album_id'] . $cfg['image_share_mode'] . $bitmap['filemtime'] . '-' . $bitmap['filesize'] . '-' . filemtime('image/share.png')) . '"';
    if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
        header('HTTP/1.1 304 Not Modified');
        header('ETag: ' . $etag);
        header('Cache-Control: max-age=5');
        exit;
    }
    // Background (253 x 52 pixel)
    $dst_image = imageCreateFromPng('image/share.png');
    // Image copy source NJB_IMAGE_SIZE x NJB_IMAGE_SIZE => 50x50
    $src_image = imageCreateFromString($bitmap['image']);
    imageCopyResampled($dst_image, $src_image, 1, 1, 0, 0, 50, 50, NJB_IMAGE_SIZE, NJB_IMAGE_SIZE);
    imageDestroy($src_image);
    // Text
    $font = NJB_HOME_DIR . 'fonts/DejaVuSans.ttf';
    $font_color = imagecolorallocate($dst_image, 0, 0, 99);
    imagettftext($dst_image, 8, 0, 55, 13, $font_color, $font, $text);
    imagettftext($dst_image, 8, 0, 55, 30, $font_color, $font, $bitmap['artist']);
    imagettftext($dst_image, 8, 0, 55, 47, $font_color, $font, $bitmap['album']);
    // For to long text overwrite 4 pixels right margin
    $src_image = imageCreateFromPng('image/share.png');
    ImageCopy($dst_image, $src_image, 249, 0, 249, 0, 4, 52);
    imageDestroy($src_image);
    // Buffer data
    ob_start();
    ImagePng($dst_image);
    $data = ob_get_contents();
    ob_end_clean();
    imageDestroy($dst_image);
    header('Cache-Control: max-age=5');
    streamData($data, 'image/jpeg', false, false, $etag);
}
开发者ID:jdeblese,项目名称:ompd-mod,代码行数:55,代码来源:image.php

示例12: waterMark

 function waterMark($original, $watermark = 'watermark.png', $placement = 'bottom=10,right=10', $destination = null)
 {
     $info_o = @getImageSize($original);
     if (!$info_o) {
         return false;
     }
     $info_w = @getImageSize($watermark);
     if (!$info_w) {
         return false;
     }
     list($vertical, $horizontal) = explode(',', $placement);
     list($vertical, $sy) = explode('=', trim($vertical));
     list($horizontal, $sx) = explode('=', trim($horizontal));
     switch (trim($vertical)) {
         case 'bottom':
             $y = $info_o[1] - $info_w[1] - (int) $sy;
             break;
         case 'middle':
             $y = ceil($info_o[1] / 2) - ceil($info_w[1] / 2) + (int) $sy;
             break;
         default:
             $y = (int) $sy;
             break;
     }
     switch (trim($horizontal)) {
         case 'right':
             $x = $info_o[0] - $info_w[0] - (int) $sx;
             break;
         case 'center':
             $x = ceil($info_o[0] / 2) - ceil($info_w[0] / 2) + (int) $sx;
             break;
         default:
             $x = (int) $sx;
             break;
     }
     //header("Content-Type: ".$info_o['mime']);
     $f = $this->createFuncName;
     $isrc = $f($this->file);
     $idest = imagecreatetruecolor($info_o[0], $info_o[1]);
     $iWatermark = @imageCreateFromString(file_get_contents($watermark));
     $iOriginal = @imageCreateFromString(file_get_contents($original));
     imageAlphaBlending($idest, true);
     imageSaveAlpha($idest, true);
     imageCopy($idest, $iOriginal, 0, 0, 0, 0, $info_o[0], $info_o[1]);
     imageCopy($idest, $iWatermark, $x, $y, 0, 0, $info_w[0], $info_w[1]);
     if ($this->format == 'jpeg') {
         $f = $this->outputFuncName;
         $f($idest, $original, $this->outputQuality);
     } else {
         $f = $this->outputFuncName;
         $f($idest, $original);
     }
     imagedestroy($iOriginal);
     imagedestroy($idest);
     imageDestroy($iWatermark);
     return true;
 }
开发者ID:sergey-sla,项目名称:framework,代码行数:57,代码来源:Image.php

示例13: waterMark

 function waterMark($original, $watermark, $placement = 'bottom=0,right=0', $destination)
 {
     $info_o = @getImageSize($original);
     if (!$info_o) {
         return false;
     }
     $info_w = @getImageSize($watermark);
     if (!$info_w) {
         return false;
     }
     list($vertical, $horizontal) = explode(',', $placement, 2);
     list($vertical, $sy) = explode('=', trim($vertical), 2);
     list($horizontal, $sx) = explode('=', trim($horizontal), 2);
     switch (trim($vertical)) {
         case 'bottom':
             $y = $info_o[1] - $info_w[1] - (int) $sy;
             break;
         case 'middle':
             $y = ceil($info_o[1] / 2) - ceil($info_w[1] / 2) + (int) $sy;
             break;
         default:
             $y = (int) $sy;
             break;
     }
     switch (trim($horizontal)) {
         case 'right':
             $x = $info_o[0] - $info_w[0] - (int) $sx;
             break;
         case 'center':
             $x = ceil($info_o[0] / 2) - ceil($info_w[0] / 2) + (int) $sx;
             break;
         default:
             $x = (int) $sx;
             break;
     }
     $original = @imageCreateFromString(file_get_contents($original));
     $watermark = @imageCreateFromString(file_get_contents($watermark));
     $out = imageCreateTrueColor($info_o[0], $info_o[1]);
     imageCopy($out, $original, 0, 0, 0, 0, $info_o[0], $info_o[1]);
     if ($info_o[0] > 60 && $info_o[1] > 60) {
         imageCopy($out, $watermark, $x, $y, 0, 0, $info_w[0], $info_w[1]);
     }
     switch ($info_o[2]) {
         case 1:
             imageGIF($out, $destination);
             break;
         case 2:
             imageJPEG($out, $destination);
             break;
         case 3:
             imagePNG($out, $destination);
             break;
     }
     imageDestroy($out);
     imageDestroy($original);
     imageDestroy($watermark);
     return true;
 }
开发者ID:somov,项目名称:test_app_itm_ee,代码行数:58,代码来源:CNSNImageConv.php

示例14: read_image_descriptor

 function read_image_descriptor()
 {
     /* Reset global variables */
     $this->buffer = array();
     $this->fou = '';
     /* Header -> GIF89a */
     $this->fou .= "GIF89a";
     $this->getbytes(9);
     for ($i = 0; $i < 9; $i++) {
         $this->image_descriptor[$i] = $this->buffer[$i];
     }
     $local_color_table_flag = $this->buffer[8] & 0x80 ? TRUE : FALSE;
     if ($local_color_table_flag) {
         $code = $this->buffer[8] & 0x7;
         $sorted = $this->buffer[8] & 0x20 ? TRUE : FALSE;
     } else {
         $code = $this->global_color_table_code;
         $sorted = $this->global_sorted;
     }
     $size = 2 << $code;
     $this->logical_screen_descriptor[4] &= 0x70;
     $this->logical_screen_descriptor[4] |= 0x80;
     $this->logical_screen_descriptor[4] |= $code;
     if ($sorted) {
         $this->logical_screen_descriptor[4] |= 0x8;
     }
     $this->putbytes($this->logical_screen_descriptor, 7);
     if ($local_color_table_flag) {
         $this->getbytes(3 * $size);
         $this->putbytes($this->buffer, 3 * $size);
     } else {
         $this->putbytes($this->global, 3 * $size);
     }
     $this->fou .= ",";
     $this->image_descriptor[8] &= 0x40;
     $this->putbytes($this->image_descriptor, 9);
     /* LZW minimum code size */
     $this->getbytes(1);
     $this->putbytes($this->buffer, 1);
     /* Image Data */
     for (;;) {
         $this->getbytes(1);
         $this->putbytes($this->buffer, 1);
         if (($u = $this->buffer[0]) == 0) {
             break;
         }
         $this->getbytes($u);
         $this->putbytes($this->buffer, $u);
     }
     /* trailer */
     $this->fou .= ";";
     /* Write to file */
     switch ($this->fm) {
         /* Write as BMP */
         case "BMP":
             $im = imageCreateFromString($this->fou);
             $framename = $this->sp . $this->image_count++ . ".bmp";
             if (!$this->imageBmp($im, $framename)) {
                 $this->es = "error #3";
                 return 0;
             }
             imageDestroy($im);
             break;
             /* Write as PNG */
         /* Write as PNG */
         case "PNG":
             $im = imageCreateFromString($this->fou);
             $framename = $this->sp . $this->image_count++ . ".png";
             if (!imagePng($im, $framename)) {
                 $this->es = "error #3";
                 return 0;
             }
             imageDestroy($im);
             break;
             /* Write as JPG */
         /* Write as JPG */
         case "JPG":
             $im = imageCreateFromString($this->fou);
             $framename = $this->sp . $this->image_count++ . ".jpg";
             if (!imageJpeg($im, $framename)) {
                 $this->es = "error #3";
                 return 0;
             }
             imageDestroy($im);
             break;
             /* Write as GIF */
         /* Write as GIF */
         case "GIF":
             $im = imageCreateFromString($this->fou);
             $framename = $this->output . $this->sp . ".gif";
             if (!imageGif($im, $framename)) {
                 $this->es = "error #3";
                 return 0;
             }
             imageDestroy($im);
             break;
     }
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:98,代码来源:CNGifSplit.php

示例15: initFromString

 /**
  * Initialize a layer from a string (obtains with file_get_contents, cURL...)
  * 
  * This not recommanded to initialize JPEG string with this method, GD displays bugs !
  * 
  * @param string $imageString
  * 
  * @return ImageWorkshopLayer
  */
 public static function initFromString($imageString)
 {
     if (!($image = @imageCreateFromString($imageString))) {
         throw new ImageWorkshopException('Can\'t generate an image from the given string.', static::ERROR_CREATE_IMAGE_FROM_STRING);
     }
     return new ImageWorkshopLayer($image);
 }
开发者ID:gdragffy,项目名称:ImageWorkshop,代码行数:16,代码来源:ImageWorkshop.php


注:本文中的imageCreateFromString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。