কম্পিউটার টিউটোরিয়াল

PHP-তে imagecolorat() ফাংশন

পরিচয়

PHP-তে imagecolorat() ফাংশনটি একটি ছবির নির্দিষ্ট কোঅর্ডিনেটে (x, y) অবস্থিত পিক্সেলের রঙের সূচক (color index) ফেরত দেয়।_TRUE COLOR ছবির ক্ষেত্রে এটি সরাসরি RGB মান ফেরত দেয়।

সিনট্যাক্স

imagecolorat($img, $x, $y): int|false

প্যারামিটারসমূহ

  • img − imagecreatetruecolor() দিয়ে তৈরি করা ছবি রিসোর্স।

  • x − পিক্সেলের x-কোঅর্ডিনেট (বাম থেকে ডানে)۔

  • y − পিক্সেলের y-কোঅর্ডিনেট (উপর থেকে নিচে)۔

রিটার্ন ভ্যালু

পিক্সেলের রঙ সূচক (integer) ফেরত দেয়। _TRUE COLOR ছবির ক্ষেত্রে এটি ০xRRGGBB ফরম্যাটে RGB মান থাকে। প্যালেট ছবির ক্ষেত্রে প্যালেট সূচক ফেরত দেয়। ব্যর্থ হলে false।

উদাহরণ

<?php
$img = imagecreatefrompng("https://www.tutorialspoint.com/images/tp-logo-diamond.png");
$rgb = imagecolorat($img, 15, 25);
$colors = imagecolorsforindex($img, $rgb);
var_dump($colors);
?>

আউটপুট

array(4) {
  ["red"]=> int(255)
  ["green"]=> int(255)
  ["blue"]=> int(255)
  ["alpha"]=> int(127)
}

ব্যাখ্যা: (১৫, ২৫) কোঅর্ডিনেটে সাদা রঙের পিক্সেল (RGB: ২৫৫, ২৫৫, ২৫৫) এবং আলফা ১২৭ (আধা পারদর্শী) পাওয়া গেল। imagecolorsforindex() ফাংশনটি রঙ সূচক থেকে RGBA আর্গুমেন্টে রূপান্তর করে।

  1. PHP-তে imagecreate() ফাংশন

  2. PHP-তে imagefill() ফাংশন

  3. PHP-তে imagefilledrectangle() ফাংশন

  4. PHP-তে imagefilledellipse() ফাংশন