Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | imagecolortransparent() Function
Next article icon

PHP | imagecolortransparent() Function

Last Updated : 23 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The imagecolortransparent() function is an inbuilt function in PHP which is used to define color as transparent. It sets the color of a transparent image. It returns the identifier of the new transparent color. If an image has no transparent color and color not specified then it returns -1. Syntax:
int imagecolortransparent ( $image, $color )
Parameters: This function accepts two parameters as mentioned above and described below:
  • $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image.
  • $color: This parameter is used to set the color identifier created by imagecolorallocate() function.
Return Value: This function returns the identifier of the new transparent color. If the color of an image is not specified and the image has no transparent color then it returns -1. Below programs illustrate the imagecolortransparent() function in PHP: Program 1: php
<?php  // Create an image of size 500x400 $image = imagecreatetruecolor(500, 400);  // Allocate green color to image $green = imagecolorallocate($image, 0, 153, 0);  // Allocate black color to image $black = imagecolorallocate($image, 0, 0, 0);   // Make the background transparent imagecolortransparent($image, $black);   // Draw a green filled rectangle  imagefilledrectangle($image, 50, 50, 450, 300, $green);   // Output the image to the browser header('Content-Type: image/png');    imagepng($image);   imagedestroy($image); ?> 
output: image transparent Program 2: php
<?php  // Create an image of size 500x400 $image = imagecreatetruecolor(500, 400);  // Allocate green color to image $green = imagecolorallocate($image, 0, 153, 0);  // Allocate black color to image $black = imagecolorallocate($image, 0, 0, 0);   // Make the background transparent imagecolortransparent($image, $black);   // Function to draw the circle imageellipse($image, 250, 200, 250, 250, $green);   // Output the image to the browser header('Content-Type: image/png');    imagepng($image);   imagedestroy($image); ?> 
Output: transparent background image Related Articles:
  • PHP | imageellipse() Function
  • PHP | imagecolorstotal() Function
  • PHP | imagecolorresolve() Function
Reference: http://php.net/manual/en/function.imagecolortransparent.php

Next Article
PHP | imagecolortransparent() Function

V

vijay_raj
Improve
Article Tags :
  • Misc
  • Web Technologies
  • PHP
  • Image-Processing
  • PHP-function
Practice Tags :
  • Misc

Similar Reads

    PHP | imagecolorset() Function
    The imagecolorset() function is an inbuilt function in PHP which is used to set the color for the specified palette index. It is used to specify the index in the palette to the specified color. To perform the actual flood-fill, it is useful to create the flood-fill-like effects in palleted images wi
    2 min read
    PHP | imagecolorat() function
    The imagecolorat() function is an inbuilt function in PHP which is used to get the index of the color of the pixel. This function returns the pixel value at the specified location.Syntax:   int imagecolorat( $image, $x, $y ) Parameters: This function accepts three parameters as mentioned above and d
    2 min read
    PHP | imagecolorexactalpha() Function
    The imagecolorexactalpha() function is an inbuilt function in PHP which is used to get the index of the specified color with alpha value. This function returns the index of the specified color and alpha value (RGBA value) in the palette of the image. Syntax: int imagecolorexactalpha ( $image, $red,
    2 min read
    PHP | imagecolorexact() Function
    The imagecolorexact() function is an inbuilt function in PHP which is used to get the index of specified color in the palette of the image. In created image files only used colors in the image are resolved. Colors present only in the palette are not resolved. Syntax: int imagecolorexact ( $image, $r
    2 min read
    PHP | imagecolorresolve() Function
    The imagecolorresolve() function is an inbuilt function in PHP which is used to get the index of the specified color or its closest possible alternative color. This function returns a color index value for a requested color, either the exact matched color or the closest possible alternative. Syntax:
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences