• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagecolormatch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convert

 /**
  * Convert an image. Returns TRUE when successfull, FALSE if image is
  * not a truecolor image.
  *
  * @param   img.Image image
  * @return  bool
  * @throws  img.ImagingException
  */
 public function convert($image)
 {
     if (!imageistruecolor($image->handle)) {
         return false;
     }
     $tmp = Image::create($image->getWidth(), $image->getHeight(), IMG_TRUECOLOR);
     $tmp->copyFrom($image);
     imagetruecolortopalette($image->handle, $this->dither, $this->ncolors);
     imagecolormatch($tmp->handle, $image->handle);
     unset($tmp);
     return true;
 }
开发者ID:xp-framework,项目名称:imaging,代码行数:20,代码来源:MatchingPaletteConverter.class.php


示例2: asPalette

 function asPalette($nColors = 255, $dither = null, $matchPalette = true)
 {
     $nColors = intval($nColors);
     if ($nColors < 1) {
         $nColors = 1;
     } elseif ($nColors > 255) {
         $nColors = 255;
     }
     if ($dither === null) {
         $dither = $this->isTransparent();
     }
     $temp = $this->copy();
     imagetruecolortopalette($temp->handle, $dither, $nColors);
     if ($matchPalette == true) {
         imagecolormatch($this->handle, $temp->handle);
     }
     if ($this->isTransparent()) {
         $trgb = $this->getTransparentColorRGB();
         $tci = $temp->getClosestColor($trgb);
         $temp->setTransparentColor($tci);
     }
     $temp->releaseHandle();
     return new wiPaletteImage($temp->handle);
 }
开发者ID:BackupTheBerlios,项目名称:haxoo-svn,代码行数:24,代码来源:TrueColorImage.class.php


示例3: imagecreatetruecolor

<?php

$ima = imagecreatetruecolor(110, 20);
$background_color = imagecolorallocate($ima, 0, 0, 0);
$imb = imagecreatetruecolor(110, 20);
$background_color = imagecolorallocate($imb, 0, 0, 100);
var_dump(imagecolormatch($ima, $imb));
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:imagecolormatch_error3.php


示例4: image_aplatir


//.........这里部分代码省略.........
    if ($creer) {
        $im = @$image["fonction_imagecreatefrom"]($im);
        imagepalettetotruecolor($im);
        $im_ = imagecreatetruecolor($x_i, $y_i);
        if ($image["format_source"] == "gif" and function_exists('ImageCopyResampled')) {
            // Si un GIF est transparent,
            // fabriquer un PNG transparent
            // Conserver la transparence
            @imagealphablending($im_, false);
            @imagesavealpha($im_, true);
            if (function_exists("imageAntiAlias")) {
                imageAntiAlias($im_, true);
            }
            @ImageCopyResampled($im_, $im, 0, 0, 0, 0, $x_i, $y_i, $x_i, $y_i);
            imagedestroy($im);
            $im = $im_;
        }
        // allouer la couleur de fond
        if ($transparence) {
            @imagealphablending($im_, false);
            @imagesavealpha($im_, true);
            $color_t = imagecolorallocatealpha($im_, $dr, $dv, $db, 127);
        } else {
            $color_t = ImageColorAllocate($im_, $dr, $dv, $db);
        }
        imagefill($im_, 0, 0, $color_t);
        //??
        //$dist = abs($trait);
        $transp_x = false;
        if ($image["format_source"] == "jpg") {
            $im_ =& $im;
        } else {
            for ($x = 0; $x < $x_i; $x++) {
                for ($y = 0; $y < $y_i; $y++) {
                    $rgb = ImageColorAt($im, $x, $y);
                    $a = $rgb >> 24 & 0xff;
                    $r = $rgb >> 16 & 0xff;
                    $g = $rgb >> 8 & 0xff;
                    $b = $rgb & 0xff;
                    $a = (127 - $a) / 127;
                    if ($a == 1) {
                        // Limiter calculs
                        $r = $r;
                        $g = $g;
                        $b = $b;
                    } else {
                        if ($a == 0) {
                            // Limiter calculs
                            $r = $dr;
                            $g = $dv;
                            $b = $db;
                            $transp_x = $x;
                            // Memoriser un point transparent
                            $transp_y = $y;
                        } else {
                            $r = round($a * $r + $dr * (1 - $a));
                            $g = round($a * $g + $dv * (1 - $a));
                            $b = round($a * $b + $db * (1 - $a));
                        }
                    }
                    $a = (1 - $a) * 127;
                    $color = ImageColorAllocateAlpha($im_, $r, $g, $b, $a);
                    imagesetpixel($im_, $x, $y, $color);
                }
            }
        }
        // passer en palette si besoin
        if ($format == 'gif' or $format == 'png' and $qualite !== 0) {
            // creer l'image finale a palette
            // (on recycle l'image initiale si possible, sinon on en recree une)
            if ($im === $im_) {
                $im = imagecreatetruecolor($x_i, $y_i);
            }
            @imagetruecolortopalette($im, true, $qualite);
            //$im = imagecreate($x_i, $y_i);
            // copier l'image true color vers la palette
            imagecopy($im, $im_, 0, 0, 0, 0, $x_i, $y_i);
            // matcher les couleurs au mieux par rapport a l'image initiale
            // si la fonction est disponible (php>=4.3)
            if (function_exists('imagecolormatch')) {
                @imagecolormatch($im_, $im);
            }
            if ($format == 'gif' && $transparence && $transp_x) {
                $color_t = ImagecolorAt($im, $transp_x, $transp_y);
                if ($format == "gif" && $transparence) {
                    @imagecolortransparent($im, $color_t);
                }
            }
            // produire le resultat
            _image_gd_output($im, $image, $qualite);
        } else {
            _image_gd_output($im_, $image, $qualite);
        }
        if ($im !== $im_) {
            imagedestroy($im);
        }
        imagedestroy($im_);
    }
    return _image_ecrire_tag($image, array('src' => $dest));
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:101,代码来源:images_transforme.php


