Node screenshot tool images (node-images)

Source: Internet
Author: User

We often encounter the server upload images to crop or add logo and so on, how to do on the node platform?

See everyone in the use of "GM" this tool, the function is very powerful, but on the Windows platform is a variety of pits Ah, I have a whole afternoon, although some problems solved, but also chose another good, and lightweight cross-platform better module--images

Installation mode NPM Install images

GitHub address is Https://github.com/zhangyuanwei/node-images

As the author describes, lightweight, cross-platform, jquery-style

I'll just list a few of the features we've used to demo

1. Set or get the size of the picture

The first type:

1 var images = require ("Images"); 2 images ("image/test.jpg")3    . Size ()4     . Save ("Image/dist.jpg ");

The second Kind

1 var images = require ("Images"); 2 images ("image/test.jpg")3    . Width ()4     . Save ("image/ Dist.jpg ");

In either of these ways, if the parameter is not included, the width or height of the picture is returned, and the size returns a json,{width:,height:}, if the parameter is included, The picture will change the image size according to the parameter settings (there is also a resize () interface can also set the size of the picture)

2. Draw a region, currently images in this area function is relatively limited, can only draw square.

1 var images = require ("Images"); 2 images (400,400)3     . Fill (255,0,0,0.5)4     . Save ("image/ Dist.jpg ");

The above code draws a 400*400 Red square.

3. Draw the logo into the picture, this is still more practical, directly on the code

1 var images = require ("Images"); 2 images ("image/test.jpg")3     . Draw (Images ("image/logo.jpg"), 200,200)  4     . Save ("image/dist.jpg");

4. Capturing part of the image, this function and its usefulness, especially when capturing the user's avatar, is very meaningful

1 var images = require ("Images"); 2 images (Images ("image/test.jpg"), 200,200,500,500)3     . Resize (+4)      . Save ("image/dist.jpg");

This is a few of the more common features of this tool, although a lot less than GM, but enough to meet most of our basic needs.

Node screenshot tool images (node-images)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.