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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:39:44+00:00 2026-06-08T10:39:44+00:00

I have a script that creates an image whose height depends on the depth

  • 0

I have a script that creates an image whose height depends on the depth of a recursive tree. Precalculating the height of the image would be a pain, because I would need to run a recursive function twice. Thus, I wonder if it is possible to resize the image from inside my only recursive function. Long story short, I need to resize an image resource, is it possible? For instance, how can I make the following code work? Thanks!

//Create the image
$image = imagecreatetruecolor(800, 100);

//Change the image height from 100 to 1000 pixels
imagecopyresized($image, $image, 0, 0, 0, 0, 800, 1000, 800, 100);

//Set the header
header('Content-Type: image/png');

//Output the image
imagepng($image);

//Destroy the image
imagedestroy($image);
  • 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-08T10:39:47+00:00Added an answer on June 8, 2026 at 10:39 am

    Your code is almost perfect, except you aren’t giving it the source image to work with. You need $source = imagecreatefrompng("someimage.png");, and then in your imagecopyresize set the source image argument to $source.

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

Sidebar

Related Questions

I have a script that creates an image and calls imagepng to output it
I have php script that creates a temporary watermark image for users that are
I have a script that creates a thumbnail out of an uploaded image. it
I have a PHP script that creates a thumbnail and lists an image gallery.
I have a project that creates a disk image and would like to use
I have written a CGI script that creates an image dynamically using GET data.
i have a script that creates divs with some background image then moves them,
I have Ruby script that creates a proxy so that I can make HTTP
Hi I have a script that creates a file and stores it on the
I have a PHP script that creates large complex tables. I am attempting to

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.