PHP Velho Oeste 2024

gd_info

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

gd_infoObtém informações sobre a biblioteca GD instalada atualmente

Descrição

gd_info(): array

Obtém informação sobre a versão e as capacidades da biblioteca GD instalada.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Retorna um array associativo.

Elementos de array retornados por gd_info()
Atributo Significado
GD Version Valor string descrevendo a versão da libgd instalada.
FreeType Support Valor bool. true se o suporte FreeType estiver instalado.
FreeType Linkage Valor string dewscrevendo a maneira que FreeType foi linkado. Os valores esperados são: 'with freetype', 'with TTF library', e 'with unknown library'. Este elemento será definido apenas se FreeType Support for true.
GIF Read Support Valor bool. true se o suporte para ler imagens GIF estiver incluso.
GIF Create Support Valor bool. true se o suporte para criação de imagens GIF estiver incluso.
JPEG Support Valor bool. true se o suporte a JPEG estiver incluso.
PNG Support Valor bool. true se o suporte a PNG estiver incluso.
WBMP Support Valor bool. true se o suporte a WBMP estiver incluso.
XBM Support Valor bool. true se o suporte a XBM estiver incluso.
WebP Support Valor bool. true se o suporte a WebP estiver incluso.
AVIF Support Valor bool. true se o suporte a AVIF estiver incluso. Disponível a partir do PHP 8.1.0.

Exemplos

Exemplo #1 Usando gd_info()

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

O exemplo acima produzirá algo semelhante a:

array(10) {
  ["GD Version"]=>
  string(24) "bundled (2.1.0 compatible)"
  ["FreeType Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(false)
  ["JPEG Support"]=>
  bool(false)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XBM Support"]=>
  bool(false)
  ["WebP Support"]=>
  bool(false)
  ["AVIF Support"]=>
  bool(false)
}

Veja Também

  • imagepng() - Envia uma imagem PNG para o navegador ou arquivo
  • imagejpeg() - Envia a imagem para o navegador ou para um arquivo
  • imagegif() - Envia a imagem para o navegador ou para um arquivo
  • imagewbmp() - Envia a imagem para o navegador ou para um arquivo
  • imagewebp() - Output a WebP image to browser or file
  • imageavif() - Envia a imagem para o navegador ou para um arquivo
  • imagetypes() - Retorna os tipos de imagens suportados pela instalação do PHP
add a note add a note

User Contributed Notes 1 note

up
-3
yohami dot com - zerodj at hotmail dot com
20 years ago
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!
To Top