Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Load image to GD2 from MySQL BLOB
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: Tue Apr 21, 2009 7:05 pm   Post subject: Load image to GD2 from MySQL BLOB

Hey,
Say I have a blob data of an image (JPEG) in a database. I want to know how I can pull that data and load it into GD2 (like imagecreatefromjpeg) so I can manipulate it and re-draw the image with php.

Thanks!
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Tue Apr 21, 2009 9:23 pm   Post subject: RE:Load image to GD2 from MySQL BLOB

store it in the DB encoded somehow, say base64; then fetch it into a string, decode it, and then make the image.

Alas I do not know specifics of the library, but I know there is a way.
Dan




PostPosted: Tue Apr 21, 2009 9:54 pm   Post subject: RE:Load image to GD2 from MySQL BLOB

I have allwasy been aginsted sotring images and binnary files in databases like that. Is there any reason you need to store it in the database and can't use the file system witch was made for such things?
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Amailer




PostPosted: Sat Apr 25, 2009 1:51 am   Post subject: RE:Load image to GD2 from MySQL BLOB

Yeah I just ended up storing it as a file... I had figured managing the editing of the image would have been easier, say if I want to edit the original image, or revert back it would be better to have all the data in the database.

However, to get it to be "editable" in GD2, I had to basically re-create the image in PHP (separate page) and then call it back in my image editor page. At least that's the only way I could think of.
Tony




PostPosted: Sat Apr 25, 2009 1:57 am   Post subject: Re: RE:Load image to GD2 from MySQL BLOB

Amailer @ Sat Apr 25, 2009 1:51 am wrote:
in PHP (separate page)

You know, PHP doesn't have to be embedded into a page.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Amailer




PostPosted: Sat Apr 25, 2009 2:06 am   Post subject: RE:Load image to GD2 from MySQL BLOB

Are you referring to PHP GTK? (what? confused...and scared now).

What I meant though, the only other way I could think of was recreating the image from the database as a .jpg/.png or whatever file and then using imagecreatefromjpeg to call it from the URL.
jeffgreco13




PostPosted: Mon Apr 27, 2009 9:02 am   Post subject: RE:Load image to GD2 from MySQL BLOB

what kind of editing are you trying to do? just resizing and cropping? or colour changes and filters too
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: