downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

getimagesize> <GD ve Resim İşlevleri
Last updated: Fri, 27 Nov 2009

view this page in

gd_info

(PHP 4 >= 4.3.0, PHP 5)

gd_infoKurulu GD kütüphanesi hakkında bilgi verir

Açıklama

array gd_info ( void )

Kurulu GD kütüphanesinin sürümü ve yapabildikleri hakkında bilgi verir.

Dönen Değerler

Bir ilişkisel dizi döner.

gd_info() tarafından döndürülen dizinin elemanları
Öznitelik Anlamı
GD Version Kurulu libgd sürümünü içeren string türünde bir değer.
Freetype Support boolean türünde bir değer. Freetype desteği varsa TRUE.
Freetype Linkage Freetype desteğinin nasıl sağlandığını açıklayan string türünde bir değer. Olası değerler: 'with freetype' (freetype ile), 'with TTF library' (TTF kütüphanesi ile) ve 'with unknown library' (bilinmeyen bir kütüphane ile). Bu eleman sadece Freetype Support elemanının değeri TRUE ise anlamlıdır.
T1Lib Support boolean türünde bir değer. T1Lib desteği varsa TRUE.
GIF Read Support boolean türünde bir değer. GIF resimleri okuma desteği varsa TRUE.
GIF Create Support boolean türünde bir değer. GIF resimleri oluşturma desteği varsa TRUE.
JPEG Support boolean türünde bir değer. JPEG desteği varsa TRUE.
PNG Support boolean türünde bir değer. PNG desteği varsa TRUE.
WBMP Support boolean türünde bir değer. WBMP desteği varsa TRUE.
XPM Support boolean türünde bir değer. XPM desteği varsa TRUE.
XBM Support boolean türünde bir değer. XBM desteği varsa TRUE.
JIS-mapped Japanese Font Support boolean türünde bir değer. JIS eşlemli Japonca yazı tipi desteği varsa TRUE.

Bilginize: PHP 5.3.0 öncesinde, JPEG Support özniteliğinin ismi JPG Support idi.

Örnekler

Örnek 1 gd_info() kullanımı

<?php
var_dump
(gd_info());
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

array(11) {
  ["GD Version"]=>
  string(27) "bundled (2.0.34 compatible)"
  ["FreeType Support"]=>
  bool(false)
  ["T1Lib Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(true)
  ["JPEG Support"]=>
  bool(false)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XPM Support"]=>
  bool(false)
  ["XBM Support"]=>
  bool(true)
  ["JIS-mapped Japanese Font Support"]=>
  bool(false)
}

Sürüm Bilgisi

Sürüm: Açıklama
5.3.0 JPG Support özniteliğinin ismi JPEG Support oldu.

Ayrıca Bakınız

  • imagepng() - Tarayıcıya veya bir dosyaya bir PNG resmi çıktılar
  • imagejpeg() - Tarayıcıya veya bir dosyaya bir JPEG resmi çıktılar
  • imagegif() - Bir dosyaya veya tarayıcıya bir GIF resmi çıktılar
  • imagewbmp() - Resmi bir dosyaya veya tarayıcıya çıktılar
  • imagetypes() - Kurulu PHP'nin desteklediği resim türlerini döndürür



getimagesize> <GD ve Resim İşlevleri
Last updated: Fri, 27 Nov 2009
 
add a note add a note User Contributed Notes
gd_info
baumbach at kabece dot com
03-Nov-2006 04:58
@ thorerik dot lie at gmail dot com

<?
$array=gd_info ();
foreach ($array as $key=>$val) {
 
  if ($val===true) {
    $val="Enabled";
  }

  if ($val===false) {
    $val="Disabled";
  }

  echo "$key: $val <br />\n";

}
?>

does the same thing (SCNR)
Michael Z
28-Sep-2005 07:40
An easy way to get the numeric value for the GD Version :
$Version = ereg_replace('[[:alpha:][:space:]()]+', '', $GDArray['GD Version']);
Hagan Fox
03-May-2005 11:35
This function safely determines the GD version, even on PHP versions earlier than 4.3 that lack the gd_info() function.  Use it to avoid having your script halt with a fatal error if you try to use a TrueColor function and the GD version isn't 2.0 or later.

You can optionally specify a version, but if you specify version 2 it might be overridden.  Once the version number is determined it's retained to speed future calls.

<?php
/**
* Get which version of GD is installed, if any.
*
* Returns the version (1 or 2) of the GD extension.
*/
function gdVersion($user_ver = 0)
{
    if (!
extension_loaded('gd')) { return; }
    static
$gd_ver = 0;
   
// Just accept the specified setting if it's 1.
   
if ($user_ver == 1) { $gd_ver = 1; return 1; }
   
// Use the static variable if function was called previously.
   
if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
   
// Use the gd_info() function if possible.
   
if (function_exists('gd_info')) {
       
$ver_info = gd_info();
       
preg_match('/\d/', $ver_info['GD Version'], $match);
       
$gd_ver = $match[0];
        return
$match[0];
    }
   
// If phpinfo() is disabled use a specified / fail-safe choice...
   
if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
        if (
$user_ver == 2) {
           
$gd_ver = 2;
            return
2;
        } else {
           
$gd_ver = 1;
            return
1;
        }
    }
   
// ...otherwise use phpinfo().
   
ob_start();
   
phpinfo(8);
   
$info = ob_get_contents();
   
ob_end_clean();
   
$info = stristr($info, 'gd version');
   
preg_match('/\d/', $info, $match);
   
$gd_ver = $match[0];
    return
$match[0];
}
// End gdVersion()

