Graal Forums

Graal Forums (http://forums.graalonline.com/forums/index.php)
-   NPC Scripting (http://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Getting the base64 of an image (http://forums.graalonline.com/forums/showthread.php?t=134267998)

Gunderak 03-16-2013 02:40 PM

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.

Crow 03-16-2013 02:46 PM

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()?

Gunderak 03-16-2013 03:15 PM

It works with loadstring! Thankyou!

Skyld 03-16-2013 05:17 PM

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?

Crow 03-16-2013 05:31 PM

Quote:

Originally Posted by Skyld (Post 1715054)
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?

Gunderak 03-17-2013 01:58 AM

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.

fowlplay4 03-17-2013 03:51 AM

Quote:

Originally Posted by Gunderak (Post 1715080)
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.

Cubical 03-17-2013 08:07 AM

Quote:

Originally Posted by fowlplay4 (Post 1715082)
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.

Gunderak 03-17-2013 10:16 AM

How do you use a drawing panel serverside? iv'e used it clientside before for era valentines day cards. Is it the same logic?

Crow 03-17-2013 01:06 PM

Quote:

Originally Posted by Gunderak (Post 1715080)
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.

Gunderak 03-19-2013 05:46 AM

Iv'e tried not encoding it, but the php server fails to put it back together.


All times are GMT +2. The time now is 09:59 AM.

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