Jump to content


Photo

Converting image Resourse to stream Resource


  • Please log in to reply
4 replies to this topic

#1 benjam

benjam
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts
  • LocationSalt Lake City, UT

Posted 31 July 2006 - 05:32 PM

I am trying to upload an image from an html form and then resize that image and save the image (not the filename, but the actual data) to a database.

I can do it just fine by opening the file, reading the contents, and uploading the contents to the database, but when I try to resize the image (which I can also do just fine) and then try to read the contents of the GD resource, I cannot get the actual data back out in a string (binary) format to be saved in the database.

So my question is this:
How can I read the data from the resized image resource so that I can save it to the database?

Thanks for any help.
Windows 7
MySQL: 5.1.36-community
PHP: 5.3.2 VC9
Apache 2.2 (apachelounge VC9)

#2 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 31 July 2006 - 05:57 PM

thats difficult but caption ck would tell you how to do it without telling you the script

1st Use the script to save the uploaded file somewhere

2nd Create a page which uses the GET method to get the file name and it shows the image resized

3rd The first script should get the contents of the 2nd script after giving it the get parameters (eg fread("image.php?url=uploads/pic.gif&h=100&w=100", filesize("image.php?url=uploads/pic.gif&h=100&w=100")); )

4th Now save the fread data in the database

5th Delete the image which was used to resize (uploaded image)

END

I know this would take time and i dint give you the script, cause its getting around 12am here and i have school tomorrow and hav to get some sleep.
I am a PHP Guru, ask me questions if you want to

#3 benjam

benjam
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts
  • LocationSalt Lake City, UT

Posted 31 July 2006 - 07:32 PM

Yeah, I am aware of that solution (saving the file and then reading it back), but was hoping there might be a faster, more efficient method.
Windows 7
MySQL: 5.1.36-community
PHP: 5.3.2 VC9
Apache 2.2 (apachelounge VC9)

#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 31 July 2006 - 07:36 PM

try ob_start() and ob_get_content()
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#5 benjam

benjam
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts
  • LocationSalt Lake City, UT

Posted 31 July 2006 - 09:17 PM

I tried that, and it worked, but I've decided to go with the save and read back method.

Thanks for your help everybody.
Windows 7
MySQL: 5.1.36-community
PHP: 5.3.2 VC9
Apache 2.2 (apachelounge VC9)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users