Re: Reading only RGB portion of an image, file_get_conents minus file headers etc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23 January 2012 13:26, Matijn Woudt <tijnema@xxxxxxxxx> wrote:
> On Mon, Jan 23, 2012 at 1:51 PM, Nicholas Cooper <nicholas@xxxxxxxxxxxxx> wrote:
>> Hi everyone,
>>
>> I've created an image in RGB from ImageMagick, it's 4 by 4 so I'm
>> expecting 48 numbers (4*4*3). [width*height*(R,G,B)]
>>
>> When I read the file with PHP and unpack it I get between 330 and 333,
>> I guess this difference is down to headers and end of file data.  Is
>> there anyway to access only the useful image bits, those 48 numbers?
>>
>> Thank you,
>>
>> Nicholas Cooper
>>
>
> Hi,
>
> The easiest way is probably using imagecolorat[1]. Just do a nested
> for loop over x and y values, and call imagecolorat for each pixel.
>
> Matijn
>
> [1] www.php.net/imagecolorat

Thank you that does the trick and gives the expected output.  I plan
to be processing a large number of images and have always been wary of
using the built in image functions for performance reasons.  So if
there is any other solutions I'm welcome to them, or even if someone
just wants to say that performance is not such an issue any more.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux