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


PHP ImageTrueColorToPalette函数代码示例

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


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

示例1: MaxFileSize

 function MaxFileSize()
 {
     if (phpthumb_functions::gd_version() < 2) {
         $this->DebugMessage('Skipping MaxFileSize() because gd_version is "' . phpthumb_functions::gd_version() . '"', __FILE__, __LINE__);
         return false;
     }
     if ($this->maxb > 0) {
         switch ($this->thumbnailFormat) {
             case 'png':
             case 'gif':
                 $imgRenderFunction = 'image' . $this->thumbnailFormat;
                 ob_start();
                 $imgRenderFunction($this->gdimg_output);
                 $imgdata = ob_get_contents();
                 ob_end_clean();
                 if (strlen($imgdata) > $this->maxb) {
                     for ($i = 8; $i >= 1; $i--) {
                         $tempIMG = ImageCreateTrueColor(ImageSX($this->gdimg_output), ImageSY($this->gdimg_output));
                         ImageCopy($tempIMG, $this->gdimg_output, 0, 0, 0, 0, ImageSX($this->gdimg_output), ImageSY($this->gdimg_output));
                         ImageTrueColorToPalette($tempIMG, true, pow(2, $i));
                         ob_start();
                         $imgRenderFunction($tempIMG);
                         $imgdata = ob_get_contents();
                         ob_end_clean();
                         if (strlen($imgdata) <= $this->maxb) {
                             ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i));
                             break;
                         }
                     }
                 }
                 if (strlen($imgdata) > $this->maxb) {
                     ImageTrueColorToPalette($this->gdimg_output, true, pow(2, $i));
                     return false;
                 }
                 break;
             case 'jpeg':
                 ob_start();
                 ImageJPEG($this->gdimg_output);
                 $imgdata = ob_get_contents();
                 ob_end_clean();
                 $OriginalJPEGquality = $this->thumbnailQuality;
                 if (strlen($imgdata) > $this->maxb) {
                     for ($i = 3; $i < 20; $i++) {
                         $q = round(100 * (1 - log10($i / 2)));
                         ob_start();
                         ImageJPEG($this->gdimg_output, '', $q);
                         $imgdata = ob_get_contents();
                         ob_end_clean();
                         $this->thumbnailQuality = $q;
                         if (strlen($imgdata) <= $this->maxb) {
                             break;
                         }
                     }
                 }
                 if (strlen($imgdata) > $this->maxb) {
                     return false;
                 }
                 break;
             default:
                 return false;
                 break;
         }
     }
     return true;
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:65,代码来源:phpthumb.class.php

示例2: 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:exside,项目名称:phpThumb,代码行数:14,代码来源:phpthumb.filters.php

示例3: colorDecrease

 function colorDecrease($image, $dither, $ncolors)
 {
     $width = imagesx($image);
     $height = imagesy($image);
     $colors_handle = ImageCreateTrueColor($width, $height);
     ImageCopyMerge($colors_handle, $image, 0, 0, 0, 0, $width, $height, 100);
     ImageTrueColorToPalette($image, $dither, $ncolors);
     ImageColorMatch($colors_handle, $image);
     ImageDestroy($colors_handle);
 }
开发者ID:vallejos,项目名称:samples,代码行数:10,代码来源:Wallpaper.bkp.php

示例4: init_wanted

