![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
imagecolorexact() function in PHP
The imagecolorexact() function gets the index of the specified color.
Syntax
imagecolorexact ( $img, $red, $green, $blue )
Parameters
img: Image resource created with imagecreatetruecolor().
red: Red color component
green: Green color component
blue: Blue color component
Return
The imagecolorexact() function returns the index of the specified color in the palette, or -1 if the color does not exist.
Example
The following is an example:
<?php $img = imagecreatefrompng('https://www.tutorialspoint.com/assets/videos/courses/67/images/course_67_image.png'); $colors = Array(); $colors[] = imagecolorexact($img, 30, 90, 50); $colors[] = imagecolorexact($img, 80, 120, 100); $colors[] = imagecolorexact($img, 25, 80, 50); print_r($colors); imagedestroy($img); ?>
Output
The following is the output:
Array ( [0] => 1989170 [1] => 5273700 [2] => 1658930 )
Advertisements