Hi Galen,
Thanks for that - all sorted now. I had looked at
imagetruecolortopalette, but had not taken it on board. I'm now using
it as follows to get a balance between image quality and file size (for
png output):
imagetruecolortopalette ( $myImage, true, 64);
It's just remarkable how much better quality I can get for a given size
with jpeg as opposed to png - but then I'm unable to use jpeg for my
current application.
Many, many thanks for your help.
CHEERS> SAM
Galen wrote:
Sam,
OK, sorry, I only had a few moments before. Let's see if this points
you in the right direction.
Basically, you can have "standard" 8-bit images ("color") and then
"true" color images (24 bit). When you "create" the GD image
resource, you use a function to do that. One such function is
imagecreate() - this generates a palette based image that (IIRC, 8
bit or less) will compress to that smaller PNG 8 file.
imagecreatetruecolor() typically makes full-depth ("true color")
images that become PNG 24/32 and support transparency and everything.
You may find imagetruecolortopalette() also of interest as it
transforms a true color image into a palette based image.
So the distinction is this: true color = 32 bit (24 bit + alpha
channel), palette based = exact number of colors + no alpha channel
I may be subtly wrong on a few of these smaller points, and please
accept my apologies if I am, but the gist is that you need a
palette-based image to get 8-bit PNGs!
-Galen
On May 14, 2004, at 4:27 PM, Sam Joseph wrote:
Hi Galen,
Many thanks for your reply. I tried to find things in the php
manual relating to bit depth, but I didn't find anything relevant:
http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF
-8&oe=UTF-8&q=site:www%2Ephp%2Enet+bit+depth
I haven't read every single one of the image functions in detail,
but I did look through them all, and at the moment I can't see
anything that allows me to manipulate the bit depth. The closest
thing I can see is the imagecolorstotal function which returns the
number of colors in the specified image's palette.
Apologies if I'm missing something obvious, but if anybody knows
about a specific function that does this I'd be very interested to
hear about it.
Many thanks in advance.
CHEERS> SAM
Galen wrote:
IIRC, the goal of PNG is lossless output and it outputs that
exactly with PHP. What you send is what you get out. When you're
using GD, I suggest you make an 8 bit GD image resource, then make
that into PNG. There are several functions dealing with converting
bit depth and such, poke around the GD image reference section in
the PHP manual.
Sorry if this is too vague, it's all off the top of my head but I
think it will give you enough to go on.
-Galen
On May 14, 2004, at 3:05 PM, Sam Joseph wrote:
Hi all,
I've recently got the GD libraries set up and working with php and
I have been resizing and reformating images to my hearts content.
One thing I notice however is that when I output png images they
seem by default to come out in the larger size PNG32 format, as
opposed to the lightweight PNG8 format that I would prefer.
I've checked the archives and googled and found no direct
reference to this issue.
If anybody can tell me how to adjust the png output format php I'd
be very grateful. Although I have the feeling that this might
well require hacking away at the gd source
Thanks in advance.
CHEERS> SAM
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php