示例5: imagecreatetruecolor

<?php

$im = imagecreatetruecolor(5, 5);
$im2 = imagecreate(5, 5);
imagecolormatch($im, $im2);
echo "ok\n";
imagedestroy($im);
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:colormatch.php


示例6: get

 public function get($type = 'png', $interlace = false, $quality = NULL, $filter = PNG_ALL_FILTERS)
 {
     $type = strtolower($type);
     if ($interlace === true) {
         imageinterlace($this->image, 1);
     }
     ob_start();
     switch ($type) {
         case 'png':
             $quality = $quality === NULL ? 9 : max(0, min(9, (int) $quality));
             imagepng($this->image, NULL, $quality, $filter);
             break;
         case 'jpeg':
             $quality = $quality === NULL ? 100 : max(0, min(100, (int) $quality));
             imagejpeg($this->image, NULL, $quality);
             break;
         case 'gif':
             $quality = $quality === NULL ? 255 : max(0, min(255, (int) $quality));
             $temp = imagecreatetruecolor($this->width, $this->height);
             imagecopy($temp, $this->image, 0, 0, 0, 0, $this->width, $this->height);
             imagetruecolortopalette($temp, false, $quality);
             imagecolormatch($this->image, $temp);
             imagegif($temp);
             break;
     }
     return trim(ob_get_clean());
 }
开发者ID:dlueth,项目名称:qoopido.rescale,代码行数:27,代码来源:Image.php


示例7: match

 public function match($sourceImage = '')
 {
     if (!is_resource($sourceImage)) {
         return Error::set(lang('Error', 'resourceParameter', '1.(sourceImage)'));
     }
     imagecolormatch($this->canvas, $sourceImage);
     return $this;
 }
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:8,代码来源:GD.php


示例8: asPalette

 /**
  * @see WideImage_Image#asPalette($nColors, $dither, $matchPalette)
  */
 function asPalette($nColors = 255, $dither = null, $matchPalette = true)
 {
     $nColors = intval($nColors);
     if ($nColors < 1) {
         $nColors = 1;
     } elseif ($nColors > 255) {
         $nColors = 255;
     }
     if ($dither === null) {
         $dither = $this->isTransparent();
     }
     $temp = $this->copy();
     imagetruecolortopalette($temp->handle, $dither, $nColors);
     if ($matchPalette == true && function_exists('imagecolormatch')) {
         imagecolormatch($this->handle, $temp->handle);
     }
     // The code below isn't working properly; it corrupts transparency on some palette->tc->palette conversions.
     // Why is this code here?
     /*
     			if ($this->isTransparent())
     			{
     				$trgb = $this->getTransparentColorRGB();
     				$tci = $temp->getClosestColor($trgb);
     				$temp->setTransparentColor($tci);
     			}
     			/**/
     $temp->releaseHandle();
     return new WideImage_PaletteImage($temp->handle);
 }
