Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-12-01 Thread Richard Lynch
Robert Sossomon wrote:
> Chris is quoted as saying on 11/30/2004 2:53 PM:
>> imagesx()  requires an image resource , not a file path.  so you'd need
>> to use one of the imagecreatefrom* functions to create the resource.
>>
>> But it looks like all you want is the width and height of an image
>> If so use get imagesize() ( which *does* except a pathname, not a
>> resource)
>>
>> Chris
>>
>> http://www.php.net/image
>> http://www.php.net/getimagesize
> 
> I had looked at get image size, but thought the other would be quicker...
> ARGH.

imagesx() is probably quicker once you have loaded in the entire image to
your GD resource...

But assuming the image could be *HUGE* and that getimagesize only has to
read the first N bytes to determine the size of the image, getimagesize
will win any speed race for an otherwise un-opened image file, I should
think.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread Robert Sossomon
Chris is quoted as saying on 11/30/2004 2:53 PM:
imagesx()  requires an image resource , not a file path.  so you'd need 
to use one of the imagecreatefrom* functions to create the resource.

But it looks like all you want is the width and height of an image 
If so use get imagesize() ( which *does* except a pathname, not a resource)

Chris
http://www.php.net/image
http://www.php.net/getimagesize

I had looked at get image size, but thought the other would be quicker...  ARGH.
$a=getimagesize($path);
$width = $a[0];
$width = $width/2;
$height = $a[1];
$height = $height/2;
works!!
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread John Nichel
Robert Sossomon wrote:

When I run it in the browser, I get:
Fatal error: Call to undefined function: imagesx() in 
c:\fourh\spotlight3.php on line 31

when i run it from the command line I get:
C:\fourh>php.exe spotlight3.php
Content-type: text/html
X-Powered-By: PHP/4.3.9

Warning:  imagesx(): supplied argument is not a valid Image 
resource in <
b>C:\fourh\spotlight3.php on line 31

Warning:  imagesy(): supplied argument is not a valid Image 
resource in <
b>C:\fourh\spotlight3.php on line 32

Doh, my bad.  imagesx() requires the image resource, and not the path.
As for the difference in browser vs. command line, it looks as if you've 
got multiple php.ini files.  Do a phpinfo() in a browser, and it will 
show you where it's looking for the php.ini file.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread Chris
imagesx()  requires an image resource , not a file path.  so you'd need 
to use one of the imagecreatefrom* functions to create the resource.

But it looks like all you want is the width and height of an image 
If so use get imagesize() ( which *does* except a pathname, not a resource)

Chris
http://www.php.net/image
http://www.php.net/getimagesize
Robert Sossomon wrote:
Here's the code for the page...

while ($file = readdir($handle))
{
 for ($i = 0; $i < count($extensoes); $i++)
 {
  if (eregi("\.". $extensoes[$i] ."$", $file))
  {
   $array[] = $file;
  }
 }
}
closedir($handle);
sort($array);
reset($array);
// takes the objects in the array and randomizes them
$arrayobj = array_rand($array);
$random = $array[$arrayobj];
// this creates the path name to the random file
// $path becomes the path name (duh) for the file
$path = $dir . $random;
$width = imagesx($random)/4;
$height = imagesy($random)/4;
// this is set up as an  tag and will show a random image
print "\n";
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread Greg Donald
On Tue, 30 Nov 2004 14:43:51 -0500, Robert Sossomon <[EMAIL PROTECTED]> wrote:
> Fatal error: Call to undefined function: imagesx() in c:\fourh\spotlight3.php 
> on
> line 31

Do print_r( gd_info() ); to see if your PHP has support for working with images.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread Robert Sossomon
John Nichel is quoted as saying on 11/30/2004 2:17 PM:

$width = imagesx($path)/4;
$height = imagesy($path)/4;
$width = imagesx($path)/4;
$height = imagesy($path)/4;
When I run it in the browser, I get:
Fatal error: Call to undefined function: imagesx() in c:\fourh\spotlight3.php on 
line 31

when i run it from the command line I get:
C:\fourh>php.exe spotlight3.php
Content-type: text/html
X-Powered-By: PHP/4.3.9

Warning:  imagesx(): supplied argument is not a valid Image resource in <
b>C:\fourh\spotlight3.php on line 31

Warning:  imagesy(): supplied argument is not a valid Image resource in <
b>C:\fourh\spotlight3.php on line 32

--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread John Nichel
Robert Sossomon wrote:

> // this is the path of your files folder. Change 'pathofile'
> $dir = "images/";
I would make this the path from root, ie...
$dir = "/root/path/images/";

// takes the objects in the array and randomizes them
$arrayobj = array_rand($array);
$random = $array[$arrayobj];
// this creates the path name to the random file
// $path becomes the path name (duh) for the file
$path = $dir . $random;
$width = imagesx($random)/4;
$height = imagesy($random)/4;
You need to supply the path to the image...I'm betting you wanted to do...
$width = imagesx($path)/4;
$height = imagesy($path)/4;
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] imagesx(): supplied argument is not a valid Image resource (CODE)

2004-11-30 Thread Robert Sossomon
Here's the code for the page...

while ($file = readdir($handle))
{
 for ($i = 0; $i < count($extensoes); $i++)
 {
  if (eregi("\.". $extensoes[$i] ."$", $file))
  {
   $array[] = $file;
  }
 }
}
closedir($handle);
sort($array);
reset($array);
// takes the objects in the array and randomizes them
$arrayobj = array_rand($array);
$random = $array[$arrayobj];
// this creates the path name to the random file
// $path becomes the path name (duh) for the file
$path = $dir . $random;
$width = imagesx($random)/4;
$height = imagesy($random)/4;
// this is set up as an  tag and will show a random image
print "\n";
?>
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php