Load image from JS to Phaser Game - phaser-framework

I'm doing a custom game which I'd like to change the background and a character picture according to a file they upload.
The input file is outside phaser. If possible, I'd like to show the picture directly without uploading to the server.

If you use a file loader to get the base64 encoding of the image, you can use this.textures.addBase64 to load the image into the texture manager, after that loads you can create new objects with that image tag, or set existing images to that texture.
Working Example =>
https://stackblitz.com/edit/phaser-use-uploaded-image

Related

How to change linked SVG image to included SVG image in Inkscape?

When importing external SVG images the Inkscape offers three options:
Include SVG image as editable object(s) in the current file
Embed the SVG file in a image tag (not editable in this document)
Link the SVG file in a image tag (not editable in this document)
At first, for convenience I imported an SVG images (Image A) into master SVG image B in the third way (Link the SVG file) so that when editing image A, master image B changes accordingly. However, later in the publishing process, I found that I needed to make sure every part in master image B had to be editable, including those parts within image A.
Had I imported image A in the first way above (include SVG image), this would be possible. I had made some transformations to the linked image A within master image B so I didn't want to do it again. Is there a way to transform a linked image (<image xlink:href="XXX.svg" />) to an included image (<svg>...</svg>) with just a few clicks while preserving all the transformations I did to this image?
Right-click on the image and select 'Embed image'. This is going to embed it as an image, <svg:image ...>, though, not as an svg (I think that would be invalid SVG code, too).
For multiple images, use the extension 'Extensions > Images > Embed Images' without any image selected (or with all of them).

Add background image to existing PDF in NodeJS

I am currently trying to add a background image to an existing PDF using NodeJS, but I cannot find the right tool to get the job done.
I have looked into pdf-lib (https://pdf-lib.js.org/), but couldn't find an option to embed background images within pdf-lib's documentation.
Is there a good library to get the job done?
Alternatively, it would also be acceptable to have another PDF as background for the existing PDF, instead of having a background image.

How to get the background image of canvas after loading with loadFromJSON fabricjs?

When I load json string of canvas with background image and objects. I can not get the background image. when I console the data i can not see the background image there.
How can I bind the background image in JSON.stringify() function when saving the canvas in database?
As you mentioned, it is important when to call canvas.toJSON().
It is also very important to note this: you might see the background image property in your json string, but the image would not be saved properly at the time of canvas.toJSON() call. So as a result when you call loadFromJSON, every object is loaded into canvas except the background image.
Also, make sure you always use the latest fabricjs version.

NVD3.js: Is it possible to let user download any graph as JPEG or PNG Image?

I want user to let download the charts/graphs as PNG image or JPEG image. Is it possible in NVD3.js to allow user to download in this format?
i don't think nvd3 has the function built in and i have very similar requirement and "example of how to export a png directly from an svg" solved my problem (internally it adopted svg-crowbar code). basically, you need to draw the svg to a canvas then export the image to png, and "explicitly set css style" for all svg element is the caveat to make the exported image like original.

Using node-imagemagick to 'crop' an image uploaded to S3

I'm building functionality that allows users to upload an image, then crop it to a square (for profile pictures etc...)
Currently, the process works like this:
User selects image from hd
Image is uploaded to S3
S3 Path is sent back to view, and image with jCrop is shown
On submit button being clicked, my controller action gets the coords set above
Now I'd like to crop this image to the given coords (note- I'm using lpatters fork of node-imagemagick as it contains 'offset'
Unfortunately, .crop only accepts a path - which we don't have, since it's hosted on S3 at this point.
Is there any workaround?
I saw tmp, but this may be a little overkill?
What about using some of the other entry points such as "resize" that then allow you to provide the custom arguments? I'm using streams in this code: https://github.com/jeffwilcox/4th-cloud/blob/master/lib/webserver.js#L542

Resources