npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imagizer-javascript

v1.9.1

Published

An Image processing library that uses openCV

Downloads

22

Readme

imagizer

Imagizer is an node js image processing library that harnesses the power of open CV to process images in JavaScript. It is built on Python Open CV and imutils so you don't have to use a powerful computer plus it's super fast.

  • Before usage be sure to have python 3 and pip installed before using imagizer
  • only jpg, jpeg, png, raw, psd and svg images are supported

Features

  • [x] Image resize
  • [x] Image rotate
  • [x] Convert Image to black and white
  • [x] Blure out image
  • [x] Cartoonise image
  • [x] Text on image
  • [x] Merge images together
  • [x] Convert images to video
  • [x] Concat 2 images vertically orhorizontally
  • [x] Convert an image to pencil sketch
  • [x] generate blank image
  • [x] generate blank image with text
  • [x] draw shape over image
  • [x] draw marker over image
  • [x] invert image colour
  • [x] change image contrast
  • [x] crop image
  • [x] enhance image
  • [x] water color image

Installation

npm i imagizer-javascript

Usage

Before using the package, be sure to import it:

const imagizer=require('imagizer-javascript')

Resizing an image

imagizer.resizeImg(image_path, new_file_name, folder_destination, resize_width).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and resized image

unprocessed image resized image

Note: All parameters are required

Black and white image

imagizer.BnW(image_path, new_file_name, folder_destination).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and black-white image

unprocessed image black and white Note: All parameters are required

Rotate Image

imagizer.rotateImage(image_path, new_file_name, folder_destination, rotate_angle).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and rotated image (90 degree)

unprocessed image black and white Note: All parameters are required

Blure Image

imagizer.BlurrImage(image_path, new_file_name, folder_destination).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and blured image

unprocessed image blurred image Note: All parameters are required

Cartonize Image

imagizer.Cartoonize(image_path, new_file_name, folder_destination).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and cartoon image

unprocessed image cartoon image Note: All parameters are required

Text on image

imagizer.TextOver(image_path, new_file_name, folder_destination, text, rgb_for_text, text_size, X_coordinate, y_coordinate, text_font).then(image_path=>{
    console.log(image_path)
})

sample image and text image

unprocessed image text image Note:

  • All parameters are required
  • rgb should be sent as a string eg '(0, 0, 0)'
  • text_size goes from 0.1 to greater (but for average text size, 0.5- 1 would be okay)
  • To use the default rgb, let rgb be undefined

available font include:

  • "FONT_HERSHEY_SIMPLEX"
  • "FONT_HERSHEY_PLAIN"
  • "FONT_HERSHEY_DUPLEX"
  • "FONT_HERSHEY_COMPLEX"
  • "FONT_HERSHEY_TRIPLEX"
  • "FONT_HERSHEY_COMPLEX_SMALL"
  • "FONT_HERSHEY_SCRIPT_SIMPLEX"
  • "FONT_HERSHEY_SCRIPT_COMPLEX"
  • "FONT_ITALIC"

Pencil Sketch image

imagizer.PencilSketchImg(image_path, new_file_name, folder_destination).then(image_path=>{
    console.log(image_path)
}).catch(err=>{ console.log(err) })

sample image and pencil-sketch image

unprocessed image sketch image Note: All parameters are required

Merge 2 images overlay

imagizer.OverLay(image_one, image_two, new_file_name, image_one_opacity, image_two_opacity, file_destination).then(img_path=>{
    console.log(img_path)
})

sample images

unprocessed image unprocessed image 2

resulting merged image

overlay image Note:

  • All parameters are required
  • opacity can take the values 0.1, 0.9, 1.3, etc

Create Video from Images

  • This feature takes a folder that contains images and convert them to an avi video
imagizer.CreateVieo(image_folder, video_name, video_destination).then(video_path=>{
    console.log(video_path)
})

Note:

  • All parameters are required
  • The video always has an avi file extension

Concatenate 2 images vertically or horizontally

  • For vertical concatenation
 imagizer.ConcatImage(image_one, image_two, new_filename.jpg, file_destination, 'vertical').then(img_path=>{
                console.log(img_path)
            })
  • For horizontal concatenation
imagizer.ConcatImage(image_one, image_two, new_filename.jpg, file_destination, 'horizontal').then(img_path=>{
                console.log(img_path)
            })

resulting image

vertical image horizontal image 2

Note:

  • All parameters are required
  • Specify the file extenstion for the new file name

