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

PHP imageistruecolor函数代码示例

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

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



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

示例1: analyze

 /**
  * {@inheritdoc}
  */
 public function analyze($filename)
 {
     $imageSize = @getimagesize($filename);
     if ($imageSize === false) {
         throw new UnsupportedFileException('File type not supported.');
     }
     $imageInfo = new ImageInfo();
     $type = null;
     $colors = null;
     if ($imageSize[2] === IMAGETYPE_JPEG) {
         $gd = imagecreatefromjpeg($filename);
         $type = imageistruecolor($gd) ? 'TRUECOLOR' : 'PALETTE';
         $colors = imagecolorstotal($gd);
         imagedestroy($gd);
     } elseif ($imageSize[2] === IMAGETYPE_GIF) {
         $gd = imagecreatefromgif($filename);
         $type = imageistruecolor($gd) ? 'TRUECOLOR' : 'PALETTE';
         $colors = imagecolorstotal($gd);
         imagedestroy($gd);
     } elseif ($imageSize[2] === IMAGETYPE_PNG) {
         $gd = imagecreatefrompng($filename);
         $type = imageistruecolor($gd) ? 'TRUECOLOR' : 'PALETTE';
         $colors = imagecolorstotal($gd);
         imagedestroy($gd);
     }
     $imageInfo->setAnalyzer(get_class($this))->setSize($imageSize[0], $imageSize[1])->setResolution(null, null)->setUnits(null)->setFormat($this->mapFormat($imageSize[2]))->setColors($colors)->setType($type)->setColorspace(!empty($imageSize['channels']) ? $imageSize['channels'] === 4 ? 'CMYK' : 'RGB' : 'RGB')->setDepth($imageSize['bits'])->setCompression(null)->setQuality(null)->setProfiles(null);
     return $imageInfo;
 }
开发者ID:temp,项目名称:image-analyzer,代码行数:31,代码来源:GdDriver.php


示例2: resize

 public function resize($maxW = null, $maxH = null, $canEnlarge = false)
 {
     $src = $this->_rawImage;
     if ($maxW === null && $maxH === null) {
         return $src;
     }
     if (imageistruecolor($src)) {
         imageAlphaBlending($src, true);
         imageSaveAlpha($src, true);
     }
     $srcW = imagesx($src);
     $srcH = imagesy($src);
     $width = $maxW && ($canEnlarge || $maxW <= $srcW) ? $maxW : $srcW;
     $height = $maxH && ($canEnlarge || $maxH <= $srcW) ? $maxH : $srcH;
     $ratio_orig = $srcW / $srcH;
     if ($width / $height > $ratio_orig) {
         $width = $height * $ratio_orig;
     } else {
         $height = $width / $ratio_orig;
     }
     $maxW = $maxW ? $maxW : $width;
     $maxH = $maxH ? $maxH : $height;
     $img = imagecreatetruecolor($maxW, $maxH);
     $trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127);
     imagefill($img, 0, 0, $trans_colour);
     $offsetX = ($maxW - $width) / 2;
     $offsetY = ($maxH - $height) / 2;
     imagecopyresampled($img, $src, $offsetX, $offsetY, 0, 0, $width, $height, $srcW, $srcH);
     imagealphablending($img, true);
     imagesavealpha($img, true);
     return $img;
 }
开发者ID:tomk,项目名称:imagehelper,代码行数:32,代码来源:ImageHelper.php


示例3: convert

 /**
  * Convert an image.
  *
  * @param   img.Image image
  * @return  bool
  * @throws  img.ImagingException
  */
 public function convert($image)
 {
     // Create temporary variable as local variable access is faster
     // than member variable access.
     $handle = $image->handle;
     if (imageistruecolor($handle)) {
         $l = [];
         $h = $image->getHeight();
         $w = $image->getWidth();
         for ($y = 0; $y < $h; $y++) {
             for ($x = 0; $x < $w; $x++) {
                 $rgb = imagecolorat($handle, $x, $y);
                 if (!isset($l[$rgb])) {
                     $g = 0.299 * ($rgb >> 16 & 0xff) + 0.587 * ($rgb >> 8 & 0xff) + 0.114 * ($rgb & 0xff);
                     $l[$rgb] = imagecolorallocate($handle, $g, $g, $g);
                 }
                 imagesetpixel($handle, $x, $y, $l[$rgb]);
             }
         }
         unset($l);
     } else {
         for ($i = 0, $t = imagecolorstotal($handle); $i < $t; $i++) {
             $c = imagecolorsforindex($handle, $i);
             $g = 0.299 * $c['red'] + 0.587 * $c['green'] + 0.114 * $c['blue'];
             imagecolorset($handle, $i, $g, $g, $g);
         }
     }
 }
