module gd
Image file processing module
base module. Can be used to create and manipulate image files, referenced by:
1var gd = require('gd');
static function
create
Create a new image
1
2
3static Image gd.create(Integer width,
Integer height,
Integer color = gd.TRUECOLOR) async;
Call parameters:
- width: Integer, specifies the width of the image
- height: Integer, specifies the image height
- color: Integer, specifies the image type, allowed values aregd.TRUECOLORorgd.PALETTE
Return result:
- Image, returns the successfully created image object
load
Decode image from format data
1static Image gd.load(Buffer data) async;
Call parameters:
- data:Buffer, given the decoded image data
Return result:
- Image, returns the decoded image object
Decode image from stream object
1static Image gd.load(SeekableStream stm) async;
Call parameters:
- stm:SeekableStream, the stream object where the given image data resides
Return result:
- Image, returns the decoded image object
Decode an image from the specified file
1static Image gd.load(String fname) async;
Call parameters:
- fname: String, specifies the file name
Return result:
- Image, returns the decoded image object
rgb
Generate combined color from rgb color components
1
2
3static Integer gd.rgb(Integer red,
Integer green,
Integer blue);
Call parameters:
- red: Integer, red component, range 0-255
- green: Integer, green component, range 0-255
- blue: Integer, blue component, range 0-255
Return result:
- Integer, returns the combined color
rgba
Generate combined color from rgba color components
1
2
3
4static Integer gd.rgba(Integer red,
Integer green,
Integer blue,
Number alpha);
Call parameters:
- red: Integer, red component, range 0-255
- green: Integer, green component, range 0-255
- blue: Integer, blue component, range 0-255
- alpha: Number, transparent component, range is 0.0-1.0
Return result:
- Integer, returns the combined color
hsl
Generate combined color from hsl color components
1
2
3static Integer gd.hsl(Number hue,
Number saturation,
Number lightness);
Call parameters:
- hue: Number, the hue component, the range is 0-360
- saturation: Number, saturation component, in the range 0.0-1.0
- lightness: Number, luminance component, range is 0.0-1.0
Return result:
- Integer, returns the combined color
hsla
Generate combined colors from hsla color components
1
2
3
4static Integer gd.hsla(Number hue,
Number saturation,
Number lightness,
Number alpha);
Call parameters:
- hue: Number, the hue component, the range is 0-360
- saturation: Number, saturation component, in the range 0.0-1.0
- lightness: Number, luminance component, range is 0.0-1.0
- alpha: Number, transparent component, range is 0.0-1.0
Return result:
- Integer, returns the combined color
hsb
Generate combined color from hsb color components
1
2
3static Integer gd.hsb(Number hue,
Number saturation,
Number brightness);
Call parameters:
- hue: Number, the hue component, the range is 0-360
- saturation: Number, saturation component, in the range 0.0-1.0
- brightness: Number, brightness component, range is 0.0-1.0
Return result:
- Integer, returns the combined color
hsba
Generate combined colors from hsba color components
1
2
3
4static Integer gd.hsba(Number hue,
Number saturation,
Number brightness,
Number alpha);
Call parameters:
- hue: Number, the hue component, the range is 0-360
- saturation: Number, saturation component, in the range 0.0-1.0
- brightness: Number, brightness component, range is 0.0-1.0
- alpha: Number, transparent component, range is 0.0-1.0
Return result:
- Integer, returns the combined color
color
Generate combined colors from strings
1static Integer gd.color(String color);
Call parameters:
- color: String, a string specifying the color, such as: "#ff0000", "ff0000", "#f00", "f00"
Return result:
- Integer, returns the combined color
constant
NONE
Image format constant, indicating that the current image source is unknown
1const gd.NONE = 0;
JPEG
Image format constant, indicating that the current image source is jpeg format data
1const gd.JPEG = 1;
GIF
Image format constant, indicating that the current image source is gif format data
1const gd.GIF = 2;
PNG
Image format constant, indicating that the current image source is png format data
1const gd.PNG = 3;
TIFF
Image format constant, indicating that the current image source is tiff format data
1const gd.TIFF = 4;
BMP
Image format constant, indicating that the current image source is bmp format data
1const gd.BMP = 5;
WEBP
Image format constant, indicating that the current image source is webp format data
1const gd.WEBP = 6;
TRUECOLOR
Image type constant, indicating that the current image is a true color image
1const gd.TRUECOLOR = 0;
PALETTE
Image type constant, indicating that the current image is a palette image
1const gd.PALETTE = 1;
ARC
Fan drawing style, draws an arc connecting the start and end points
1const gd.ARC = 0;
CHORD
Fan drawing style, draws a straight line connecting the origin, start and end points
1const gd.CHORD = 1;
NOFILL
Sector drawing style, draws an unfilled sector
1const gd.NOFILL = 2;
EDGED
Fan drawing style, draws an arc connecting the start and end points and a line connecting the origin
1const gd.EDGED = 4;
HORIZONTAL
Mirror direction, horizontal mirror processing
1const gd.HORIZONTAL = 1;
VERTICAL
Mirror direction, do mirroring vertically
1const gd.VERTICAL = 2;
BOTH
Mirror orientation, both landscape and portrait are mirrored
1const gd.BOTH = 3;
LEFT
Rotation direction, rotate to the left
1const gd.LEFT = 1;
RIGHT
Rotation direction, rotate right
1const gd.RIGHT = 2;
MEAN_REMOVAL
Filter type: use average removal to achieve contouring effect
1const gd.MEAN_REMOVAL = 0;
EDGEDETECT
Filter Type: Use edge detection to highlight the edges of the image
1const gd.EDGEDETECT = 1;
EMBOSS
Filter Type: Emboss Image
1const gd.EMBOSS = 2;
SELECTIVE_BLUR
Filter Type: Blur Image
1const gd.SELECTIVE_BLUR = 3;
GAUSSIAN_BLUR
Filter Type: Blur image with Gaussian algorithm
1const gd.GAUSSIAN_BLUR = 4;
NEGATE
Filter Type: Invert all colors in the image
1const gd.NEGATE = 5;
GRAYSCALE
Filter Type: Convert Image to Grayscale
1const gd.GRAYSCALE = 6;
SMOOTH
filter type: make the image smoother, set the smoothness level with arg1
1const gd.SMOOTH = 7;
BRIGHTNESS
Filter type: change the brightness of the image, use arg1 to set the brightness level, the value range is -255~255
1const gd.BRIGHTNESS = 8;
CONTRAST
Filter type: change the contrast of the image, use arg1 to set the contrast level, the value range is 0~100
1const gd.CONTRAST = 9;
COLORIZE
Filter type: change the color tone of the image, use arg1, arg2, arg3 to specify red, blue, green respectively, each color range is 0~255, arg4 is the transparency, the value returned is 0~127
1const gd.COLORIZE = 10;