Afficher un message
Vieux 26/06/2007, 09h38   #2
james.gauth@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: get image size from binary data

On 26 Jun, 08:31, Christoph Burschka <christoph.bursc...@rwth-
aachen.de> wrote:
> Is there some way to get the dimensions of an image, given the binary
> data of the image, without having to write it to a temporary file?
>
> It seems that getimagesize() will only take a filename, but since I have
> to download the image from a remote URL with fsockopen(), I have it
> stored as a binary string.
>
> I've had a cursory glance at the data, but predictably the size is not
> stored in decimal format anywhere...
>
> --
> cb


If the image format is supported by your GD Library, you can use the
following:

<?php

$binary_data = file_get_contents('http://www.google.co.uk/intl/en_uk/
images/logo.gif');

$im = imagecreatefromstring($binary_data);

$width = imagesx($im);
$height = imagesy($im);

print "width: $width\n";
print "height: $height\n";

?>

  Réponse avec citation
 
Page generated in 0,04635 seconds with 9 queries