Jump to content

Archived

This topic is now archived and is closed to further replies.

Madatan

Getting width and height from an image, help?

Recommended Posts

[code]
<?php
$path= "fotoalbum/".$HTTP_POST_FILES['ufile']['name'];
$filename = $HTTP_POST_FILES['ufile']['name'];
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path) && $bilder < $maxbilder && $fotoalbum != '')
{
        $extension = strrchr($filename, '.');
        $extension = strtolower($extension);

        switch($extension) {
                case '.jpg':
                case '.jpeg':
                        $im = @imagecreatefromjpeg($filename);
                        break;
                case '.gif':
                        $im = @imagecreatefromgif($filename);

                        break;

                // ... etc

                default:
                        $im = false;
                        break;
        }

if ($filename == false) {
        die ('Unable to open image');
}
$bildy = imagesy($im);
$bildx = imagesx($im);
?>
[/code]

I can't get this to work, anyone got any ideas on how to do this?

Share this post


Link to post
Share on other sites
where $img is the image (use the one on the server)
and $width is the width
and $height is the height

so
$img = "images/myimage.jpg";
list($width, $height) = getimagesize($img);

echo "Width is ".$width."<br />\n"
."And Height is ".$height;

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.