PHP - Obtener tamaño de imágenes con php

 
Vista:

Obtener tamaño de imágenes con php

Publicado por RoKanRol (6 intervenciones) el 07/07/2002 16:58:24
Hola, quisiera saber como puedo obtener el tamaño en pixels de una imágen gif o jpg a través de php.

Existe funciones para esto?

Gracias.-
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Obtener tamaño de imágenes con php

Publicado por Angel (13 intervenciones) el 08/07/2002 19:14:12
Creo que esto te servira:

The getimagesize() function will determine the size of any GIF, JPG, PNG, SWF, PSD, TIFF or BMP image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag.

Returns an array with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 a flag indicating the type of the image. 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order, 9 = JPC, 10 = JP2, 11 = JPX. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag. Example 1. getimagesize (file)

<?php
$size = getimagesize ("img/flag.jpg");
echo "<img src=\"img/flag.jpg\" {$size[3]}>";
?>



Example 2. getimagesize (URL)

<?php $size = getimagesize ("http://www.example.com/gifs/logo.gif"); ?>



Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar