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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:27:13+00:00 2026-06-01T08:27:13+00:00

I am trying to create a chart with PHP and GD. The chart is

  • 0

I am trying to create a chart with PHP and GD. The chart is already working but I
can’t get the background to be transparent (with anti-aliasing).

I want to place an anti-aliased line on a gradient background (this is the HTML background) but it shows some white pixels (see the image link and my code below). Is it possible to do this with GD? I have searched a lot on the Internet but can’t find any solutions.

Image showing aliasing problem

PHP

<?php
$img = imagecreatetruecolor(1000, 1000);

imagesavealpha($img, true);
imagealphablending($img, true);

$color = imagecolorallocatealpha($img, 255, 255, 255, 127); 
$red = imagecolorallocate($img, 255, 0, 0); 

imagefill($img, 0, 0, $color);

imageantialias($img, true);
imageline($img, 10, 10, 500, 20, $red);

header("content-type: image/png");
imagepng($img); 
imagedestroy($img); 
?>

HTML

<style type="text/css">
    body{
        background:url('/Image/background.png');
    }
</style>

<img src="./example.php" />
  • 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-01T08:27:14+00:00Added an answer on June 1, 2026 at 8:27 am

    The PHP manual basically states that you cannot:

    It does not support alpha components. It works using a direct blend
    operation. It works only with truecolor images.

    Thickness and styled are not supported.

    Using antialiased primitives with transparent background color can end
    with some unexpected results. The blend method uses the background
    color as any other colors. The lack of alpha component support does
    not allow an alpha based antialiasing method.

    http://es.php.net/imageantialias

    So unless someone comes with third-party code or some witty hacks, you’re out of luck.

    • 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 visualized chart using Jquery Highcharts plug-in. But I'm unable
I'm trying to create a chart using the Google Visualization API, with PHP &
I am trying to create a magento shopping cart module but things arent working
I am trying to create a chat application in .net but I am confused
I'm trying to create a very simple chat application in Flex/.Net using FluorineFX but
I'm trying to create a sample bar chart or pie chart from a MySQL
I am trying to create a scatter chart on my web page with CSS
Im trying to create a page in which users can search for items on
i have been trying to get the source of a page in php using
I've been trying to create a chart that looks similar to Google's Finance Charts

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.