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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:53:07+00:00 2026-05-30T10:53:07+00:00

I wrote this code that was supposed to draw a black line of 1px

  • 0

I wrote this code that was supposed to draw a black line of 1px at the bottom of an image, but it isn’t working as expected and it generates a totally black image:

    $img = imagecreatefrompng("image.png");    
    $dest = imagecreatetruecolor(50, 25);
    imagecopy($dest, $img, 0, 0, $px + $position[$pos][0], $py + $position[$pos][1] , 50, 25);
    $w = imagesx($dest);
    $h = imagesy($dest);
    $out = ImageCreateTrueColor(imagesx($dest),imagesy($dest)) or die('Problem In Creating image');

    for( $x=0; $x<$w; $x++) {
        imagesetpixel($out, $x, $h, imagecolorallocate($out, 0, 0, 0));
    }

Where’s the problem?

  • 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-05-30T10:53:09+00:00Added an answer on May 30, 2026 at 10:53 am

    The problem is that you’re drawing your line on the $out image, which has nothing in it.

    1. You load up $img (the original).
    2. you create $dest
    3. you resize $img into $dest
    4. you create $out
    5. you draw the line on $out.

    $out never gets a copy of either the original or resized image, so it stays at the default all-black. You then draw a black line on a black image… ending up with a black image.

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

Sidebar

Related Questions

I wrote this piece of code that is supposed to redirect something written on
I wrote this code that compiles on Solaris gcc it works fine too for
I have a program I wrote in Windows with this piece of code that
this is my code that I write it but I want to use LINQ
I want to write a line of code that returns a pointer to this
I wrote this code for zoom in/out . it works but even with one
I wrote this code and there is a problem that I can't seem to
How to write this JavaScript code without eval? var typeOfString = eval(typeof + that.modules[modName].varName);
I'm trying to write a code that could print something like this -xv -xvv
I'm trying to write a regular expression for html code that looks like this:

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.