Jump to content


Photo

Getting width and height from an image, help?


  • Please log in to reply
3 replies to this topic

#1 Madatan

Madatan
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 02 September 2006 - 07:16 PM

<?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);
?>

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

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 02 September 2006 - 07:23 PM

list($width, $height) = getimagesize($img);

Tell me the problem, I will try tell you the solution

#3 Madatan

Madatan
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts

Posted 02 September 2006 - 07:28 PM

It wont work, still not getting any width or height values

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 02 September 2006 - 07:49 PM

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;
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users