Jump to content


Image Dimensions


3 replies to this topic

#1 BlazeForc3

    Young Padawan

  • Members
  • Pip
  • 62 posts
  • Location:Australia

Posted 11 January 2006 - 02:27 AM

Is there a function in php which will determine the dimensions of an image and store them in variables?

#2 rus321

    Young Padawan

  • Members
  • Pip
  • 49 posts

Posted 11 January 2006 - 05:35 AM

try something like this?

<?php
function image_mirror ($input_image_resource)
{
   $width = imagesx ( $input_image_resource );
   $height = imagesy ( $input_image_resource );
   $output_image_resource = imagecreatetruecolor ( $width, $height );
   $y = 1;

   while ( $y < $height )
   {
	   for ( $i = 1; $i <= $width; $i++ )
		   imagesetpixel ( $output_image_resource, $i, $y, imagecolorat ( $input_image_resource, ( $i ), ( $height - $y ) ) );
	   $y = $y + 1;
   }
  
   return $output_image_resource;
}
?>

Edited by rus321, 11 January 2006 - 05:36 AM.


#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 11 January 2006 - 04:57 PM

That is a function to mirror the image, not get the dimensions.
Although, out of that function you would be looking specifically at:
http://php.net/manua...ion.imagesx.php
http://php.net/manua...ion.imagesy.php

And as an alternative to those, you can try the following function:
http://php.net/manua...etimagesize.php

Note: To get an images size, it has to be uploaded to a server some where where you can access it. I'm not sure if you get the the size of a temp file.

#4 BlazeForc3

    Young Padawan

  • Members
  • Pip
  • 62 posts
  • Location:Australia

Posted 12 January 2006 - 10:30 PM

Thanks guys that helped alot





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users