Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน getimagesize() ใน PHP

คำอธิบาย

ฟังก์ชัน getimagesize() ใช้แสดงขนาดของไฟล์ภาพ

รูปแบบการใช้งาน (Syntax)

getimagesize($file_name, $img_info)

พารามิเตอร์

  • file_name: ไฟล์ภาพ เช่น เส้นทางของไฟล์ภาพ

  • img_info: ดึงข้อมูลขยายจากไฟล์ภาพ รองรับเฉพาะไฟล์ JFIF

ค่าที่คืนกลับ

ฟังก์ชัน getimagesize() คืนค่าอาร์เรย์ที่ประกอบด้วยความสูง ความกว้าง ประเภท MIME type ของภาพ ฯลฯ

ตัวอย่าง

<?php
   $image_info = getimagesize("https://www.tutorialspoint.com/images/tp-logo-diamond.png");
   print_r($image_info);
?>

ผลลัพธ์

Array (
   [0] => 205
   [1] => 120
   [2] => 3
   [3] => width="205" height="120"
   [bits] => 8
   [mime] => image/png
)