PHP 8.3.4 Released!

imagegd2

(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)

imagegd2Tarayıcıya veya bir dosyaya bir GD2 görüntü çıktılar

Açıklama

imagegd2(
    GdImage $görüntü,
    ?string $dosya = null,
    int $parça_boyutu = 128,
    int $tür = IMG_GD2_RAW
): bool

Bir GD2 görüntüyü belirtilen dosyaya çıktılar.

Bağımsız Değişkenler

görüntü

imagecreatetruecolor() gibi bir görüntü oluşturma işlevinden dönen bir GdImage nesnesi.

dosya

GD2 görüntünün kaydedileceği yol. Belirtilmezse veya null verilirse ham görüntü akımı doğrudan çıktılanır.

Dosyanın kaydedileceği yol veya işlev döndüğünde kendiliğinden kapanan açık bir akım kaynağı. null atanırsa veya hiçbir şey atanmazsa doğrudan ham görüntü akımı çıktılanır.

parça_boyutu

Parça boyutu.

tür

IMG_GD2_RAW veya IMG_GD2_COMPRESSED olabilir. IMG_GD2_RAW öntanımlıdır.

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner.

Dikkat

Ancak, libgd görüntüyü çıktılamakta başarısız olursa bu işlev true döndürür.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.3 dosya artık null olabiliyor.
8.0.0 görüntü bağımsız değişkeninde artık bir GdImage nesnesi aktarmak gerekiyor; evvelce resource türünde geçerli bir gd değeri gerekirdi.

Örnekler

Örnek 1 - Bir GD2 görüntünün çıktılanması

<?php
// Bir tuval oluşturup üzerine bir metin çizelim
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);

// Görüntüyü çıktılayalım
imagegd2($im);

// Belleği serbest bırakalım
imagedestroy($im);
?>

Örnek 2 - Bir GD2 görüntünün kaydedilmesi

<?php
// Bir tuval oluşturup üzerine bir metin çizelim
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);

// gd2 görüntüyü kaydedelim
// GD2 görüntülerin dosya biçemi .gd2'dir.
// http://www.libgd.org/GdFileFormats adresine bakınız
imagegd2($im, 'simple.gd2');

// Belleği serbest bırakalım
imagedestroy($im);
?>

Notlar

Bilginize:

GD2 biçemi görüntü parçalarının hızlı yüklenebilmesi için kullanılan bir görüntü biçemidir. GD2 biçeminin sadece GD2 uyumlu uygulamalarda kullanılabileceğine dikkat ediniz.

Uyarı

GD ve GD2 görüntü biçemleri libgd'nin tescilli görüntü biçemleridir. Bunlar kullanımdan kalkmış kabul edilmeli, geliştirme ve deneme amacı dışında kullanılmamalıdır.

Ayrıca Bakınız

  • imagegd() - Tarayıcıya veya bir dosyaya bir GD görüntü çıktılar
add a note

User Contributed Notes 2 notes

up
2
Nick
12 years ago
You can use this function in combination with imagecreatefromstring() to clone the gd resource with minimum fuss (no writing to tmp file):

<?php
function cloneGd($gd)
{
ob_start();
imagegd2($gd);
return
imagecreatefromstring(ob_get_clean());
}
?>
up
0
mark at teckis dot com
20 years ago
yes, the gd2 file format does improve the speed of image creations as the data-setup is designed to be native for the GD function - ie, the image doesn't have to be converted to a usable format prior to processing.

you may also note that the newer gd2 format creates much smaller size files than the older imagegd function, certainly for images involving chunks of single colours anyway. you'll probably find this function most useful for saving overlay images or background images used in larger image creation scripts.

to read a ping or jpeg image (.png / .jpg) and save a .gd2 version to server...

$img = $_GET['img'];
if(file_exists($img))
{
$dim = getimagesize($img);
$cr = ($dim[2] < 4) ? ($dim[2] < 3) ? ($dim[2] < 2) ? NULL : imagecreatefromjpeg($img) : imagecreatefrompng($img) : Null;
if($cr !== NULL)
{
imagegd2($cr,substr($img,0,strrpos($img,'.')).'.gd2');
}
}

should save a copy with the same filename and directory using extension .gd2 - which can then be nicely and swiftly read using either imagecreatefromgd2 or imagecreatefromgd2part
To Top