开发者ID:FabiolaBraga,项目名称:kandaframework,代码行数:32,代码来源:WideImage_TrueColorImage.php


示例9: ImageTrueColorToPalette2

 public function ImageTrueColorToPalette2(&$image, $dither, $ncolors)
 {
     // http://www.php.net/manual/en/function.imagetruecolortopalette.php
     // zmorris at zsculpt dot com (17-Aug-2004 06:58)
     $width = imagesx($image);
     $height = imagesy($image);
     $image_copy = imagecreatetruecolor($width, $height);
     //imagecopymerge($image_copy, $image, 0, 0, 0, 0, $width, $height, 100);
     imagecopy($image_copy, $image, 0, 0, 0, 0, $width, $height);
     imagetruecolortopalette($image, $dither, $ncolors);
     imagecolormatch($image_copy, $image);
     imagedestroy($image_copy);
     return true;
 }
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:14,代码来源:phpthumb.filters.php


示例10: generate_thumbnails

 function generate_thumbnails($source, $targets_and_constraints, $target_format, $thumbnail_quality)
 {
     $files_created_in_operation = array();
     list($width, $height) = getimagesize($source);
     $ok = false;
     if ($width > 0) {
         $pixel_size_buffer = 1.25;
         $max_bytes = $comicpress_manager->convert_short_size_string_to_bytes(ini_get('memory_limit'));
         if ($max_bytes > 0) {
             $max_thumb_size = 0;
             foreach ($targets_and_constraints as $target_and_constraint) {
                 list($target, $constraint) = $target_and_constraint;
                 $width_to_use = $constraint['width'];
                 $archive_comic_height = (int) ($width_to_use * $height / $width);
                 $max_thumb_size = max($width_to_use * $archive_comic_height * 4, $max_thumb_size);
             }
             $input_image_size = $width * $height * 4;
             if (strtolower(pathinfo($input, PATHINFO_EXTENSION)) == "gif") {
                 $input_image_size *= 2;
             }
             $recommended_size = ($input_image_size + $max_thumb_size) * $pixel_size_buffer;
             if (function_exists('memory_get_usage')) {
                 $recommended_size += memory_get_usage();
             }
             if ($recommended_size > $max_bytes) {
                 $comicpress_manager->warnings[] = sprintf(__("<strong>You don't have enough memory available to PHP and GD to process this file.</strong> You should <strong>set your PHP <tt>memory_size</tt></strong> to at least <strong><tt>%sM</tt></strong> and try again. For more information, read the ComicPress Manager FAQ.", 'comicpress-manager'), (int) ($recommended_size / (1024 * 1024)));
                 return false;
             }
         }
         foreach ($targets_and_constraints as $target_and_constraint) {
             list($target, $constraint) = $target_and_constraint;
             $width_to_use = $constraint['width'];
             $archive_comic_height = (int) ($width_to_use * $height / $width);
             $pathinfo = pathinfo($source);
             $thumb_image = imagecreatetruecolor($width_to_use, $archive_comic_height);
             imagealphablending($thumb_image, true);
             switch (strtolower($pathinfo['extension'])) {
                 case "jpg":
                 case "jpeg":
                     $comic_image = imagecreatefromjpeg($source);
                     break;
                 case "gif":
                     $is_gif = true;
                     $temp_comic_image = imagecreatefromgif($source);
                     list($width, $height) = getimagesize($input);
                     $comic_image = imagecreatetruecolor($width, $height);
                     imagecopy($comic_image, $temp_comic_image, 0, 0, 0, 0, $width, $height);
                     imagedestroy($temp_comic_image);
                     break;
                 case "png":
                     $comic_image = imagecreatefrompng($source);
                     break;
                 default:
                     return false;
             }
             imagealphablending($comic_image, true);
             if ($is_palette = !imageistruecolor($comic_image)) {
                 $number_of_colors = imagecolorstotal($comic_image);
             }
             imagecopyresampled($thumb_image, $comic_image, 0, 0, 0, 0, $width_to_use, $archive_comic_height, $width, $height);
             $ok = true;
             @touch($target);
             if (file_exists($target)) {
                 @unlink($target);
                 switch (strtolower($target_format)) {
                     case "jpg":
                     case "jpeg":
                         if (imagetypes() & IMG_JPG) {
                             @imagejpeg($thumb_image, $target, $comicpress_manager->get_cpm_option("cpm-thumbnail-quality"));
                         } else {
                             return false;
                         }
                         break;
                     case "gif":
                         if (imagetypes() & IMG_GIF) {
                             if (function_exists('imagecolormatch')) {
                                 $temp_comic_image = imagecreate($width_to_use, $archive_comic_height);
                                 imagecopymerge($temp_comic_image, $thumb_image, 0, 0, 0, 0, $width_to_use, $archive_comic_height, 100);
                                 imagecolormatch($thumb_image, $temp_comic_image);
                                 @imagegif($temp_comic_image, $target);
                                 imagedestroy($temp_comic_image);
                             } else {
                                 @imagegif($thumb_image, $target);
                             }
                         } else {
                             return false;
                         }
                         break;
                     case "png":
                         if (imagetypes() & IMG_PNG) {
                             if ($is_palette) {
                                 imagetruecolortopalette($thumb_image, true, $number_of_colors);
                             }
                             @imagepng($thumb_image, $target, 9);
                         } else {
                             return false;
                         }
                         break;
                     default:
                         return false;
//.........这里部分代码省略.........
开发者ID:johnbintz,项目名称:comicpress-manager-1.5,代码行数:101,代码来源:ComicPressGDProcessing.php


示例11: match

 public function match($sourceImage) : InternalGD
 {
     if (!is_resource($sourceImage)) {
         throw new InvalidArgumentException('Error', 'resourceParameter', '1.($sourceImage)');
     }
     imagecolormatch($this->canvas, $sourceImage);
     return $this;
 }
开发者ID:znframework,项目名称:znframework,代码行数:8,代码来源:InternalGD.php


示例12: asPalette

 /**
  * @see GDImage_Image#asPalette($nColors, $dither, $matchPalette)
  */
 function asPalette($nColors = 255, $dither = null, $matchPalette = true)
 {
     $nColors = intval($nColors);
     if ($nColors < 1) {
         $nColors = 1;
     } elseif ($nColors > 255) {
         $nColors = 255;
     }
     if ($dither === null) {
         $dither = $this->isTransparent();
     }
     $temp = $this->copy();
     imagetruecolortopalette($temp->handle, $dither, $nColors);
     if ($matchPalette == true && function_exists('imagecolormatch')) {
         imagecolormatch($this->handle, $temp->handle);
     }
     $temp->releaseHandle();
     return new GDImage_PaletteImage($temp->handle);
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:22,代码来源:TrueColorImage.php


示例13: imagecreatetruecolor

<?php

$ima = imagecreatetruecolor(110, 20);
$background_color = imagecolorallocate($ima, 0, 0, 0);
var_dump(imagecolormatch($ima));
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:imagecolormatch_error1.php


示例14: cpm_write_thumbnail


//.........这里部分代码省略.........
                            }
                            if ($recommended_size > $max_bytes) {
                                $cpm_config->warnings[] = sprintf(__("<strong>You don't have enough memory available to PHP and GD to process this file.</strong> You should <strong>set your PHP <tt>memory_size</tt></strong> to at least <strong><tt>%sM</tt></strong> and try again. For more information, read the ComicPress Manager FAQ.", 'comicpress-manager'), (int) ($recommended_size / (1024 * 1024)));
                                return false;
                            }
                        }
                        foreach ($write_targets as $type => $target) {
                            $width_to_use = isset($cpm_config->properties["{$type}_comic_width"]) ? $cpm_config->properties["{$type}_comic_width"] : $cpm_config->properties['archive_comic_width'];
                            if ($width_to_use < $width) {
                                $archive_comic_height = (int) ($width_to_use * $height / $width);
                                $pathinfo = pathinfo($input);
                                $thumb_image = imagecreatetruecolor($width_to_use, $archive_comic_height);
                                imagealphablending($thumb_image, true);
                                switch (strtolower($pathinfo['extension'])) {
                                    case "jpg":
                                    case "jpeg":
                                        $comic_image = imagecreatefromjpeg($input);
                                        break;
                                    case "gif":
                                        $is_gif = true;
                                        $temp_comic_image = imagecreatefromgif($input);
                                        list($width, $height) = getimagesize($input);
                                        $comic_image = imagecreatetruecolor($width, $height);
                                        imagecopy($comic_image, $temp_comic_image, 0, 0, 0, 0, $width, $height);
                                        imagedestroy($temp_comic_image);
                                        break;
                                    case "png":
                                        $comic_image = imagecreatefrompng($input);
                                        break;
                                    default:
                                        return false;
                                }
                                imagealphablending($comic_image, true);
                                if ($is_palette = !imageistruecolor($comic_image)) {
                                    $number_of_colors = imagecolorstotal($comic_image);
                                }
                                imagecopyresampled($thumb_image, $comic_image, 0, 0, 0, 0, $width_to_use, $archive_comic_height, $width, $height);
                                $ok = true;
                                @touch($target);
                                if (file_exists($target)) {
                                    @unlink($target);
                                    switch (strtolower($target_format)) {
                                        case "jpg":
                                        case "jpeg":
                                            if (imagetypes() & IMG_JPG) {
                                                @imagejpeg($thumb_image, $target, cpm_option("cpm-thumbnail-quality"));
                                            } else {
                                                return false;
                                            }
                                            break;
                                        case "gif":
                                            if (imagetypes() & IMG_GIF) {
                                                if (function_exists('imagecolormatch')) {
                                                    $temp_comic_image = imagecreate($width_to_use, $archive_comic_height);
                                                    imagecopymerge($temp_comic_image, $thumb_image, 0, 0, 0, 0, $width_to_use, $archive_comic_height, 100);
                                                    imagecolormatch($thumb_image, $temp_comic_image);
                                                    @imagegif($temp_comic_image, $target);
                                                    imagedestroy($temp_comic_image);
                                                } else {
                                                    @imagegif($thumb_image, $target);
                                                }
                                            } else {
                                                return false;
                                            }
                                            break;
                                        case "png":
                                            if (imagetypes() & IMG_PNG) {
                                                if ($is_palette) {
                                                    imagetruecolortopalette($thumb_image, true, $number_of_colors);
                                                }
                                                @imagepng($thumb_image, $target, 9);
                                            } else {
                                                return false;
                                            }
                                            break;
                                        default:
                                            return false;
                                    }
                                }
                            } else {
                                copy($input, $target);
                            }
                            if (!file_exists($target)) {
                                $ok = false;
                            } else {
                                @chmod($target, CPM_FILE_UPLOAD_CHMOD);
                                $files_created_in_operation[] = $target;
                            }
                            imagedestroy($comic_image);
                            imagedestroy($thumb_image);
                        }
                    } else {
                        $ok = false;
                    }
                    return $ok ? $files_created_in_operation : false;
            }
        }
    }
    return null;
}
开发者ID:johnbintz,项目名称:comicpress-manager-1.4,代码行数:101,代码来源:comicpress_manager_admin.php


