![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
imagecolormatch() function in PHP
The imagecolormatch() function forms the colors of the palette version of an image more closely match the true color version
Syntax
bool imagecolormatch ( img1, img2 )
Parameters
img1: Create image with imagecreatetruecolor() function.
img2: A palette image link resource pointing to an image. This image has the same size as img1.
Return
The imagecolormatch() function returns TRUE on success or FALSE on failure.
Example
The following is an example
<?php $img1 = imagecreatefrompng('http://www.tutorialspoint.com/images/Swift.png'); $img2 = imagecreate(imagesx($img1), imagesy($img1)); $color = Array(); $color[] = imagecolorallocate($img2, 110, 40, 180); $color[] = imagecolorallocate($img2, 90, 10, 90); $color[] = imagecolorallocate($img2, 66, 170, 110); $color[] = imagecolorallocate($img2, 130,90, 70); echo imagecolormatch($img1, $img2); imagedestroy($img1); imagedestroy($img2); ?>
Output
The following is the output:
1
Example
Let us see another example
<?php $img1 = imagecreatefrompng('http://www.tutorialspoint.com/images/tp-logo-diamond.png'); $img2 = imagecreate(imagesx($img1), imagesy($img1)); $color = Array(); $color[] = imagecolorallocate($img2, 10, 1, 20); $color[] = imagecolorallocate($img2, 40, 30, 10); $color[] = imagecolorallocate($img2, 15, 100, 50); $color[] = imagecolorallocate($img2, 70, 20, 30); echo imagecolormatch($img1, $img2); imagedestroy($img1); imagedestroy($img2); ?>
Output
The following is the output:
1
Advertisements