Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2006, 07:36 AM
Authorized User
 
Join Date: Mar 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pritz Send a message via Yahoo to pritz
Default getImagesize() ??

Hi all,

can some make me understand why following code is not working?
$img_size=array();
for($i=0;$i<5;$i++)
{
  $p=creating dynamically path;
  $img_size[]=getimagesize($p);
 }
i used usleep() also before function call but it's off no use?
i need it urgent can some1 turn for help
???
Regards,
Priti

 
Old February 25th, 2006, 02:32 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Image is a file and we may use filesize($filename).
It returns in bytes.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
mediasworks.com project
 
Old February 27th, 2006, 12:09 AM
Authorized User
 
Join Date: Mar 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pritz Send a message via Yahoo to pritz
Default

Quote:
quote:Originally posted by anshul
 Image is a file and we may use filesize($filename).
It returns in bytes.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
mediasworks.com project
Thanks for reply,
but I need width and height of the image :-(


 
Old February 27th, 2006, 12:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

list($width, $height, $type, $attr) = getimagesize("absolute/path/to/image/image.jpg");

$attr will write out: width="100" height="200"

peace
mike
 
Old February 27th, 2006, 08:00 AM
Authorized User
 
Join Date: Mar 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pritz Send a message via Yahoo to pritz
Default

Quote:
quote:Originally posted by harpua
 list($width, $height, $type, $attr) = getimagesize("absolute/path/to/image/image.jpg");

$attr will write out: width="100" height="200"

peace
mike
Thanks for the reply
I got it but I want to use getimagesize in a FOR loop after creating the path dynamically.i searched the net also but was not able to see any example where getimagesize is used in a forloop somewhere just a note was there that use usleep() but it also didn't worked .
can any1 with any positive thoughts guide me here what shell i do
?????/
Regards,
Priti

 
Old February 27th, 2006, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I was half asleep, you are trying to asign the image size to an array you can do it like this.

$img_size=array();
for($i=0;$i<5;$i++)
{
  $p=creating dynamically path;
  list($width, $height, $type, $attr) = getimagesize($p);
  $img_size[]=$width . "-" . $height . "-" . $type . "-" . $attr;
}

foreach ($img_size as $imagesize1) {
    echo $imagesize1;
}

if you want to just use width="" height="" you can just use the $attr variable.
mike
 
Old February 28th, 2006, 08:54 AM
Authorized User
 
Join Date: Mar 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to pritz Send a message via Yahoo to pritz
Default

Quote:
quote:Originally posted by harpua
 Sorry I was half asleep, you are trying to asign the image size to an array you can do it like this.

$img_size=array();
for($i=0;$i<5;$i++)
{
$p=creating dynamically path;
list($width, $height, $type, $attr) = getimagesize($p);
$img_size[]=$width . "-" . $height . "-" . $type . "-" . $attr;
}

foreach ($img_size as $imagesize1) {
    echo $imagesize1;
}

if you want to just use width="" height="" you can just use the $attr variable.
mike

hey its work but with follow warning thanks a lot but with warning
:-(
Warning: getimagesize(Array) [function.getimagesize]: failed to open stream: No such file or directory in C:\apachefriends\xampp\htdocs\modules\mod_mediaIma ge.php on line 88

what could be the reason any idea plz i think i m near to solution ???








Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with getimagesize function echovue Beginning PHP 1 January 20th, 2007 03:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.