示例15: getImage


//.........这里部分代码省略.........
     } elseif ($intWidth) {
         $intHeight = ceil($objFile->height * $width / $objFile->width);
         $strNewImage = imagecreatetruecolor($intWidth, $intHeight);
     } elseif ($intHeight) {
         $intWidth = ceil($objFile->width * $height / $objFile->height);
         $strNewImage = imagecreatetruecolor($intWidth, $intHeight);
     }
     $arrGdinfo = gd_info();
     $strGdVersion = preg_replace('/[^0-9\\.]+/', '', $arrGdinfo['GD Version']);
     switch ($objFile->extension) {
         case 'gif':
             if ($arrGdinfo['GIF Read Support']) {
                 $strSourceImage = imagecreatefromgif(TL_ROOT . '/' . $image);
                 $intTranspIndex = imagecolortransparent($strSourceImage);
                 // Handle transparency
                 if ($intTranspIndex >= 0 && $intTranspIndex < imagecolorstotal($strSourceImage)) {
                     $arrColor = imagecolorsforindex($strSourceImage, $intTranspIndex);
                     $intTranspIndex = imagecolorallocate($strNewImage, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagecolortransparent($strNewImage, $intTranspIndex);
                 }
             }
             break;
         case 'jpg':
         case 'jpeg':
             if ($arrGdinfo['JPG Support'] || $arrGdinfo['JPEG Support']) {
                 $strSourceImage = imagecreatefromjpeg(TL_ROOT . '/' . $image);
             }
             break;
         case 'png':
             if ($arrGdinfo['PNG Support']) {
                 $strSourceImage = imagecreatefrompng(TL_ROOT . '/' . $image);
                 // Handle transparency (GDlib >= 2.0 required)
                 if (version_compare($strGdVersion, '2.0', '>=')) {
                     imagealphablending($strNewImage, false);
                     $intTranspIndex = imagecolorallocatealpha($strNewImage, 0, 0, 0, 127);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagesavealpha($strNewImage, true);
                 }
             }
             break;
     }
     // The new image could not be created
     if (!$strSourceImage) {
         $this->log('Image "' . $image . '" could not be processed', 'Controller getImage()', TL_ERROR);
         return null;
     }
     imagecopyresampled($strNewImage, $strSourceImage, $intPositionX, $intPositionY, 0, 0, $intWidth, $intHeight, $objFile->width, $objFile->height);
     // Fallback to PNG if GIF ist not supported
     if ($objFile->extension == 'gif' && !$arrGdinfo['GIF Create Support']) {
         $objFile->extension = 'png';
     }
     // Create the new image
     switch ($objFile->extension) {
         case 'gif':
             imagegif($strNewImage, TL_ROOT . '/' . $strCacheName);
             break;
         case 'jpg':
         case 'jpeg':
             imagejpeg($strNewImage, TL_ROOT . '/' . $strCacheName, !$GLOBALS['TL_CONFIG']['jpgQuality'] ? 80 : $GLOBALS['TL_CONFIG']['jpgQuality']);
             break;
         case 'png':
             // Optimize non-truecolor images (see #2426)
             if (version_compare($strGdVersion, '2.0', '>=') && function_exists('imagecolormatch') && !imageistruecolor($strSourceImage)) {
                 // TODO: make it work with transparent images, too
                 if (imagecolortransparent($strSourceImage) == -1) {
                     $intColors = imagecolorstotal($strSourceImage);
                     // Convert to a palette image
                     // @see http://www.php.net/manual/de/function.imagetruecolortopalette.php#44803
                     if ($intColors > 0 && $intColors < 256) {
                         $wi = imagesx($strNewImage);
                         $he = imagesy($strNewImage);
                         $ch = imagecreatetruecolor($wi, $he);
                         imagecopymerge($ch, $strNewImage, 0, 0, 0, 0, $wi, $he, 100);
                         imagetruecolortopalette($strNewImage, false, $intColors);
                         imagecolormatch($ch, $strNewImage);
                         imagedestroy($ch);
                     }
                 }
             }
             imagepng($strNewImage, TL_ROOT . '/' . $strCacheName);
             break;
     }
     // Destroy the temporary images
     imagedestroy($strSourceImage);
     imagedestroy($strNewImage);
     // Resize the original image
     if ($target) {
         $this->import('Files');
         $this->Files->rename($strCacheName, $target);
         return $target;
     }
     // Set the file permissions when the Safe Mode Hack is used
     if ($GLOBALS['TL_CONFIG']['useFTP']) {
         $this->import('Files');
         $this->Files->chmod($strCacheName, 0644);
     }
     // Return the path to new image
     return $strCacheName;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:101,代码来源:Controller.php


示例16: get


//.........这里部分代码省略.........
         $intHeight = max(round($objFile->height * $width / $objFile->width), 1);
         $strNewImage = imagecreatetruecolor($intWidth, $intHeight);
     } elseif ($intHeight) {
         $intWidth = max(round($objFile->width * $height / $objFile->height), 1);
         $strNewImage = imagecreatetruecolor($intWidth, $intHeight);
     }
     $arrGdinfo = gd_info();
     $strGdVersion = preg_replace('/[^0-9\\.]+/', '', $arrGdinfo['GD Version']);
     switch ($objFile->extension) {
         case 'gif':
             if ($arrGdinfo['GIF Read Support']) {
                 $strSourceImage = imagecreatefromgif(TL_ROOT . '/' . $image);
                 $intTranspIndex = imagecolortransparent($strSourceImage);
                 // Handle transparency
                 if ($intTranspIndex >= 0 && $intTranspIndex < imagecolorstotal($strSourceImage)) {
                     $arrColor = imagecolorsforindex($strSourceImage, $intTranspIndex);
                     $intTranspIndex = imagecolorallocate($strNewImage, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagecolortransparent($strNewImage, $intTranspIndex);
                 }
             }
             break;
         case 'jpg':
         case 'jpeg':
             if ($arrGdinfo['JPG Support'] || $arrGdinfo['JPEG Support']) {
                 $strSourceImage = imagecreatefromjpeg(TL_ROOT . '/' . $image);
             }
             break;
         case 'png':
             if ($arrGdinfo['PNG Support']) {
                 $strSourceImage = imagecreatefrompng(TL_ROOT . '/' . $image);
                 // Handle transparency (GDlib >= 2.0 required)
                 if (version_compare($strGdVersion, '2.0', '>=')) {
                     imagealphablending($strNewImage, false);
                     $intTranspIndex = imagecolorallocatealpha($strNewImage, 0, 0, 0, 127);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagesavealpha($strNewImage, true);
                 }
             }
             break;
     }
     // The new image could not be created
     if (!$strSourceImage) {
         imagedestroy($strNewImage);
         \System::log('Image "' . $image . '" could not be processed', __METHOD__, TL_ERROR);
         return null;
     }
     imageinterlace($strNewImage, 1);
     // see #6529
     imagecopyresampled($strNewImage, $strSourceImage, $intPositionX, $intPositionY, 0, 0, $intWidth, $intHeight, $objFile->width, $objFile->height);
     // Fallback to PNG if GIF ist not supported
     if ($objFile->extension == 'gif' && !$arrGdinfo['GIF Create Support']) {
         $objFile->extension = 'png';
     }
     // Create the new image
     switch ($objFile->extension) {
         case 'gif':
             imagegif($strNewImage, TL_ROOT . '/' . $strCacheName);
             break;
         case 'jpg':
         case 'jpeg':
             imagejpeg($strNewImage, TL_ROOT . '/' . $strCacheName, \Config::get('jpgQuality') ?: 80);
             break;
         case 'png':
             // Optimize non-truecolor images (see #2426)
             if (version_compare($strGdVersion, '2.0', '>=') && function_exists('imagecolormatch') && !imageistruecolor($strSourceImage)) {
                 // TODO: make it work with transparent images, too
                 if (imagecolortransparent($strSourceImage) == -1) {
                     $intColors = imagecolorstotal($strSourceImage);
                     // Convert to a palette image
                     // @see http://www.php.net/manual/de/function.imagetruecolortopalette.php#44803
                     if ($intColors > 0 && $intColors < 256) {
                         $wi = imagesx($strNewImage);
                         $he = imagesy($strNewImage);
                         $ch = imagecreatetruecolor($wi, $he);
                         imagecopymerge($ch, $strNewImage, 0, 0, 0, 0, $wi, $he, 100);
                         imagetruecolortopalette($strNewImage, false, $intColors);
                         imagecolormatch($ch, $strNewImage);
                         imagedestroy($ch);
                     }
                 }
             }
             imagepng($strNewImage, TL_ROOT . '/' . $strCacheName);
             break;
     }
     // Destroy the temporary images
     imagedestroy($strSourceImage);
     imagedestroy($strNewImage);
     // Resize the original image
     if ($target) {
         \Files::getInstance()->copy($strCacheName, $target);
         return \System::urlEncode($target);
     }
     // Set the file permissions when the Safe Mode Hack is used
     if (\Config::get('useFTP')) {
         \Files::getInstance()->chmod($strCacheName, \Config::get('defaultFileChmod'));
     }
     // Return the path to new image
     return \System::urlEncode($strCacheName);
 }
