By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

imagetruecolortopalette returns a max of 128 colors

P: n/a
Dear all,

I'm sure that im doing something wrong, but I can't imagine what!
My problem is the following:

I create an image using imagecreatetruecolor, and, after some
painting, I push the resulting image to the client in 256 colors:
imagetruecolortopalette($this->m_oIMG, false, 256);
header("Content-type: image/png");
if(!imagepng($this->m_oIMG)) echo("Error Creating Image!!!");

The problem is that the resulting image never contain more that 128
colors! I can't push the 24bit image because of the size, as the
images are pretty big.
As you may imagine, the final image quality is quite horrible, for an
save the image and open it with photoshop (for instance...), after
that, count the colors.

Any ideas? :)

Thx for your time,

Dec 30 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Vegethalia <ve********@gmail.comwrote:
Anyway, you know why when you tell imagetrucolortopalette to use a
certain number of colors (ie 64), it never uses as much? Is that a bug
or just an nonperfect algorithm?
The beauty of a system like PHP is that you can download the source and
look at it yourself.

The process of identifying an "ideal" 8-bit palette for a true-color image
is surprisingly complicated. Most palettized displays don't actually have
256 colors available (a few dozen are almost always reserved for system
use), so perhaps they optimized it for 128. However, I'm just pulling that
from thin air.
Tim Roberts, ti**
Providenza & Boekelheide, Inc.
Jan 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.