php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22413 imagecolorstotal() returns 0 from 24 bit colour images
Submitted: 2003-02-25 04:38 UTC Modified: 2003-02-25 12:39 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: skotske at hotmail dot com Assigned:
Status: Wont fix Package: GD related
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-02-25 04:38 UTC] skotske at hotmail dot com
When assigning the number of colours to a variable imagecolorstotal() returns 0.

$total = imagecolorstotal($image);
echo($total);

I was testing the greyscale example from here:

http://www.php.net/manual/en/function.imagecreatetruecolor.php

GD installed:

GD Support enabled
GD Version bundled (2.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled

Tests.  I tried this with:
gif - returns 256
jpeg (24bit colour) - returns 0
png 8bit - returns 256
png 24bit - returns 0

All the same image source image saved to the different formats from photoshop.

I've also tested the script on an older redat install and it works for all (well kinda - returns max 256, but that's an old release so who cares)  

details of the older machine:

PHP Version 4.1.2

GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with TTF library
JPG Support enabled
PNG Support enabled
WBMP Support enabled

Ideally you'd want more than 256 colors anyway?  And maybe that's what supposed to happen?  

Saw a couple of non-english postings about it in google groups from what I could make out

I've also searched the bug database and could only find a passing mention as an aside to a different bug so......

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-25 08:55 UTC] iliaa@php.net
24/32 bit color images have too many colors to count. In order to offer the requested functionality PHP would need to go through every single pixel of the image analyzing the colors used and creating an array of stored colors. This is simply way too slow & memory consuming to be implemented.
 [2003-02-25 12:39 UTC] skotske at hotmail dot com
Ah fair enough - it was more fact that it no longer returns 256 colours that made me think it was a bug. Even this limited functionality is / was useful and as it worked with earlier versions i thought something had 'broken'.  Sorry to waste your time.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 06:01:23 2020 UTC