开发者ID:iCodr8,项目名称:core,代码行数:101,代码来源:Image.php


示例17: cropImage

 /**
  * Crop the image and return the file path
  * @param string
  * @param integer
  * @param integer
  * @return string
  */
 protected function cropImage($strFile, $intPositionX, $intPositionY)
 {
     $strThumbnail = $this->getThumbnailPath($strFile);
     list($intWidth, $intHeight) = $this->getThumbnailDimensions($strFile);
     // Resize to thumbnail size first
     \Image::resize($strFile, $intWidth, $intHeight, 'proportional');
     $arrGdinfo = gd_info();
     $strGdVersion = preg_replace('/[^0-9\\.]+/', '', $arrGdinfo['GD Version']);
     $strNewImage = imagecreatetruecolor($this->arrAvatarSize[0], $this->arrAvatarSize[1]);
     $strExtension = strtolower(pathinfo($strFile, PATHINFO_EXTENSION));
     switch ($strExtension) {
         case 'gif':
             if ($arrGdinfo['GIF Read Support']) {
                 $strSourceImage = imagecreatefromgif(TL_ROOT . '/' . $strFile);
                 $intTranspIndex = imagecolortransparent($strSourceImage);
                 // Handle transparency
                 if ($intTranspIndex >= 0 && $intTranspIndex < imagecolorstotal($strSourceImage)) {
                     $arrColor = imagecolorsforindex($strSourceImage, $intTranspIndex);
                     $intTranspIndex = imagecolorallocate($strNewImage, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagecolortransparent($strNewImage, $intTranspIndex);
                 }
             }
             break;
         case 'jpg':
         case 'jpeg':
             if ($arrGdinfo['JPG Support'] || $arrGdinfo['JPEG Support']) {
                 $strSourceImage = imagecreatefromjpeg(TL_ROOT . '/' . $strFile);
             }
             break;
         case 'png':
             if ($arrGdinfo['PNG Support']) {
                 $strSourceImage = imagecreatefrompng(TL_ROOT . '/' . $strFile);
                 // Handle transparency (GDlib >= 2.0 required)
                 if (version_compare($strGdVersion, '2.0', '>=')) {
                     imagealphablending($strNewImage, false);
                     $intTranspIndex = imagecolorallocatealpha($strNewImage, 0, 0, 0, 127);
                     imagefill($strNewImage, 0, 0, $intTranspIndex);
                     imagesavealpha($strNewImage, true);
                 }
             }
             break;
     }
     // The new image could not be created
     if (!$strSourceImage) {
         imagedestroy($strNewImage);
         \System::log('Image "' . $strFile . '" could not be processed', __METHOD__, TL_ERROR);
         return null;
     }
     imagecopyresampled($strNewImage, $strSourceImage, 0, 0, intval($intPositionX), intval($intPositionY), $this->arrAvatarSize[0], $this->arrAvatarSize[1], $this->arrAvatarSize[0], $this->arrAvatarSize[1]);
     // Create the new image
     switch ($strExtension) {
         case 'gif':
             imagegif($strNewImage, TL_ROOT . '/' . $strThumbnail);
             break;
         case 'jpg':
         case 'jpeg':
             imagejpeg($strNewImage, TL_ROOT . '/' . $strThumbnail, !$GLOBALS['TL_CONFIG']['jpgQuality'] ? 80 : $GLOBALS['TL_CONFIG']['jpgQuality']);
             break;
         case 'png':
             // Optimize non-truecolor images (see #2426)
             if (version_compare($strGdVersion, '2.0', '>=') && function_exists('imagecolormatch') && !imageistruecolor($strSourceImage)) {
                 // TODO: make it work with transparent images, too
                 if (imagecolortransparent($strSourceImage) == -1) {
                     $intColors = imagecolorstotal($strSourceImage);
                     // Convert to a palette image
                     // @see http://www.php.net/manual/de/function.imagetruecolortopalette.php#44803
                     if ($intColors > 0 && $intColors < 256) {
                         $wi = imagesx($strNewImage);
                         $he = imagesy($strNewImage);
                         $ch = imagecreatetruecolor($wi, $he);
                         imagecopymerge($ch, $strNewImage, 0, 0, 0, 0, $wi, $he, 100);
                         imagetruecolortopalette($strNewImage, false, $intColors);
                         imagecolormatch($ch, $strNewImage);
                         imagedestroy($ch);
                     }
                 }
             }
             imagepng($strNewImage, TL_ROOT . '/' . $strThumbnail);
             break;
     }
     // Destroy the temporary images
     imagedestroy($strSourceImage);
     imagedestroy($strNewImage);
     return $strThumbnail;
 }
开发者ID:revision6,项目名称:contao-avatar,代码行数:93,代码来源:AvatarWidgetBase.php


示例18: trueColorToPalette

 public function trueColorToPalette()
 {
     $img = imagecreatetruecolor($this->width, $this->height);
     $bga = imagecolorallocatealpha($img, 0, 0, 0, 127);
     imagecolortransparent($img, $bga);
     imagefill($img, 0, 0, $bga);
     imagecopy($img, $this->image, 0, 0, 0, 0, $this->width, $this->height);
     imagetruecolortopalette($img, false, 255);
     imagesavealpha($img, true);
     if (imageistruecolor($this->image)) {
         $this->log("Matching colors with true color image.");
         imagecolormatch($this->image, $img);
     }
     $this->image = $img;
 }
开发者ID:sonyarianto,项目名称:cimage,代码行数:15,代码来源:imgs.php


示例19: _getFilePath


//.........这里部分代码省略.........
                         $crop_y = 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagecolorresolve函数代码示例发布时间:2022-05-15
下一篇:
PHP imagecolorexactalpha函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap