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 7864599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:50:01+00:00 2026-06-02T23:50:01+00:00

I have an array of pixel data in a JSON object. I’m attempting to

  • 0

I have an array of pixel data in a JSON object. I’m attempting to use PHP to redraw the pixel data to a GD image.

I’m using something like the following (Notice for testing purposes, I’ve started the index for the loop at 5000, about halfway into the array.)

$im = imagecreate($w,$h);
$i=5000;
while($i < count($pixels)){
    $item = $data[$i];
    $rgb = $item['rgb'];
    $pos = $item['pos'];
    $col = imagecolorallocate($im, $rgb[0],$rgb[1],$rgb[2]);
    imagesetpixel($im , $pos[0], $pos[1], $col);
    $i++;
}
header("Content-Type: image/png");
imagepng($im);

It seems my script is only making it so far down the array before it cuts out and dumps the image out with no error.

Below is the output when I start the array index about halfway thru the length of the array. I get a very small part of the image.

enter image description here

Is this due to memory? Or a timeout? The page doesn’t take long to load or anything…

  • 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-02T23:50:03+00:00Added an answer on June 2, 2026 at 11:50 pm

    Ok, for anyone else with this problem. Here’s the fix. Use imagecreatetruecolor instead of imagecreate. It seems that imagecolorallocate can only allocate up to 255 colors when using imagecreate. While imagecreatetruecolor has no such limitation.

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

Sidebar

Related Questions

I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have an array of ushort pixel data (16-bit grayscale values), and I am
I have an array of ushort pixel data that I need to save as
In F#, imagine we have an array of bytes representing pixel data with three
How is the image data saved with an uint8 array? Say that I have
I have some Javascript code that acts on an pixel array defined like so:
I have a numpy array of pixel data that I want to draw at
How do I redraw the pixel array after I after I have previously used
I have an array that contains the RGB colour values for each pixel in
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>

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.