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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:29:31+00:00 2026-05-29T21:29:31+00:00

I am trying to create a transparent image canvas and then place other random

  • 0

I am trying to create a transparent image canvas and then place other random images on top of this canvas. I then finally save the final image as a gif. I have tried the below:

    $canvas = imagecreatetruecolor($this->canvas_width, $this->canvas_height);
    imagesavealpha($canvas, true);
    imagealphablending($canvas, false);       

    $trans_colour = imagecolorallocatealpha($canvas, 0, 0, 0, 127);
    imagefill($canvas, 0, 0, $trans_colour); 

However, if there is some unused space left on the canvas then this part is black. I thought this area should be transparent?

Am I applying transparency correctly with the above?

  • 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-29T21:29:32+00:00Added an answer on May 29, 2026 at 9:29 pm

    imagesavealpha can not be used for images you eventually intend to save as GIF because GIF images do not have alpha channels. From the docs:

    imagesavealpha — Set the flag to save full alpha channel
    information (as opposed to single-color transparency) when saving PNG
    images

    So it only works if you are going to save the image as PNG. GIF images can do transparency, but not with an alpha channel; they can only be “transparent” or “not transparent” by defining a particular color as transparent. In PHP you can do that using imagecolortransparent. For example, to make all black transparent, you could do:

    $black_color = imagecolorallocate($canvas, 0, 0, 0);
    imagecolortransparent($canvas, $black_color); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a transparent png image and layer various other pngs and
Trying to create a background-image slideshow and am getting this error... This is the
In ASP.NET C# I'm trying to save a bitmap image as an 16-color non-transparent
I'm trying to create a web page with a transparent image that appears overtop
Trying to create a transparent gif with PIL. So far I have this: from
I am trying to create a transparent PNG image from a BufferedImage in Java.
Using this article from sun. I am trying to create a transparent window. I
I am trying to create a transparent link which sits over an image (a
I'm trying to create an image with a transparent background to display on a
im trying to create a semi-transparent form which is displayed in a panel. i

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.