开发者ID:xp-framework,项目名称:imaging,代码行数:35,代码来源:GrayscaleConverter.class.php


示例4: fit

 /**
  * Fit small image to specified bound
  *
  * @param string $src
  * @param string $dest
  * @param int $width
  * @param int $height
  * @return bool
  */
 public function fit($src, $dest, $width, $height)
 {
     // Calculate
     $size = getimagesize($src);
     $ratio = max($width / $size[0], $height / $size[1]);
     $old_width = $size[0];
     $old_height = $size[1];
     $new_width = intval($old_width * $ratio);
     $new_height = intval($old_height * $ratio);
     // Resize
     @ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT));
     $image = imagecreatefromstring(file_get_contents($src));
     $new_image = wp_imagecreatetruecolor($new_width, $new_height);
     imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
     if (IMAGETYPE_PNG == $size[2] && function_exists('imageistruecolor') && !imageistruecolor($image)) {
         imagetruecolortopalette($new_image, false, imagecolorstotal($image));
     }
     // Destroy old image
     imagedestroy($image);
     // Save
     switch ($size[2]) {
         case IMAGETYPE_GIF:
             $result = imagegif($new_image, $dest);
             break;
         case IMAGETYPE_PNG:
             $result = imagepng($new_image, $dest);
             break;
         default:
             $result = imagejpeg($new_image, $dest);
             break;
     }
     imagedestroy($new_image);
     return $result;
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:43,代码来源:Image.php


示例5: 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;
     }
     return imagetruecolortopalette($image->handle, $this->dither, $this->ncolors);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:PaletteConverter.class.php


示例6: testGdResourceToTruecolor

 public function testGdResourceToTruecolor()
 {
     $resource = imagecreate(10, 10);
     $this->assertFalse(imageistruecolor($resource));
     Helper::gdResourceToTruecolor($resource);
     $this->assertTrue(imageistruecolor($resource));
 }
开发者ID:EdgarPost,项目名称:image,代码行数:7,代码来源:GdHelperTest.php