// Usage:

if ($gdv = gdVersion()) {
    if (
$gdv >=2) {
        echo
'TrueColor functions may be used.';
    } else {
        echo
'GD version is 1.  Avoid the TrueColor functions.';
    }
} else {
    echo
"The GD extension isn't loaded.";
}
?>

The function only detects the GD version, but you could determine GD capabilities in a similar manner.
phpnet at furp dot com
08-Dec-2004 06:59
I updated the function below to include the GD Version info and any other string fields. The function only showed the bool values before.

// Retrieve information about the currently installed GD library
function describeGDdyn() {
  echo "\n<ul><li>GD support: ";
  if(function_exists("gd_info")){
   echo "<font color=\"#00ff00\">yes</font>";
   $info = gd_info();
   $keys = array_keys($info);
   for($i=0; $i<count($keys); $i++) {
        if(is_bool($info[$keys[$i]])) echo "</li>\n<li>" . $keys[$i] .": " . yesNo($info[$keys[$i]]);
        else echo "</li>\n<li>" . $keys[$i] .": " . $info[$keys[$i]];
   }
  } else { echo "<font color=\"#ff0000\">no</font>"; }
  echo "</li></ul>";
}

function yesNo($bool){
  if($bool) return "<font color=\"#00ff00\"> yes</font>";
  else return "<font color=\"#ff0000\"> no</font>";
}
yohami dot com - zerodj at hotmail dot com
14-Jan-2004 03:09
A cool resize / cropping script for creating thumbnails using mogrify

IMAGETEST.PHP

<?php

include 'mogrify.php';

// variables from flash (my website uses flash and php)
$picture="sample.jpg";
$fixedwidth=300;
$fixedheight=240;
//

cropimage($picture,$fixedwidth,$fixedheight,$mogrify);

 
?>

MOGRIFY.PHP

<?php
// walking the path
$mogrify="C:/apache/Imagik/mogrify.exe";

// ---------------------------------------- crop function

function cropimage($picture,$fixedwidth,$fixedheight,$mogrify) {

   
// GET IMG
   
$img = imagecreatefromjpeg($picture);
   
$width= imagesx($img);
   
$height= imagesy($img);
   
// CROP WIDTH
   
if($width!=$fixedwidth){
       
$ratio =$fixedwidth/$width;
       
$NewHeight=round($height*$ratio);
       
$NewWidth=round($width*$ratio);
       
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
       
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
       
// REFRESH
       
$img = imagecreatefromjpeg($picture);
       
$width= imagesx($img);
       
$height= imagesy($img);
    }
   
// CROP HEIGHT
   
if($height!=$fixedheight){
       
$ratio =$fixedheight/$height;
       
$NewHeight=round($height*$ratio);
       
$NewWidth=round($width*$ratio);
       
exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
       
exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
    }
   
//
   
ImageDestroy($img);
}

