![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
imagecolorclosestalpha() function in PHP
The imagecolorclosestalpha() function gets the index of closet color with alpha value.
Syntax
imagecolorclosestalpha ( img, red, green, blue, alpha )
Parameters
img: Image resource created with imagecreatetruecolor().
red: Red color component
green: Green color component
blue: Blue color component
alpha: The transparency of image, with 0 indicating completely opaque, whereas 127 indicating completely transparent.
Return
The imagecolorclosestalpha() function returns the index of the closest color in the palette.
Example
The following is an example:
<?php $img = imagecreatefrompng('http://www.tutorialspoint.com/images/tp-logo-diamond.png'); imagetruecolortopalette($img, false, 255); $match = imagecolorclosestalpha($img, 180, 100, 150, 110); $match = imagecolorsforindex($img, $match); $match = "({$match['red']}, {$match['green']}, {$match['blue']}, {$match['alpha']})"; echo $match; imagedestroy($img); ?>
Output
The following is the output:
(140, 130, 140, 0)
Advertisements