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

PHP – เปิด/ปิด Interlace ด้วย imageinterlace()

ฟังก์ชัน imageinterlace() ใช้เปิดหรือปิด interlace ในรูปภาพ Interlacing ทำให้เห็นภาพเบื้องต้นขณะโหลด (progressive loading) รูปแบบแตกต่างตาม image type JPEG non-interlaced โหลดทีละบรรทัด เรียกฟังก์ชันพารามิเตอร์ที่ 2 เป็น 1 เพื่อเปิด 0 เพื่อปิด

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

int imageinterlace(GdImage $image, int $interlace)

พารามิเตอร์

  • $image – รูปภาพที่ต้องการตั้งค่า interlace
  • $interlace – 1 เปิด interlace, 0 ปิด interlace

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

คืน 1 หาก interlace bit ถูกตั้งค่า 0 หากไม่ได้ตั้งค่า

ตัวอย่าง 1: เปิด Interlace

<?php
$img = imagecreatefromjpeg('C:\xampp\htdocs\test\30.jpg');
imageinterlace($img, 1);
header('Content-type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
?>

ตัวอย่าง 2: ปิด Interlace

<?php
$img = imagecreatefromjpeg('C:\xampp\htdocs\test\30.jpg');
imageinterlace($img, 0);
header('Content-type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
?>

ผลลัพธ์

PHP – เปิด/ปิด Interlace ด้วย imageinterlace()

PHP – เปิด/ปิด Interlace ด้วย imageinterlace()