?>

yeah!
johnschaefer at gmx dot de
10-Apr-2003 12:25
this is a replacement for this function.
you can also use this function in php >= 4.3.

the handling is the same as the gd_info function (array gd_info(void))

<?php
$code
= 'function gd_info() {
        $array = Array(
                       "GD Version" => "",
                       "FreeType Support" => 0,
                       "FreeType Support" => 0,
                       "FreeType Linkage" => "",
                       "T1Lib Support" => 0,
                       "GIF Read Support" => 0,
                       "GIF Create Support" => 0,
                       "JPG Support" => 0,
                       "PNG Support" => 0,
                       "WBMP Support" => 0,
                       "XBM Support" => 0
                      );
        $gif_support = 0;

        ob_start();
        eval("phpinfo();");
        $info = ob_get_contents();
        ob_end_clean();
     
        foreach(explode("\n", $info) as $line) {
            if(strpos($line, "GD Version")!==false)
                $array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line)));
            if(strpos($line, "FreeType Support")!==false)
                $array["FreeType Support"] = trim(str_replace("FreeType Support", "", strip_tags($line)));
            if(strpos($line, "FreeType Linkage")!==false)
                $array["FreeType Linkage"] = trim(str_replace("FreeType Linkage", "", strip_tags($line)));
            if(strpos($line, "T1Lib Support")!==false)
                $array["T1Lib Support"] = trim(str_replace("T1Lib Support", "", strip_tags($line)));
            if(strpos($line, "GIF Read Support")!==false)
                $array["GIF Read Support"] = trim(str_replace("GIF Read Support", "", strip_tags($line)));
            if(strpos($line, "GIF Create Support")!==false)
                $array["GIF Create Support"] = trim(str_replace("GIF Create Support", "", strip_tags($line)));
            if(strpos($line, "GIF Support")!==false)
                $gif_support = trim(str_replace("GIF Support", "", strip_tags($line)));
            if(strpos($line, "JPG Support")!==false)
                $array["JPG Support"] = trim(str_replace("JPG Support", "", strip_tags($line)));
            if(strpos($line, "PNG Support")!==false)
                $array["PNG Support"] = trim(str_replace("PNG Support", "", strip_tags($line)));
            if(strpos($line, "WBMP Support")!==false)
                $array["WBMP Support"] = trim(str_replace("WBMP Support", "", strip_tags($line)));
            if(strpos($line, "XBM Support")!==false)
                $array["XBM Support"] = trim(str_replace("XBM Support", "", strip_tags($line)));
        }
       
        if($gif_support==="enabled") {
            $array["GIF Read Support"]   = 1;
            $array["GIF Create Support"] = 1;
        }

        if($array["FreeType Support"]==="enabled"){
            $array["FreeType Support"] = 1;    }
 
        if($array["T1Lib Support"]==="enabled")
            $array["T1Lib Support"] = 1;    
      
        if($array["GIF Read Support"]==="enabled"){
            $array["GIF Read Support"] = 1;    }
 
        if($array["GIF Create Support"]==="enabled")
            $array["GIF Create Support"] = 1;    

        if($array["JPG Support"]==="enabled")
            $array["JPG Support"] = 1;
           
        if($array["PNG Support"]==="enabled")
            $array["PNG Support"] = 1;
           
        if($array["WBMP Support"]==="enabled")
            $array["WBMP Support"] = 1;
           
        if($array["XBM Support"]==="enabled")
            $array["XBM Support"] = 1;
       
        return $array;
    }'
;

if(!
function_exists("gd_info")) eval($code);
?>

getimagesize> <GD ve Resim İşlevleri
Last updated: Fri, 27 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites