Tutorialspoint

PHP imagecreatetruecolor() function

<?php
   $img = imagecreatetruecolor(600, 500);
   echo imagesy($img);
   echo "<br>";
   echo imagesx($img);
?>

PHP imagecolorresolve() function

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   $colors = array();
   $colors[] = imagecolorresolve($img, 120, 0, 190);
   $colors[] = imagecolorresolve($img, 110, 0, 140);
   $colors[] = imagecolorresolve($img, 120, 190, 0);
   print_r($colors);
   imagedestroy($img);
?>

PHP imagecolorstotal() function

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   echo 'Number of Colors = ' . imagecolorstotal($img);
   imagedestroy($img);
?>

PHP imagecolorsforindex() function

<?php
   $img = imagecreatefrompng('http://www.tutorialspoint.com/images/tp-logo-diamond.png');
   $x = 25;
   $y = 45;
   $rgb = imagecolorat($img, 25, 45);
   $colors = imagecolorsforindex($img, $rgb);
   var_dump($colors);
?>

PHP imagecolorresolvealpha() function

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   $colors = array();
   $colors[] = imagecolorresolvealpha($img, 120, 0, 190,0);
   $colors[] = imagecolorresolvealpha($img, 110, 0, 140,0);
   $colors[] = imagecolorresolvealpha($img, 120, 190, 0,0);
   print_r($colors);
   imagedestroy($img);
?>

PHP imagecolorclosest() function

<?php
   $img = imagecreatefrompng(
   'https://www.tutorialspoint.com/assets/videos/courses/19/images/course_19_image.png');
   imagetruecolortopalette($img, false, 255);
   $val = imagecolorclosest($img, 20, 90, 140);
   $val = imagecolorsforindex($img, $val);
   $val = "({$val['red']}, {$val['green']}, {$val['blue']})";
   echo "Closest = " . $val;
   imagedestroy($img);
?>

PHP imagecolorexact() function

<?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);
?>

PHP imagecolorclosesthwb() function

<?php
   $img = imagecreatefromgif(
   'https://www.tutorialspoint.com/images/html.gif');
   echo 'HWB = '
.  imagecolorclosesthwb($img, 50, 110, 90);
   imagedestroy($img);
?>

PHP imagecolorclosestalpha() function

<?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);
?>

PHP imagesx() function

<?php
   $img = imagecreatetruecolor(450, 250);
   echo imagesx($img);
?>

1 2 3 4 5 6 7 ... 34 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.