function init_wanted($id_troll)
{
    $lesTrolls = selectDbTrolls($id_troll);
    $res = $lesTrolls[1];
    $lesVengeances = selectDbVengeances($id_troll);
    $nb_vengeances = count($lesVengeances);
    $lesGriefs = selectDbGriefs($id_troll);
    $nb_griefs = count($lesGriefs);
    $impact = PATH_IMG . "wanted_impact_{$nb_vengeances}.png";
    if ($res[nom_image_troll] != "") {
        $fp = @fopen($res["nom_image_troll"], "r");
    } else {
        $fp = false;
    }
    /*	print_r($res);
    	die("test $res[nom_image_troll]");*/
    $images = array(ImageCreateFromPng(PATH_IMG . "wanted_fond.png"), ImageCreateFromPng(PATH_IMG . "wanted_fond.png"), ImageCreateFromPng(PATH_IMG . "wanted_transparent.png"), ImageCreateFromPng($impact), ImageCreateFromPng(PATH_IMG . "wanted_grief_{$nb_griefs}.png"));
    if ($fp == false) {
        $images[2] = ImageCreateFromPng(PATH_IMG . "wanted_interrogation.png");
    } elseif (preg_match("/.*(png|Png|PNG)/", $res["nom_image_troll"])) {
        $img = ImageCreateFromJpeg($res["nom_image_troll"]);
    } elseif (preg_match("/.*(jpg|jpeg|JPG|JPEG)/", $res["nom_image_troll"])) {
        $img = ImageCreateFromJpeg($res["nom_image_troll"]);
    } elseif (preg_match("/.*(gif|Gif|GIF)/", $res["nom_image_troll"])) {
        $img = ImageCreateFromGif($res["nom_image_troll"]);
    } elseif (preg_match("/.*mountyhall.*Blason_PJ*./", $res["nom_image_troll"])) {
        $img = @ImageCreateFromGif($res["nom_image_troll"]);
        if (!$img) {
            $img = @ImageCreateFromJpeg($res["nom_image_troll"]);
            if (!$img) {
                $img = @ImageCreateFromPng($res["nom_image_troll"]);
                if (!$img) {
                    $fp = false;
                }
            }
        }
    } else {
        $images[2] = ImageCreateFromPng(PATH_IMG . "wanted_interrogation.png");
        fclose($fp);
        $fp = false;
    }
    if ($fp != false) {
        $img_src_w = imagesx($img);
        $img_src_h = imagesy($img);
        $img_dest_w = 43;
        //150 75 33
        $img_dest_h = 55;
        // 231 115 55
        imagecopyresized($images[2], $img, 30, 44, 0, 0, $img_dest_w, $img_dest_h, $img_src_w, $img_src_h);
        fclose($fp);
    }
    $image = imagemergealpha($images);
    /* -------- Destruction ------- */
    foreach ($images as $img) {
        ImageDestroy($img);
    }
    putenv('GDFONTPATH=' . realpath('.'));
    $font = "Wanted";
    $font_size = 5;
    $noir = ImageColorAllocate($image, 0, 0, 0);
    //imagettftext($image, $font_size, 0, 10, 38, $noir, $font, $res['nom_troll']);
    imagestring($image, 2, 10, 30, $res['nom_troll'], $noir);
    //imagettftext($image, $font_size, 0, 10, 38, $noir, $font, $res['nom_troll']);
    /* -------- Génération ------- */
    /* ImagePng($image,PATH_IMG.'cache/'.$res[nom_image_troll]."_avatar.png"); */
    /* -------- Cache -------- */
    $fondclair = ImageCreateFromPng(PATH_IMG . 'wanted_fond.png');
    $gifclair = imagemergealpha(array($fondclair, $image));
    $back_color = imagecolorallocate($gifclair, 0xa9, 0xb1, 0xd3);
    ImageTrueColorToPalette($gifclair, false, 256);
    ImageGif($gifclair, PATH_IMG . "cache/wanted_{$id_troll}.gif");
    /* -------- Affichage -------- */
    //Header('Content-Type: image/gif');
    // BUG PHP5
    //ImageGif($gifclair);
    $string = file_get_contents(PATH_IMG . "cache/wanted_{$id_troll}.gif");
    echo $string;
    ImageDestroy($fondclair);
    ImageDestroy($gifclair);
}
开发者ID:relaismago,项目名称:outils,代码行数:80,代码来源:wanted.php

