New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base64 encode png buffer #47
Comments
Hi,
Also, the core dump comes probably from the fact that you're feeding img.pngPtr with a Number instead of a String or Buffer.
|
Hi, Next to that, what you're actually trying to do in the first code block of your comment is to get a base64 representation of a node-gd gd-object, which will fail since it's not a String. Let me explain in the code:
The solution is simpler than you might think:
|
@y-a-v-a, thanks for the prompt reply.
Fixed (late night copy paste error).
Less the latin1 argument (the key to the solution!), the default utf8 encoded buffer results in an invalid base64 string (this is the original reason why I started making changes); I'm not sure why? Actually, I've taken the latin1 argument away in your example and replaced it with binary and it's still working; thank you. |
True, since the documentation of nodejs (see https://nodejs.org/dist/latest-v6.x/docs/api/buffer.html#buffer_buffers_and_character_encodings ) says:
|
Why does latin1 work? Why am I required to encode the As an example: Playing with
But as we've touched on above, this isn't the case for the |
I'd like to:
My test code:
Why am I getting a null return on the gd.createFromPngPtr call?
Playing around with the examples in the documentation, the following snippet core dumps:
With node v6:
$ nvm list
-> v6.11.0
With node v8:
$ nvm list
v6.11.0
-> v8.1.0
During both runs, I'm using native libgd-dev v 2.2.101ubuntu3.3:
$ apt search libgd-dev
Sorting... Done
Full Text Search... Done
libgd-dev/yakkety-updates,yakkety-security,now 2.2.1-1ubuntu3.3 amd64 [installed]
GD Graphics Library (development version)
The text was updated successfully, but these errors were encountered: