Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-16-2013, 01:40 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Getting the base64 of an image

Hi, i'm trying to get the base64 string of an image on the server and send it through a socket, but it's failing horribly. It gets a base64 but it isn't correct, I think it's just getting the base64 of a binary dump of the image file.
Graal Script Code:
  temp.img "base64test.png";
  
temp.loc findfiles(temp.img1)[0];
  
temp.lines.loadlines(temp.loc);
  
temp.lines base64encode(temp.lines); 
temp.lines should be the base64 of the image.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 03-16-2013, 01:46 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
You will want to base64 encode the raw data of the image. loadlines() will load all lines into an array and should only be used with plain text files and formats. Try loadstring()?
__________________
Reply With Quote
  #3  
Old 03-16-2013, 02:15 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
It works with loadstring! Thankyou!
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 03-16-2013, 04:17 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I'm somewhat curious about what you stand to gain from transferring the image as base64; all you will do is make the image significantly bigger to transfer than it originally was?
__________________
Skyld
Reply With Quote
  #5  
Old 03-16-2013, 04:31 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Skyld View Post
I'm somewhat curious about what you stand to gain from transferring the image as base64; all you will do is make the image significantly bigger to transfer than it originally was?
To transmit the image data through a non-binary interface, possibly?
__________________
Reply With Quote
  #6  
Old 03-17-2013, 12:58 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Jatz and I are making a system similar to player cards for Delteria, we're sending the image of the player through a socket and letting a php script generate an image from it.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #7  
Old 03-17-2013, 02:51 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
Jatz and I are making a system similar to player cards for Delteria, we're sending the image of the player through a socket and letting a php script generate an image from it.
You would be better off using a client-side drawing panel, drawing the player object on your template, saving the image locally (temporarily) and uploading that to the server instead of getting a third-party web-server involved.

There's also server-side drawing panels that you can use as well.
__________________
Quote:
Reply With Quote
  #8  
Old 03-17-2013, 07:07 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by fowlplay4 View Post
You would be better off using a client-side drawing panel, drawing the player object on your template, saving the image locally (temporarily) and uploading that to the server instead of getting a third-party web-server involved.

There's also server-side drawing panels that you can use as well.
Rendering medium to large size drawing panels always seem to lag the server whenever I use them.
Reply With Quote
  #9  
Old 03-17-2013, 09:16 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
How do you use a drawing panel serverside? iv'e used it clientside before for era valentines day cards. Is it the same logic?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #10  
Old 03-17-2013, 12:06 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
Jatz and I are making a system similar to player cards for Delteria, we're sending the image of the player through a socket and letting a php script generate an image from it.
If you're sending data through a socket, you don't have to encode it as base64. Sending binary data through the socket works just fine.
__________________
Reply With Quote
  #11  
Old 03-19-2013, 04:46 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Iv'e tried not encoding it, but the php server fails to put it back together.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:19 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.