示例5: ImageResize

 /**
  * resizes an image using several different techniques:
  *
  * PHP's own ImageCopyResamplated
  * Bi-linear filter (slower, but better quality than ImageCopyResampled)
  * Bi-Cubic filter (slowest, but offers the best quality)
  * PHP's own ImageCopyResized (fastest one, but offers no antialising or filter)
  *
  */
 function ImageResize($dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $resample = GD_RESIZER_NO_SMOOTHING_MODE)
 {
     $pxls = intval($src_w / $dst_w) - 1;
     if ($resample == GD_RESIZER_PHP_IMAGECOPYRESAMPLED) {
         imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     } elseif ($resample == GD_RESIZER_BILINEAR_MODE) {
         //slow but better quality
         ImageTrueColorToPalette($src_img, false, 256);
         ImagePaletteCopy($dst_img, $src_img);
         $rX = $src_w / $dst_w;
         $rY = $src_h / $dst_h;
         $nY = 0;
         for ($y = $src_y; $y < $dst_h; $y++) {
             $oY = $nY;
             $nY = intval(($y + 1) * $rY + 0.5);
             $nX = 0;
             for ($x = $src_x; $x < $dst_w; $x++) {
                 $r = $g = $b = $a = 0;
                 $oX = $nX;
                 $nX = intval(($x + 1) * $rX + 0.5);
                 $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $nX, $nY));
                 $r += $c['red'];
                 $g += $c['green'];
                 $b += $c['blue'];
                 $a++;
                 $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $nX - $pxls, $nY - $pxls));
                 $r += $c['red'];
                 $g += $c['green'];
                 $b += $c['blue'];
                 $a++;
                 //you can add more pixels here! eg "$nX, $nY-$pxls" or "$nX-$pxls, $nY"
                 ImageSetPixel($dst_img, $x + $dst_x - $src_x, $y + $dst_y - $src_y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
             }
         }
     } elseif ($resample == GD_RESIZER_BICUBIC_MODE) {
         // veeeeeery slow but better quality
         ImagePaletteCopy($dst_img, $src_img);
         $rX = $src_w / $dst_w;
         $rY = $src_h / $dst_h;
         $nY = 0;
         for ($y = $src_y; $y < $dst_h; $y++) {
             $oY = $nY;
             $nY = intval(($y + 1) * $rY + 0.5);
             $nX = 0;
             for ($x = $src_x; $x < $dst_w; $x++) {
                 $r = $g = $b = $a = 0;
                 $oX = $nX;
                 $nX = intval(($x + 1) * $rX + 0.5);
                 for ($i = $nY; --$i >= $oY;) {
                     for ($j = $nX; --$j >= $oX;) {
                         $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $j, $i));
                         $r += $c['red'];
                         $g += $c['green'];
                         $b += $c['blue'];
                         $a++;
                     }
                 }
                 ImageSetPixel($dst_img, $x + $dst_x - $src_x, $y + $dst_y - $src_y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
             }
         }
     } else {
         $dst_w++;
         $dst_h++;
         //->no black border
         imagecopyresized($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:76,代码来源:gallerygdresizer.class.php

示例6: retailler

 private function retailler($nouvelle_largeur, $nouvelle_hauteur, $delta_largeur, $delta_hauteur, $reduite = false)
 {
     $ret = false;
     if (!$this->is_null()) {
         $src_r = null;
         if (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_JPG) || !strcmp($this->get_ext(), _UPLOAD_EXTENSION_JPEG)) {
             $src_r = imagecreatefromjpeg($this->get_src());
         } elseif (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_PNG)) {
             $src_r = imagecreatefrompng($this->get_src());
         } elseif (!strcmp($this->get_ext(), _UPLOAD_EXTENSION_GIF)) {
             $src_r = imagecreatefromgif($this->get_src());
         }
         if ($src_r) {
             if ($this->get_ext() == _UPLOAD_EXTENSION_JPG || $this->get_ext() == _UPLOAD_EXTENSION_JPEG) {
                 $dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
                 if ($dst_r) {
                     imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
                     $qualite = $reduite ? self::qualite_jpg_reduite : self::qualite_jpg;
                     $ret = imagejpeg($dst_r, $this->get_src(), $qualite);
                     // Mise à jour des nouvelles dimensions
                     $this->largeur = $nouvelle_largeur;
                     $this->hauteur = $nouvelle_hauteur;
                     imagedestroy($dst_r);
                 }
             } elseif ($this->get_ext() == _UPLOAD_EXTENSION_PNG) {
                 $src_alpha = $this->png_has_transparency($this->get_src());
                 $dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
                 if ($dst_r) {
                     if ($src_alpha) {
                         imagealphablending($dst_r, false);
                         imagesavealpha($dst_r, true);
                     }
                     imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
                     /* En cas d'image non transparente on reduit à une image avec palette (pb de taille) */
                     if (!$src_alpha) {
                         $tmp = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
                         ImageCopyMerge($tmp, $dst_r, 0, 0, 0, 0, $nouvelle_largeur, $nouvelle_hauteur, 100);
                         ImageTrueColorToPalette($dst_r, false, 8192);
                         ImageColorMatch($tmp, $dst_r);
                         ImageDestroy($tmp);
                     }
                     $qualite = $reduite ? self::qualite_png_reduite : self::qualite_png;
                     $ret = imagepng($dst_r, $this->get_src(), $qualite);
                     // Mise à jour des nouvelles dimensions
                     $this->largeur = $nouvelle_largeur;
                     $this->hauteur = $nouvelle_hauteur;
                     imagedestroy($dst_r);
                 }
             } elseif ($this->get_ext() == _UPLOAD_EXTENSION_GIF) {
                 $dst_r = ImageCreateTrueColor($nouvelle_largeur, $nouvelle_hauteur);
                 if ($dst_r) {
                     imagecopyresampled($dst_r, $src_r, 0, 0, $delta_largeur, $delta_hauteur, $nouvelle_largeur, $nouvelle_hauteur, $this->get_largeur() - 2 * $delta_largeur, $this->get_hauteur() - 2 * $delta_hauteur);
                     $ret = imagegif($dst_r, $this->get_src());
                     // Mise à jour des nouvelles dimensions
                     $this->largeur = $nouvelle_largeur;
                     $this->hauteur = $nouvelle_hauteur;
                     imagedestroy($dst_r);
                 }
             }
             imagedestroy($src_r);
         }
     }
     return $ret;
 }
