PDA

View Full Version : getimagesize() on a php file: fix or workaround?


sabret00the
26 Jan 2005, 14:08
ok i can use this perfectly for image files but if i wanna use itfortheavatar file lets say image.php then i seem to run into an errorofitgiving me 0's for height and width is their anyway to fix this?

* sabret00the using supermerge powers to supply extra info that may or may not help




Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

is the error it spits out.

noppid
26 Jan 2005, 16:56
You don't show your actual code, but my guess is that you are not pointing getimagesize() at an actual file. You may have to try to use imagecreatefromstring() and then use imagesy() and imagesx() for your demensions.

sabret00the
26 Jan 2005, 17:01
heres the code


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



i'll check into imagecreatefromstring() now.

noppid
26 Jan 2005, 17:06
Don't forget, it was posted at vb.com that iif() is being phased out and using it for data like that is highly inefficent.

:)

sabret00the
26 Jan 2005, 17:08
iif's are being phased out?

ok now just read it, could i just



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



basically just making the adding the line to convert it to my script or will i have to use the imagesy() imagesx() functions?

just got back, it can't create the image from string it appears



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------





Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

is the code in charge, i already miss the precious iff's :(

noppid
26 Jan 2005, 17:23
getimagesize expects a file from the file system with a valid path and name.

imagecreatefromstring gives you a GD handle to use imagesy() imagesx().

This page has all the info ya need. http://us4.php.net/manual/en/ref.image.php

sabret00the
26 Jan 2005, 17:25
thanks, will that help me to make the data into a string too?

noppid
26 Jan 2005, 17:42
thanks, will that help me to make the data into a string too?

I'm not sure what you mean, but if you mean a new pic from that string, look at imagejpg() imagepng() and imagegif().

sabret00the
26 Jan 2005, 17:45
yup that's what i meant cos it's saying

Warning: imagecreatefromstring(): Passed data is not in 'WBMP' format in \groups\groups.php on line 179

my initial plan was to use file_get_contents() and go from there but that never worked :-S