📜  Node.js GM emboss()函数(1)

📅  最后修改于: 2023-12-03 15:03:13.079000             🧑  作者: Mango

Node.js GM Emboss() Function

The emboss() function in the gm module of Node.js is used to create a "3D" effect on an image by highlighting the edges of an image with a bright color and shading the areas away from the edges with a darker color. This can create the appearance of an image being embossed onto the background.

Installation

To use the emboss() function, you first need to install the gm module in your Node.js project. You can do this by running the following command in your terminal:

npm install gm
Syntax

The syntax for using the emboss() function in Node.js is as follows:

gm('/path/to/image.jpg')
.emboss()
.write('/path/to/new/image.jpg', function (error) {
  if (!error) console.log('Image converted successfully!');
});
Parameters

The emboss() function does not take any parameters.

Example

Here is an example of using the emboss() function to create an embossed image:

const gm = require('gm');

gm('/path/to/image.jpg')
.emboss()
.write('/path/to/new/image.jpg', function (error) {
  if (!error) console.log('Image converted successfully!');
});

In this example, the emboss() function is called on an image located at /path/to/image.jpg. The resulting embossed image is saved to /path/to/new/image.jpg.

Conclusion

The emboss() function in the gm module of Node.js is a great way to add a 3D effect to your images. It's easy to use and can create some really interesting visual effects. Try experimenting with different images and settings to see what kind of embossed images you can create!