How do I export an image as binary data?

0 favourites
  • 8 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • 1. Using Base64 to export (via php) works fine.

    2. I'd like to use float64 (or whatever to compress as much as possible), but all float64 seems to do is store/get float data URL from the construct server and displays it as a text file (or load it into a sprite).

    Is there a way to get the actual binary data WITHOUT using the construct server? (for example, one can get the base64 data and send it, but using float64 is just a redirect to the C3 server URL: blob:https://preview.construct.net/YOUR_IMAGE_FILE)

    The URL only works for that session. Once project is closed the data is no longer retievable.

    (Image: PNG = 119kb, JPEG 20% = 4.9kb)

    [With base64 it's possible to get the image small using jpeg 20% quality and get the actual data, but would like to see if I can get a PNG down to that size using float64 or some other compression. If I were using just a couple images in a single session, the URL would be fine. But I'd like to save the images to a database for future retrieval.]

    Tagged:

  • Addendum: Data from the URL returns in this format.

    If I request the URL and look at the ajax it is different.

    It looks like the data on the html page is what I want, but there doesn't seem to be a way to get it with ajax or without using the construct hosting server. Is that correct?

  • Ashley

    Other than base64, is the raw binary data accessible? If so, how would you recommend retrieving it from the localhost? (By accessible I mean being able to copy it and send it to my server, then import it and load as an image.)

  • Yes, you can use raw binary data with the Binary Data object. You should never need to have to use base64 unless you are trying to put binary data in a text format, e.g. in a JSON file.

    I don't know what you mean by float64 - that's a data type, not a compression or encoding scheme like base64.

  • Let me try and rephrase this.

    I can access the url where the blob is located (url sent to a variable, copy/paste the URL into a browser and view the data.), what I can not figure out is how to grab that data out of the browser so that it can be sent to a server for storage.

    I'm beginning to think I need an ajax/php to call that url and grab the raw data from the browser, and not using C3 for anything other than the ajax call. Is that correct?

    (Sometimes it's hard to tell where C3 limitations begin, usually it can handle most anything.)

  • Use the Post binary to URL action of the AJAX object. Pick your Binary Data object, and its data will be posted as binary to the server.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The good news, I'm about done trying to get this to work so I won't have a ton more questions lol.

    Ajax post, site&file.php?, Data: "cellname="&var1

    That's the normal way to $_POST (ajax thru php to mysql)

    With the binarydata post I have tried everything I know to get that to go through.

    Just double checking this, is the data labeled (meaning, did you call it binarydata or give it a tag? Or are you expecting it to be labelled on the URL line? (I assume yes to the latter, but it isn't working.)

    What's interesting (and why I ask this) is that I'm almost positive in the C2 we could put the cellname in the URL line (double checked this in an old copy of c2 and no. It had to be labeled on the data line for a POST. Example

    However, that no longer works and the "cellname=var1" has to in the c3 data. Example

    Based on that, I have no clue how to point the binarydata where I want it to go.

    No real worries, I'm going to punt and just do jpeg 20% with base64. I know for certain that works (even if larger) and I need to get back to writing code. (I've just been messing with it long enough I'd kinda like to figure it out. Appreciate the input.)

    ***I should add, I realize the above pictures are not of the send binary to URL, but the same concept applies.***

  • Posting binary data (as in your last screenshot) means the entire posted body is a single block of binary data. The server needs to handle this and not try to parse a string of parameters or anything like that.

    That means you can't put extra string parameters in the post data, but you can put them in the query string.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)