开发者ID:PetiLabo,项目名称:PetiLabo,代码行数:64,代码来源:submit_image.php

示例7: adaptive_images_script_generate_image

/**
 * Generates a resized version of an image and saves it in the image cache folder.
 * 
 * @param string $source_file The original image to be resized.
 * @param string $cache_file  The target file where the resized version will be cached.
 * @param int    $resolution  The resolution breakpoint at which the given image is to be resized.
 * @param int    $jpg_quality The JPEG quality that will be used for resizing the images.
 * @param bool   $sharpen     Whether to sharpen the resized images or not.
 * 
 * @return array Associative array( bool: success, string: message) with the result of the image cache generation.
 */
function adaptive_images_script_generate_image($source_file, $cache_file, $resolution, $jpg_quality, $sharpen)
{
    // Get original image dimensions.
    $dimensions = @GetImageSize($source_file);
    $width = $dimensions[0];
    $height = $dimensions[1];
    // Calculate resized image dimensions.
    $ratio = $height / $width;
    $new_width = $resolution;
    $new_height = ceil($new_width * $ratio);
    // Start creating the resized image with a blank true color canvas.
    $destination = @ImageCreateTrueColor($new_width, $new_height);
    $extension = adaptive_images_script_get_file_extension($source_file);
    switch ($extension) {
        case 'png':
            $source = @ImageCreateFromPng($source_file);
            break;
        case 'gif':
            $source = @ImageCreateFromGif($source_file);
            break;
        default:
            $source = @ImageCreateFromJpeg($source_file);
            break;
    }
    // PNG images generation.
    if ($extension == 'png') {
        // Create a transparent color and fill the blank canvas with it.
        $rbga_color = @ImageColorAllocateAlpha($destination, 0, 0, 0, 127);
        @ImageColorTransparent($destination, $rbga_color);
        @ImageFill($destination, 0, 0, $rbga_color);
        // Copy source image to destination image with interpolation.
        @ImageCopyResampled($destination, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        // Convert true colour image to pallette image to achieve PNG-8 compression.
        $dither = TRUE;
        @ImageTrueColorToPalette($destination, $dither, 255);
        // Save alpha (transparency) of destination image.
        $save_alpha = TRUE;
        @ImageSaveAlpha($destination, $save_alpha);
        // Disable blending of destination image to allow for alpha (transparency) above.
        $enable_alpha_blending = FALSE;
        @ImageAlphaBlending($destination, $enable_alpha_blending);
    }
    // GIF images generation.
    if ($extension == 'gif') {
        // Create a transparent color and fill the blank canvas with it.
        $rbga_color = @ImageColorAllocateAlpha($destination, 0, 0, 0, 127);
        @ImageColorTransparent($destination, $rbga_color);
        @ImageFill($destination, 0, 0, $rbga_color);
        // Copy source image to destination image with interpolation.
        @ImageCopyResampled($destination, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        // Convert true colour image to pallette image to achieve PNG8 compression.
        $dither = TRUE;
        @ImageTrueColorToPalette($destination, $dither, 255);
        // Enable alpha blending of destination image.
        $enable_alpha_blending = TRUE;
        @ImageAlphaBlending($destination, $enable_alpha_blending);
    }
    // JPEG images generation.
    if ($extension == 'jpg' || $extension == 'jpeg') {
        // Enable JPEG interlacing.
        ImageInterlace($destination, TRUE);
        // Interpolates source image to destination image to make it more clear for JPGs.
        @ImageCopyResampled($destination, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    }
    // Cleanup source image from memory.
    @ImageDestroy($source);
    // Do sharpening if requested.
    if ($sharpen && function_exists('imageconvolution')) {
        $sharpness_factor = adaptive_images_script_sharpness_factor($width, $new_width);
        $sharpness_transformation_matrix = array(array(-1, -2, -1), array(-2, $sharpness_factor + 12, -2), array(-1, -2, -1));
        // OR
        // $sharpenMatrix = array
        // (
        //     array(-1.2, -1, -1.2),
        //     array(-1, 20, -1),
        //     array(-1.2, -1, -1.2)
        // );
        // $divisor = array_sum(array_map('array_sum', $sharpenMatrix));
        // OR
        // $sharpen = array(
        //     array(0.0, -1.0, 0.0),
        //     array(-1.0, 5.0, -1.0),
        //     array(0.0, -1.0, 0.0)
        // );
        // $divisor = array_sum(array_map('array_sum', $sharpen));
        // OR
        // $matrix = array(
        //     array(-1, -1, -1),
        //     array(-1, 16, -1),
//.........这里部分代码省略.........
开发者ID:bchamberlain88,项目名称:pavati,代码行数:101,代码来源:adaptive-images-script.php

示例8: ImageTrueColorToPalette2

function ImageTrueColorToPalette2($original_image, $dither, $ncolors)
{
    $width = imagesx($original_image);
    $height = imagesy($original_image);
    $colors_handle = ImageCreateTrueColor($width, $height);
    imagecopymerge($colors_handle, $original_image, 0, 0, 0, 0, $width, $height, 100);
    ImageTrueColorToPalette($original_image, $dither, $ncolors);
    ImageColorMatch($colors_handle, $original_image);
    ImageDestroy($colors_handle);
    return $original_image;
}
开发者ID:kklingman,项目名称:imagemanager,代码行数:11,代码来源:ImageServer.php

示例9: createThumb

 public function createThumb($dir, $prefix, $max_x = false, $max_y = false, $prefixIsRealName = false, $mode = 'square')
 {
     if (!isset($this->hash)) {
         return FALSE;
     }
     if (!$dir) {
         $dir = dirname($this->file);
     }
     if (!$prefix) {
         $prefix = 't';
     }
     if (!$max_x && !$max_y || intval($max_x) <= 0 && intval($max_y) <= 0) {
         throw new PException('Neither thumbnail max-width nor max-height provided!');
     }
     $size_x = $this->imageSize[0];
     $size_y = $this->imageSize[1];
     // old school
     if (!$max_x || !$max_y) {
         if ($max_x && intval($max_x) > 0 && $size_x) {
             $th_size_x = intval($max_x);
             $th_size_y = intval($size_y * $th_size_x / $size_x);
             $size_x = $th_size_x;
             $size_y = $th_size_y;
         }
         if ($max_y && intval($max_y) > 0 && $size_y > $max_y) {
             $th_size_y = intval($max_y);
             $th_size_x = intval($size_x * $th_size_y / $size_y);
         }
         $startx = 0;
         $starty = 0;
         $size_x = $this->imageSize[0];
         $size_y = $this->imageSize[1];
     } else {
         switch ($mode) {
             case "ratio":
                 if ($max_x / $size_x >= $max_y / $size_y) {
                     $ratio = $max_y / $size_y;
                 } else {
                     $ratio = $max_x / $size_x;
                 }
                 $startx = 0;
                 $starty = 0;
                 break;
             default:
                 if ($size_x >= $size_y) {
                     $startx = ($size_x - $size_y) / 2;
                     $starty = 0;
                     $size_x = $size_y;
                 } else {
                     $starty = ($size_y - $size_x) / 2;
                     $startx = 0;
                     $size_y = $size_x;
                 }
                 if ($max_x >= $max_y) {
                     $ratio = $max_y / $size_y;
                 } else {
                     $ratio = $max_x / $size_x;
                 }
                 break;
         }
         $th_size_x = $size_x * $ratio;
         $th_size_y = $size_y * $ratio;
     }
     switch (intval($this->imageSize[2])) {
         // note: fixed this to use the proper constants. IMG_*** are GD constants, IMAGETYPE_*** are PHP constants.
         // The two DO NOT mix
         case IMAGETYPE_GIF:
             $oldImage = ImageCreateFromGIF($this->file);
             break;
         case IMAGETYPE_JPEG:
             $oldImage = ImageCreateFromJPEG($this->file);
             break;
         case IMAGETYPE_PNG:
             $oldImage = ImageCreateFromPNG($this->file);
             break;
         case IMAGETYPE_WBMP:
             $oldImage = ImageCreateFromWBMP($this->file);
             break;
         default:
             $e = new PException('Image type not supported!');
             $e->addInfo(print_r($this->imageSize, TRUE));
             throw $e;
             break;
     }
     $newImage = ImageCreateTrueColor($th_size_x, $th_size_y);
     imageCopyResampled($newImage, $oldImage, 0, 0, $startx, $starty, $th_size_x, $th_size_y, $size_x, $size_y);
     $newFile = tempnam('Lorem ipsum dolor sit amet', 'thumb');
     switch ($this->imageSize[2]) {
         case IMAGETYPE_GIF:
             ImageTrueColorToPalette($newImage, TRUE, 256);
             ImageGIF($newImage, $newFile);
             $mimetype = 'image/gif';
             break;
         case IMAGETYPE_JPEG:
             ImageJPEG($newImage, $newFile);
             $mimetype = 'image/jpeg';
             break;
         case IMAGETYPE_PNG:
             ImagePNG($newImage, $newFile);
             $mimetype = 'image/png';
//.........这里部分代码省略.........
开发者ID:gpuenteallott,项目名称:rox,代码行数:101,代码来源:image.lib.php

示例10: reduce_colors

 /**
  * Converts an image to n-colours
  *
  * @param integer $colors Number of colours in pallete
  * @return boolean Whether it was sucessful
  * @access public
  */
 function reduce_colors($colors = 255)
 {
     //convert o,age to 256 colours
     if (!function_exists("ImageTrueColorToPalette")) {
         return false;
     }
     ImageTrueColorToPalette($this->im, 1, $colors);
     return true;
 }
开发者ID:xav335,项目名称:adanimalerie,代码行数:16,代码来源:imagemanipulator.php

示例11: colorDecrease

 private function colorDecrease()
 {
     $gifFInal = TMPDIR . "/" . $this->outWidth . "x" . $this->outHeight . "_T.gif";
     if ($this->inFormat == "image/jpeg") {
         $src_img = ImageCreateFromJPEG($this->inPath) or die('colorDecrease: Problema leyendo jpg original');
     } else {
         $src_img = ImageCreateFromGIF($this->inPath) or die('colorDecrease: Problema leyendo gif original');
     }
     $dest_img = imagecreatetruecolor($this->outWidth, $this->outHeight) or die('colorDecrease: Problema en la creaci�n de la imgen nueva gif');
     imagecopy($dest_img, $src_img, 0, 0, 0, 0, $this->outWidth, $this->outHeight);
     ImageTrueColorToPalette($dest_img, true, $this->nColors);
     ImageColorMatch($src_img, $dest_img);
     if (!imagegif($dest_img, $gifFInal)) {
         die("colorDecrease: Problema guardando la IMG gif en: {$outPath}");
     }
     ImageDestroy($dest_img);
     $this->actualSize = filesize($gifFInal);
     if ($this->actualSize > $this->maxFileSize) {
         $this->nColors--;
         if (unlink($gifFInal)) {
             $this->colorDecrease();
         }
     } else {
         unlink($this->jpgGifXcolors);
     }
 }
开发者ID:vallejos,项目名称:samples,代码行数:26,代码来源:imgConverter.class.php


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