★ wanayoo — archive 1999 http://php.net/manual/es/function.getimagesize.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Gráficos
Quick Reference
Gráficos
English version of this pageGerman version of this pageJapanese version of this page
Italian version of this pageFrench version of this pageHungarian version of this page
Spanish version of this page
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopyResized
* ImageCreate
* ImageCreateFromGif
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGif
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText

  Thanks to:
 Chek.com
 easyDNS
 VA Linux Systems

  Related sites:
Apache
MySQL
PostgreSQL
Zend Tech.

  Community:
LinuxFund.org
OSDN
Manual: GetImageSize
View the source code for this pageSearch the site



Previous page
 Gráficos
 Updated
Thu, 14 Sep 2000
ImageArc 
Next page


GetImageSize

(PHP3 <= 3.0.16, PHP4 )

GetImageSize -- Obtiene el tamaño de una imagen GIF, JPG o PNG

Descripción

array getimagesize (string filename [, array imageinfo])

La función GetImageSize() determinará el tamaño de cualquier fichero de imagen GIF, JPG o PNG y devolverá sus dimensiones junto al tipo de fichero en una cadena de texto que pueda ser usada en una marca HTML IMG normal.

Devuelve una matriz con 4 elementos. El índice 0 contiene la anchura de la imagen en pixels. El índice 1 contiene la altura. El índice 2 es una marca indicando el tipo de imagen. 1 = GIF, 2 = JPG, 3 = PNG. El índice 3 es una cadena de texto con el string correcto "height=xxx width=xxx" para ser usado directamente en una marca IMG.

Ejemplo 1. GetImageSize


<?php $size = GetImageSize("img/flag.jpg"); ?>
<IMG SRC="/old?u=http%3A%2F%2Fphp.net%2Fmanual%2Fes%2Fimg%2Fflag.jpg&y=1999" <?php echo $size[3]; ?>>

El parámetro opcional imageinfo permite extraer información adicional del fichero de imagen. Actualmente esto devolverá las diferentes marcas APP de los JPG en una matriz asociada. Algunos programas usan estas marcas APP para incluir información textual en las imagenes. Uno bastante común incluye información IPTC http://www.xe.net/iptc/ en la marca APP13. Puede usar la función iptcparse() para convertir la marca binaria APP13 en algo leible.

Ejemplo 2. GetImageSize devolviendo IPTC


<?php 
    $size = GetImageSize("testimg.jpg",&$info);
    if (isset($info["APP13"])) {
        $iptc = iptcparse($info["APP13"]);
        var_dump($iptc);
    }
?>

Nota: Esta función no requiere la libreria de imagenes GD.


User Contributed Notes: GetImageSize


stevet@linuxfan.com
18-Apr-1999 10:18
The filename needs to be either relative to the current document, or an absolute filesystem path. Thus absolute URL paths will not work.

To use absolute URL paths, use $DOCUMENT_ROOT . $imagepath



everton@dextra.com.br
13-Dec-1999 08:34
The sample code didn't worked for me.
The following one did:

<pre>
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);

if (is_array($iptc)) {
while(list($key, $val) = each($iptc)) {
while(list($k, $v) = each($val)) {
echo "$k => \"$v\"
\n";
}
}
}
}
</pre>



webmaster@feartheclown.com
29-Dec-1999 05:44
I found I was able to get the dimensions of an image just prior to storing it in the database. I did this by using GetImageSize on the actual data, not the filename. This allowed me to get the dimensions without having to create a tmp file.

$imagehw = GetImageSize($form_data);

// Do this prior to adding slashes
// to the data.

$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];

// Proceed with storing the image.



tchr@elq.org
01-Feb-2000 07:04
We noticed several request for a way to get the image info without having to download and/or write the data to a file ifit is either remote orin a base.

Gosub of ELQ has written a 150 lines php3 script that does this for you. You'll send the data as a string to the function, and it will return an array much like phps own getImageSize.

The scipt is available at

ftp://ftp.elq.org/pub/php3/elqGetImageFormat/

tChr/ELQ



luc@databoss.nl
20-Sep-2000 05:42
In the 3rd element of the returned array, the word 'height' is wrongly spelled as 'heigth'!


 About Notes


Previous page
 Gráficos
 Updated
Thu, 14 Sep 2000
ImageArc 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.