Node create image by mixing 2 images - node.js

I've got app based on google maps. Each user is one pin on it.
I want to create pin image basing on user profile photo.
What I need to do is
Resize given image to given size (50x50px)
Make this image circle
Below this image, put base pin image (png) that has place on it for circle photo
Save final image as pin photo
Final image should be png with transparency enabled.
Is there any node library that can do such things?

Imagemagick supports image composition, and node has Imagemagick bindings.
Even though, I guess you can achieve your goal via CSS only:
resize -> browser will do;
make it circle -> border-radius: 50%;
base pin image background -> background-image.

Related

Drawing to an existing image with X-window

I am using X-window (X11) to render 2D graphics (lines, circles, text...). But rather than drawing to a window, I need to draw to an existing bitmap image. Is there a way to achieve this ? If yes, are there restrictions on the bitmap format ?
(Notice: I am not trying to render an image to a window.)
Create a pixmap via: XCreatePixmap
Create a context via XCreateGC, specifying the pixmap as the drawable.
Transfer the contents of your existing image via XPutImage (see also Transferring Images between Client and Server), specifying the pixmap as the drawable and the related context.
do your renderings via GC Convenience Routines and Graphics Functions
Get the contents from the pixmap via: XGetImage, see also Transferring Images between Client and Server
Save the image data.

How to swtich image in phaser js?

How to swtich image in phaser js?
I change profile image but its showing still same but when reload the game image has been changed
With the little details you provided, I think you're looking for Image.setTexture(key: string). This method will set the texture used by an image GameObject to that of "key".

Using HTML code to detect image size on screen

I'm developing an app that grabs the HTML from a webpage and looks at images, within the HTML, that can be compressed and resized.
I can do the first part no problem in node, using Sharp here:
https://www.npmjs.com/package/sharp
I can, of course, resize the same image here too. I just don't know what dimensions to use. I don't want a tiny image to scale up and so on.
Can I somehow detect the size of the image on screen using the HTML I got to begin with?
Thanks in advance.
EDIT:
Sorry for any confusion. I need to know how big the image is being displayed on the page. So, the image may be 400x400 but the css could limit it to 200x200.
If I have a large image (1000x1000) but it's only being shown on screen at 500x500, I'd know it's a great candidate for resizing.
I'm just not sure how I can resize based on it's css dimensions.
I think in Sharp there's a metadata function that lets you access image metadata, e.g. format, width, height, etc.
Example:
const image = sharp(inputJpg);
image.metadata().then(function(metadata) {
// print image width and height
console.log({
width: metadata.width,
height: metadata.height
});
});
In Sharp library,
You can get dimension from this document:
http://sharp.dimens.io/en/stable/search.html?q=dimension
Hope it will help you.
const sharpImage = sharp('test/test.jpg');
image.metadata().then(function(metadata) {
console.log(metadata);
});

How to combine multiple image as single image in UWP

I have multiple image(near by 40 images), I need to combine these images as single image. I have referred the below link,
Combine two Images into one new Image
but I dint find anything like Graphics in UWP. How toacheive this requirement
Making a render target bitmap and draw the image to render target bitmap.
The example that how to draw image to render target bitmap.
And you can save render target bitmap to file, see http://jamescroft.co.uk/blog/how-to/storing-a-uwp-inkcanvas-drawing-as-an-image-in-a-storagefile/

Can I Capture phone screenshot using j2me app?

I am trying to develop a wireless phone projector, wherein I will be showing phone screen on projector using a projector connected PC.
I am bit confused on how to capture screenshot of any running application in j2me.
Can you help?
Just want to capture screenshot in j2me
I'm not really sure of what you wanted to do but if you are thinking of a way for your app to get a screenshot of its screen then what I can say is that you can and cannot do it. Why you cannot do it? Say your using a canvas in creating your screen. I think there isn't a way of converting the Canvas to an Image. The Canvas is limited to just drawing itself on the phone screen. But, like what I have said earlier, you can also create a screenshot of your app screen. What you need to have is an Image object over your Canvas. Why Image? It is because the Image object can be converted to an image file. And the image file will be your screenshot. But, of course, there should be something that dynamically creates the image source for the image object on the canvas.
Image myScreen = Image.createImage(createScreen());
A method that creates the screen:
InputStream createScreen(){
//dynamically creates the source of the screen
}
You can have a screenshot using myScreen. The drawback here is that rendering is quite slow. This is possible but I think this is kind of difficult to implement.
With this snippet code you can take a "screenshot" of the Canvases in your app:
public Image getScreenShot() {
Image screenshot = Image.createImage(getWidth(), getHeight());
Graphics g = screenshot.getGraphics();
paint(g);
return Image.createImage(screenshot);
}
Add getScreenShot() to any canvas that you want "screenshot" of it.Then you can get it's RGB and convert to byte[] and pass it on the network.
References:
developer.nokia

Resources