I'm making a UserScript in TypeScript that allows someone to download a specific <canvas> as a .png file. This <canvas> is an outfit in a dress-up game. I want to include a JSON blob within the exported .png so that users can later import this .png and access the outfit's data.
The data insertion should be non-destructive (no steganography).
How do I insert arbitrary data in a PNG file in JavaScript?
Related
I am considering using quill.js as a HTML editor on my page. I see it is possible to add a image (from your computer) to the HTML Editor. But where does this get saved when I save the form?
Do I need to save it a as a separate file? Will it be saved as a BLOB in DB? Or any other way?
If you take a look at the source of the DOM (using the playgrund) inside the editor, you can see that the image data is converted to a data:URI with base64 encoding.
If you take a look at this question you will get an idea of how they are converted.
Using this makes it easy to store pictures or other binary data inside any site without referring to other sources.
I have image urls in JavaScript and am trying to save them all onto a single PDF file. I am using jsPDF (JS library to generate PDFs) but it can only take images as .jpegs. Unfortunately the images I have are .ashx. Is there I way I can get convert the .ashx to .jpeg via JavaScript client-side?
Examples of image url:
http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=3849&type=card
http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=2923&type=card
http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=36037&type=card
Not possible. javascript cannot manipulate binary content. There's no client-side Javascript support for doing image manipulation.
Can I use Filereader in HTML5 to drag and drop a CSV data file onto a Dygraph canvas? Right now I'm hard-coding the file name (or JS variable containing the file name) into the 'new Dygraph()' assignment.
Sure! The main difference is that FileReader reads a file on the client's machine. The JS variable you pass to the dygraphs constructor is a file name on the server.
Instead of a file name, you can pass CSV data to the dygraphs constructor. Your should use FileReader to read the CSV data out of the file your user drags and drops. Then construct a Dygraph object using that data.
I have a list of images and an HTML string which holds a web page containing the images. I would like to create a zipped file via JavaScript code by using zip.js and save it at runtime.
The creation of the htmlString to file.html was easy, but I'm not sure on how I can send this list of images to zip.js.
I thought to create dynamically via JavaScript a list of input file elements maybe via jQuery or something, but I still cannot figure out how to do it. Does there exist some way to do that?
If I understand correctly, you managed to create the list of files (array?) and your issue is to create the zip file that contains the files.
If this is the case you can try using this small package :
https://www.npmjs.com/package/list-to-zip
It accept an array of urls and create a zip file from it.
I want to use JSChart (http://www.jscharts.com/) to generate a dynamic chart.
It uses a <canvas> object.
Furthermore I want to save the generated Chart as an image (to put in a pdf file) on the serverside.
Is it possible to save a JavaScript generated image as jpg or png on the serverside?
Preferably the solution should work with Ruby and Ruby On Rails.
I think this uses a <canvas> object to render the charts, can't tell without downloading and it requires registration, so no. If it does, perhaps take a look at Canvas2Image, that returns the canvas as a data URL, base64 encoded image, which could be sent back to the server via an AJAX call.
You can use http://xmlgraphics.apache.org/batik/ on the server to convert an SVG. It's the method used by highcharts to convert the graph generated by the application. See http://www.highcharts.com/docs/export-module/setting-up-the-server