Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:15:56+00:00 2026-06-13T13:15:56+00:00

Please help me to count number of pixels in image, or put out the

  • 0

Please help me to count number of pixels in image, or put out the array of RGB.

So this is the script thet give me one element from array:

<?php
    $img = "1.png";
    $imgHand = imagecreatefrompng("$img");
    $imgSize = GetImageSize($img);
    $imgWidth = $imgSize[0];
    $imgHeight = $imgSize[1];
    echo '<img src="'.$img.'"><br><br>';
    for ($l = 0; $l < $imgHeight; $l++) {
        for ($c = 0; $c < $imgWidth; $c++) {
            $pxlCor = ImageColorAt($imgHand,$c,$l);
            $pxlCorArr = ImageColorsForIndex($imgHand, $pxlCor);
        }
    }


        print_r($pxlCorArr); 
?>

sorry for my english i from ukraine

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:15:57+00:00Added an answer on June 13, 2026 at 1:15 pm

    The number of pixels in an image is simply the height multiplied by the width.

    However, I think this is what you want:

    <?php
        $img = "1.png";
        $imgHand = imagecreatefrompng("$img");
        $imgSize = GetImageSize($img);
        $imgWidth = $imgSize[0];
        $imgHeight = $imgSize[1];
        echo '<img src="'.$img.'"><br><br>';
    
        // Define a new array to store the info
        $pxlCorArr= array();
    
        for ($l = 0; $l < $imgHeight; $l++) {
            // Start a new "row" in the array for each row of the image.
            $pxlCorArr[$l] = array();
    
            for ($c = 0; $c < $imgWidth; $c++) {
                $pxlCor = ImageColorAt($imgHand,$c,$l);
    
                // Put each pixel's info in the array
                $pxlCorArr[$l][$c] = ImageColorsForIndex($imgHand, $pxlCor);
            }
        }
    
        print_r($pxlCorArr); 
    ?>
    

    This will store all the pixel data for the image in the pxlCor and pxlCorArr arrays, which you can then manipulate to output what you want.

    The array is a 2d array, meaning you can refrence an individual pixel with an $pxlCorArr[y][x] starting at [0][0].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me arrange these 3 buttons horizontally like this photoshopped image: Please take
Please help me to figure this out. I am having two tab bar items
Please help me in this case. I've got an array, and I'd like to
Can any one please help with select script? desired outcome TABLENAME, ATTRIBUTE, NULLABLE, DATATYPE,
Please help me somebody to convert unicodestring into string This is how i am
Please help me with this update query. I COMPLETELY understand how redundant this is
Please help me to improve the following script: http://jsfiddle.net/n9BkM/8/ I need the following fucntionality:
Please help me understand the following code snippet :- def any(l): whether any number
Can some one please help explain why when I block and continue observer's onNext
I'm surprised that this question apparently doesn't yet exist. If it does, please help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.