Generate blank image

  • This feature helps you create a blank image
imagizer.generateBlankImg(new_filename, file_destination, img_height, img_width, background_rgb).then(image_path=>{
    console.log(image_path)
})
  • All parameters are required
  • set backgroung_rgb to undefined to use default rgb value
  • rgb should be sent as a string eg '(0, 0, 0)'
  • set rgb to "random" to use randomly generated rgb
  • all generated image are have a ".jpg" file extension

sample image

sample image

Generate blank image with text

  • This feature hekps you generate blank images with text over it
imagizer.generateBlankImgWithText(new_filename, file_destination, img_height, img_width, image_rgb, text_rgb, text_y_coordinate, text_x_coordinate, text, text_size, font).then(image_path=>{
    console.log(img_path)
})
  • All parameters are required
  • set rgb to undefined to use default rgb value
  • rgb should be sent as a string eg '(0, 0, 0)'
  • set rgb to "random" to use randomly generated rgb
  • all generated image are have a ".jpg" file extension

available font include:

  • "FONT_HERSHEY_SIMPLEX"
  • "FONT_HERSHEY_PLAIN"
  • "FONT_HERSHEY_DUPLEX"
  • "FONT_HERSHEY_COMPLEX"
  • "FONT_HERSHEY_TRIPLEX"
  • "FONT_HERSHEY_COMPLEX_SMALL"
  • "FONT_HERSHEY_SCRIPT_SIMPLEX"
  • "FONT_HERSHEY_SCRIPT_COMPLEX"
  • "FONT_ITALIC"

sample image

sample image

Draw shape on image

  • This feature helps draw sapes over images
imagizer.drawShapeOverImg(file_origin, new_filename, file_destination, point1, point2, rgb, thickness, shape).then(img_path=>{
    console.log(img_path)
})
  • point 1 and point 2 take in string in the format (x, y) eg "(20, 100)". Point 1 is the starting point of the shape while point 2 is the ending point
  • rgb takes in a string in the format "(0, 0, 0)". This is the rgb value of the shape
  • thickness takes in an int that specifies the shape thickness (for most cases, 1-4 would suffice)
  • shape takes in a string of the shape to be drawn which includes: "circle", "rectangle", "line", and "arrow"

sample image

sample image

Draw marker over image

  • This feature adds a marker over image
imagizer.drawMarkerOnImg(file_origin, new_filename, file_destination, point, rgb, marker_type, marker_size, thickness).then(img_path=>{
    console.log(img_path)
})
  • Point takes in string in the format "(10, 20)" which specifies the x and y coordinate
  • rgb takes in a string in the format "(0, 0, 0)". This is the rgb value of the marker
  • marker type is the marker type to be used. Available options include: "MARKER_CROSS", "MARKER_TILTED_CROSS", "MARKER_STAR", "MARKER_DIAMOND", "MARKER_SQUARE", "MARKER_TRIANGLE_UP", and "MARKER_TRIANGLE_DOWN"
  • marker size takes in int that specifies the marker size
  • thickness takes in an int that specifies the marker thickness (for most cases, 1-4 would suffice)

sample image

sample image

Invert image color

  • This feature inverts an image colour
imagizer.invertImgColor(file_origin, new_filename, file_destination)

sample image

sample image

Change Image Contrast

  • This feature changes the image contrast
imagizer.contrastImg(file_origin, new_filename, file_destination, contrast_value).then(img_path=>{
    console.log(img_path)
})
  • Contrast value takes in a number usually between 1.0-5.0 based on your preference

sample images

unprocessed image contrast image

Crop Image

  • This feature crops an image
imagizer.cropImg(file_origin, new_filename, file_destination, x1, x2, y1, y2).then(img_path=>{
    console.log(img_path)
})
  • x1, x2, y1, y2 values take in number parameters. It specifies the start and end point to be cropped eg start from coordinate x1:y1 and end in the coordinate x2:y2

sample images

unprocessed image cropped image

Enhance Image

  • Enhance image quality
imagizer.enhancePhoto(file_origin, new_filename, file_destination).then((img_path) => {
        console.log(img_path)
    })

sample images

unprocessed image enhanced image

Water color image

  • Give image a water color effect
imagizer.stylePhoto(file_origin, new_filename, file_destination).then(img_path=>{
    console.log(img_path)
})

sample images

unprocessed image water color image

Author

Valentine Oragbakosi