示例7: output

 /**
  * Output an image. If the image is true-color, it will be converted
  * to a paletted image first using imagetruecolortopalette().
  *
  * @param   resource handle
  * @return  bool
  */
 public function output($handle)
 {
     if (imageistruecolor($handle)) {
         imagetruecolortopalette($handle, $this->dither, $this->ncolors);
     }
     return imagegif($handle);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:GifStreamWriter.class.php


示例8: load

 /**
  * {@inheritdoc}
  */
 protected function load()
 {
     // Return immediately if the image file is not valid.
     if (!$this->isValid()) {
         return FALSE;
     }
     switch ($this->getType()) {
         case GDToolkitWebP::IMAGETYPE_WEBP:
             $function = 'imagecreatefromwebp';
             break;
         default:
             $function = 'imagecreatefrom' . image_type_to_extension($this->getType(), FALSE);
     }
     if (function_exists($function) && ($resource = $function($this->getImage()->getSource()))) {
         $this->setResource($resource);
         if (imageistruecolor($resource)) {
             return TRUE;
         } else {
             // Convert indexed images to true color, so that filters work
             // correctly and don't result in unnecessary dither.
             $new_image = $this->createTmp($this->getType(), imagesx($resource), imagesy($resource));
             if ($ret = (bool) $new_image) {
                 imagecopy($new_image, $resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource));
                 imagedestroy($resource);
                 $this->setResource($new_image);
             }
             return $ret;
         }
     }
     return FALSE;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:34,代码来源:GDToolkitWebP.php


示例9: imageflip

function imageflip(&$image, $x = 0, $y = 0, $width = null, $height = null)
{
    if ($width < 1) {
        $width = imagesx($image);
    }
    if ($height < 1) {
        $height = imagesy($image);
    }
    // Truecolor provides better results, if possible.
    if (function_exists('imageistruecolor') && imageistruecolor($image)) {
        $tmp = imagecreatetruecolor(1, $height);
    } else {
        $tmp = imagecreate(1, $height);
    }
    $x2 = $x + $width - 1;
    for ($i = (int) floor(($width - 1) / 2); $i >= 0; $i--) {
        // Backup right stripe.
        imagecopy($tmp, $image, 0, 0, $x2 - $i, $y, 1, $height);
        // Copy left stripe to the right.
        imagecopy($image, $image, $x2 - $i, $y, $x + $i, $y, 1, $height);
        // Copy backuped right stripe to the left.
        imagecopy($image, $tmp, $x + $i, $y, 0, 0, 1, $height);
    }
    imagedestroy($tmp);
    return true;
}
开发者ID:Saloo20xX,项目名称:rtl-theme-maker,代码行数:26,代码来源:rtl-theme-maker-functions.php


示例10: testConstructMethodAlwaysConvertResourceTrueColor

 public function testConstructMethodAlwaysConvertResourceTrueColor()
 {
     $resource = imagecreatefromgif(__DIR__ . '/../../../data/lisbon1.gif');
     $this->assertFalse(imageistruecolor($resource));
     $adapter = new GdAdapter($resource);
     $this->assertTrue(imageistruecolor($adapter->getResource()));
 }
开发者ID:phower,项目名称:image,代码行数:7,代码来源:GdAdapterTest.php


示例11: get_hexcolor

function get_hexcolor($im, $c)
{
    if (imageistruecolor($im)) {
        return $c;
    }
    $colors = imagecolorsforindex($im, $c);
    return ($colors['red'] << 16) + ($colors['green'] << 8) + $colors['blue'];
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:copyresized.php


示例12: dither

 /**
  * Convert the image to 2 colours with dithering.
  */
 protected function dither()
 {
     if (!imageistruecolor($this->image)) {
         imagepalettetotruecolor($this->image);
     }
     imagefilter($this->image, IMG_FILTER_GRAYSCALE);
     imagetruecolortopalette($this->image, true, 2);
 }
开发者ID:reginaldoazevedojr,项目名称:zebra,代码行数:11,代码来源:Image.php


示例13: ReadSourceFile

 function ReadSourceFile($image_file_name)
 {
     $this->DestroyImage();
     $this->ImageStatsSRC = @getimagesize($image_file_name);
     if ($this->ImageStatsSRC[2] == 3) {
         $this->ImageStatsSRC[2] = IMG_PNG;
     }
     $this->ImageMimeType = $this->ImageStatsSRC['mime'];
     $this->ImageTypeNo = $this->ImageStatsSRC[2];
     switch ($this->ImageTypeNo) {
         case IMG_GIF:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             $this->ImageTypeExt = '.gif';
             $image_read_func = 'imagecreatefromgif';
             break;
         case IMG_JPG:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             if (function_exists('exif_read_data')) {
                 $this->exif_get_data($image_file_name);
             }
             $this->ImageTypeExt = '.jpg';
             $image_read_func = 'imagecreatefromjpeg';
             break;
         case IMG_PNG:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             $this->ImageTypeExt = '.png';
             $image_read_func = 'imagecreatefrompng';
             break;
         default:
             return false;
     }
     $this->ImageID = $image_read_func($image_file_name);
     if (function_exists('imageistruecolor')) {
         if (imageistruecolor($this->ImageID)) {
             if (function_exists('imageantialias')) {
                 imageantialias($this->ImageID, true);
             }
             imagealphablending($this->ImageID, false);
             if (function_exists('imagesavealpha')) {
                 $this->Alpha = true;
                 imagesavealpha($this->ImageID, true);
             }
         }
     }
     $this->ChangeFlag = true;
     if ($this->ImageID) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:GabrielAnca,项目名称:icy_phoenix,代码行数:57,代码来源:class_image.php


示例14: image_resize

 /**
  * This function is almost equal to the image_resize (native function of wordpress)
  */
 function image_resize($file, $max_w, $max_h, $crop = false, $far = false, $iar = false, $dest_path = null, $jpeg_quality = 90)
 {
     $image = wp_load_image($file);
     if (!is_resource($image)) {
         return new WP_Error('error_loading_image', $image);
     }
     $size = @getimagesize($file);
     if (!$size) {
         return new WP_Error('invalid_image', __('Could not read image size'), $file);
     }
     list($orig_w, $orig_h, $orig_type) = $size;
     $dims = mf_image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop, $far, $iar);
     if (!$dims) {
         $dims = array(0, 0, 0, 0, $orig_w, $orig_h, $orig_w, $orig_h);
     }
     list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
     $newimage = imagecreatetruecolor($dst_w, $dst_h);
     imagealphablending($newimage, false);
     imagesavealpha($newimage, true);
     $transparent = imagecolorallocatealpha($newimage, 255, 255, 255, 127);
     imagefilledrectangle($newimage, 0, 0, $dst_w, $dst_h, $transparent);
     imagecopyresampled($newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     // convert from full colors to index colors, like original PNG.
     if (IMAGETYPE_PNG == $orig_type && !imageistruecolor($image)) {
         imagetruecolortopalette($newimage, false, imagecolorstotal($image));
     }
     // we don't need the original in memory anymore
     imagedestroy($image);
     $info = pathinfo($dest_path);
     $dir = $info['dirname'];
     $ext = $info['extension'];
     $name = basename($dest_path, ".{$ext}");
     $destfilename = "{$dir}/{$name}.{$ext}";
     if (IMAGETYPE_GIF == $orig_type) {
         if (!imagegif($newimage, $destfilename)) {
             return new WP_Error('resize_path_invalid', __('Resize path invalid'));
         }
     } elseif (IMAGETYPE_PNG == $orig_type) {
         if (!imagepng($newimage, $destfilename)) {
             return new WP_Error('resize_path_invalid', __('Resize path invalid'));
         }
     } else {
         // all other formats are converted to jpg
         //Todo: add option for use progresive JPG
         //imageinterlace($newimage, true); //Progressive JPG
         if (!imagejpeg($newimage, $destfilename, apply_filters('jpeg_quality', $jpeg_quality, 'image_resize'))) {
             return new WP_Error('resize_path_invalid', __('Resize path invalid'));
         }
     }
     imagedestroy($newimage);
     // Set correct file permissions
     $stat = stat(dirname($destfilename));
     $perms = $stat['mode'] & 0666;
     //same permissions as parent folder, strip off the executable bits
     @chmod($destfilename, $perms);
     return $destfilename;
 }
开发者ID:ahsaeldin,项目名称:projects,代码行数:60,代码来源:MF_thumb.php


示例15: _save

 protected function _save($image, $filename = null, $mime_type = null)
 {
     global $ewww_debug;
     if (!defined('EWWW_IMAGE_OPTIMIZER_DOMAIN')) {
         require_once plugin_dir_path(__FILE__) . 'ewww-image-optimizer.php';
     }
     if (!defined('EWWW_IMAGE_OPTIMIZER_JPEGTRAN')) {
         ewww_image_optimizer_init();
     }
     list($filename, $extension, $mime_type) = $this->get_output_format($filename, $mime_type);
     if (!$filename) {
         $filename = $this->generate_filename(null, null, $extension);
     }
     if ('image/gif' == $mime_type) {
         if (!$this->make_image($filename, 'imagegif', array($image, $filename))) {
             return new WP_Error('image_save_error', __('Image Editor Save Failed'));
         }
     } elseif ('image/png' == $mime_type) {
         // convert from full colors to index colors, like original PNG.
         if (function_exists('imageistruecolor') && !imageistruecolor($image)) {
             imagetruecolortopalette($image, false, imagecolorstotal($image));
         }
         if (property_exists('WP_Image_Editor', 'quality')) {
             $compression_level = floor((101 - $this->quality) * 0.09);
             $ewww_debug .= "png quality = " . $this->quality . "<br>";
         } else {
             $compression_level = floor((101 - false) * 0.09);
         }
         if (!$this->make_image($filename, 'imagepng', array($image, $filename, $compression_level))) {
             return new WP_Error('image_save_error', __('Image Editor Save Failed'));
         }
     } elseif ('image/jpeg' == $mime_type) {
         if (method_exists($this, 'get_quality')) {
             if (!$this->make_image($filename, 'imagejpeg', array($image, $filename, $this->get_quality()))) {
                 return new WP_Error('image_save_error', __('Image Editor Save Failed'));
             }
         } else {
             if (!$this->make_image($filename, 'imagejpeg', array($image, $filename, apply_filters('jpeg_quality', $this->quality, 'image_resize')))) {
                 return new WP_Error('image_save_error', __('Image Editor Save Failed'));
             }
         }
     } else {
         return new WP_Error('image_save_error', __('Image Editor Save Failed'));
     }
     // Set correct file permissions
     $stat = stat(dirname($filename));
     $perms = $stat['mode'] & 0666;
     //same permissions as parent folder, strip off the executable bits
     @chmod($filename, $perms);
     ewww_image_optimizer_aux_images_loop($filename, true);
     $ewww_debug = "{$ewww_debug} image editor (gd) saved: {$filename} <br>";
     $image_size = filesize($filename);
     $ewww_debug = "{$ewww_debug} image editor size: {$image_size} <br>";
     ewww_image_optimizer_debug_log();
     return array('path' => $filename, 'file' => wp_basename(apply_filters('image_make_intermediate_size', $filename)), 'width' => $this->size['width'], 'height' => $this->size['height'], 'mime-type' => $mime_type);
 }
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:56,代码来源:image-editor.php


示例16: imagepalettetotruecolor

 function imagepalettetotruecolor(&$src)
 {
     if (imageistruecolor($src)) {
         return true;
     }
     $dst = imagecreatetruecolor(imagesx($src), imagesy($src));
     imagecopy($dst, $src, 0, 0, 0, 0, imagesx($src), imagesy($src));
     imagedestroy($src);
     $src = $dst;
     return true;
 }
开发者ID:ittiwat,项目名称:dpf_project,代码行数:11,代码来源:functions.php


示例17: imagebmp

 function imagebmp($tipo = 'jpg', $imagesource = '', $imagebmp = 'new.bmp')
 {
     // Conviete imagen de JPG a BMP
     switch ($tipo) {
         case 'jpg':
             $im = imagecreatefromjpeg($imagesource);
             break;
         case 'png':
             $im = imagecreatefrompng($imagesource);
             break;
         case 'gif':
             $im = imagecreatefromgif($imagesource);
             break;
     }
     if (!$im) {
         return false;
     }
     $w = imagesx($im);
     $h = imagesy($im);
     $result = '';
     if (!imageistruecolor($im)) {
         $tmp = imagecreatetruecolor($w, $h);
         imagecopy($tmp, $im, 0, 0, 0, 0, $w, $h);
         imagedestroy($im);
         $im =& $tmp;
     }
     $biBPLine = $w * 3;
     $biStride = $biBPLine + 3 & ~3;
     $biSizeImage = $biStride * $h;
     $bfOffBits = 54;
     $bfSize = $bfOffBits + $biSizeImage;
     $result .= substr('BM', 0, 2);
     $result .= pack('VvvV', $bfSize, 0, 0, $bfOffBits);
     $result .= pack('VVVvvVVVVVV', 40, $w, $h, 1, 24, 0, $biSizeImage, 0, 0, 0, 0);
     $numpad = $biStride - $biBPLine;
     for ($y = $h - 1; $y >= 0; --$y) {
         for ($x = 0; $x < $w; ++$x) {
             $col = imagecolorat($im, $x, $y);
             $result .= substr(pack('V', $col), 0, 3);
         }
         for ($i = 0; $i < $numpad; ++$i) {
             $result .= pack('C', 0);
         }
     }
     if ($imagebmp == "") {
         echo $result;
     } else {
         $file = fopen($imagebmp, "wb");
         fwrite($file, $result);
         fclose($file);
     }
     return $imagebmp;
 }
开发者ID:erick120191,项目名称:adminplayidea,代码行数:53,代码来源:system_helper.php


示例18: getOptimizedGdResource

 /**
  * @param  resource $resource
  * @param  resource $controlResource
  * @return resource
  */
 public function getOptimizedGdResource($resource, $controlResource)
 {
     if (imageistruecolor($resource)) {
         $resource = $this->rh->getPalettizedGdResource($resource);
     }
     $totalColors = imagecolorstotal($resource);
     $trans = imagecolortransparent($resource);
     $reds = new \SplFixedArray($totalColors);
     $greens = new \SplFixedArray($totalColors);
     $blues = new \SplFixedArray($totalColors);
     $i = 0;
     do {
         $colors = imagecolorsforindex($resource, $i);
         $reds[$i] = $colors['red'];
         $greens[$i] = $colors['green'];
         $blues[$i] = $colors['blue'];
     } while (++$i < $totalColors);
     if (imageistruecolor($controlResource)) {
         $controlResource = $this->rh->getPalettizedGdResource($controlResource);
     }
     $controlTotalColors = imagecolorstotal($controlResource);
     $controlTrans = imagecolortransparent($controlResource);
     $controlReds = new \SplFixedArray($controlTotalColors);
     $controlGreens = new \SplFixedArray($controlTotalColors);
     $controlBlues = new \SplFixedArray($controlTotalColors);
     $i = 0;
     do {
         $colors = imagecolorsforindex($controlResource, $i);
         $controlReds[$i] = $colors['red'];
         $controlGreens[$i] = $colors['green'];
         $controlBlues[$i] = $colors['blue'];
     } while (++$i < $controlTotalColors);
     $width = imagesx($resource);
     $height = imagesy($resource);
     $y = 0;
     do {
         $x = 0;
         do {
             $index = imagecolorat($resource, $x, $y);
             $red = $reds[$index];
             $green = $greens[$index];
             $blue = $blues[$index];
             $controlIndex = imagecolorat($controlResource, $x, $y);
             $controlRed = $controlReds[$controlIndex];
             $controlGreen = $controlGreens[$controlIndex];
             $controlBlue = $controlBlues[$controlIndex];
             if (($red & 0b11111100) === ($controlRed & 0b11111100) && ($green & 0b11111100) === ($controlGreen & 0b11111100) && ($blue & 0b11111100) === ($controlBlue & 0b11111100)) {
                 imagesetpixel($resource, $x, $y, $trans);
             }
         } while (++$x !== $width);
     } while (++$y !== $height);
     return $resource;
 }
开发者ID:MagiChain,项目名称:imagecraft,代码行数:58,代码来源:GifOptimizer.php


示例19: 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


示例20: resize

 public function resize($width, $height, $keepRatio, $file, $target, $keepSmaller = true, $cropToFit = false, $jpegQuality = 75, $pngQuality = 6, $png8Bits = false)
 {
     list($oldWidth, $oldHeight, $type) = getimagesize($file);
     $i = getimagesize($file);
     switch ($type) {
         case IMAGETYPE_PNG:
             $source = imagecreatefrompng($file);
             break;
         case IMAGETYPE_JPEG:
             $source = imagecreatefromjpeg($file);
             break;
         case IMAGETYPE_GIF:
             $source = imagecreatefromgif($file);
             break;
     }
     $srcX = $srcY = 0;
     if ($cropToFit) {
         list($srcX, $srcY, $oldWidth, $oldHeight) = $this->_calculateSourceRectangle($oldWidth, $oldHeight, $width, $height);
     } elseif (!$keepSmaller || $oldWidth > $width || $oldHeight > $height) {
         if ($keepRatio) {
             list($width, $height) = $this->_calculateWidth($oldWidth, $oldHeight, $width, $height);
         }
     } else {
         $width = $oldWidth;
         $height = $oldHeight;
     }
     if (imageistruecolor($source) == false || $type == IMAGETYPE_GIF) {
         $thumb = imagecreate($width, $height);
     } else {
         $thumb = imagecreatetruecolor($width, $height);
     }
     imagealphablending($thumb, false);
     imagesavealpha($thumb, true);
     imagecopyresampled($thumb, $source, 0, 0, $srcX, $srcY, $width, $height, $oldWidth, $oldHeight);
     if ($type == IMAGETYPE_PNG && $png8Bits === true) {
         imagetruecolortopalette($thumb, true, 255);
     }
     switch ($type) {
         case IMAGETYPE_PNG:
             imagepng($thumb, $target, $pngQuality);
             break;
         case IMAGETYPE_JPEG:
             imagejpeg($thumb, $target, $jpegQuality);
             break;
         case IMAGETYPE_GIF:
             imagegif($thumb, $target);
             break;
     }
     imagedestroy($thumb);
     return $target;
 }
开发者ID:pbleuse-orange,项目名称:skoch-filter-file-resize,代码行数:51,代码来源:Gd.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imagejpeg函数代码示例发布时间:2022-05-15
下一篇:
PHP imageinterlace函数代码示例发布时间: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