|
użytkowników online: 18
|
OPINIE UŻYTKOWNIKÓW
|
Po wysłaniu do Dariusza problemu jeszcze nie opisanego w poradach, odpowiedź pojawia się na stronach już po 24 godzinach. To jedna z najważniejszych zalet serwisu! Za około 100 złotych rocznie mam profesjonalnego i doświadczonego konsultanta od technologii internetowych! Polecam serwis z poradami każdemu webmasterowi, niezależnie od stażu pracy i umiejętności.
Paweł Kowalski
grupa hiperMEDIA.pl
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
imagetruecolortopalette (PHP 4 >= 4.0.6, PHP 5) imagetruecolortopalette -- Convert a true color image to a palette image Descriptionvoid imagetruecolortopalette ( resource image, bool dither, int ncolors )
imagetruecolortopalette() converts a truecolor image
to a palette image. The code for this function was originally drawn from
the Independent JPEG Group library code, which is excellent. The code
has been modified to preserve as much alpha channel information as
possible in the resulting palette, in addition to preserving colors as
well as possible. This does not work as well as might be hoped. It is
usually best to simply produce a truecolor output image instead, which
guarantees the highest output quality.
dither indicates if the image should be dithered -
if it is TRUE then dithering will be used which will result in a more
speckled image but with better color approximation.
ncolors sets the maximum number of colors that
should be retained in the palette.
Notatka: Fa funkcja wymaga GD 2.0.1 lub nowszego.
User Contributed Noteszmorris at zsculpt dot com
17-Aug-2004 07:58
Sometimes this function gives ugly/dull colors (especially when ncolors < 256). Here is a replacement that uses a temporary image and ImageColorMatch() to match the colors more accurately. It might be a hair slower, but the file size ends up the same:
<?php
function ImageTrueColorToPalette2( $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 );
}
?>
php at roelvanmastbergen dot nl
06-Jun-2004 06:34
The palette created by this function often looks quite awful (at least it did on all of my test images). A better way to convert your true-colour images is by first making a resized copy of them with imagecopyresampled() to a 16x16 pixel destination. The resized image then contains only 256 pixels, which is exactly the number of colours you need. These colours usually look a lot better than the ones generated by imagetruecolortopalette().
The only disadvantage to this method I have found is that different-coloured details in the original image are lost in the conversion.
jemore at nospaM dot m6net dot fr
22-Nov-2003 07:25
If you open a truecolor image (with imageCreateFromPng for example), and you save it directly to GIF format with imagegif, you can have a 500 internal server error. You must use imageTrueColorToPalette to reduce to 256 colors before saving the image in GIF format.
darkelder at php dot net
17-Jul-2003 10:34
TrueColor images should be converted to Palette images with this function. So, if you want to use imagecolorstotal() function [ http://php.net/manual/en/function.imagecolorstotal.php ] , you should first convert the image to a palette image with imagetruecolortopalette();
|