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

@artdotstyle/filepix

v1.0.11

Published

powerful image convertor package this package you can convert the file into a different format

Downloads

11

Readme

FilePix

npm building workflow

Installation

Install via NPM:

npm install filepix
const filepix = require("filepix");
import * as filepix from "filepix";

Convert images to PDF

this feature let you convert your images into a single pdf file

filepix.img2PDF(pages = './inputImagesDir', output = "./outputImageDir/output.pdf");

or maybe your images file in different path for this case you can use below code:

filepix.img2PDF(
  pages = [
        './1.jpg',
        './public/upload/2.jpg',
        './public/upload/example/3.jpg'
  ],
  output = "./outputImageDir/output.pdf");

Add effects

Color

Apply multiple color modification rules

let options = {
   effects: [
              {
                  name: 'color',
                  config: [{ apply: 'green', params: [100] }]
              }
            ]
  };
filepix.img2PDF(pages = './inputImagesDir', output = "./outputImageDir/output.pdf", options);

Flip

Flip the image horizontally or vertically. Defaults to horizontal.

let options = {
   effects: [
              {
                  name: 'mirror'
              }
            ]
  };
let options = {
   effects: [
              {
                name: 'flip',
                config: {
                    vertical: true
                }
              }
            ]
  };
filepix.img2PDF(pages = './inputImagesDir', output = "./outputImageDir/output.pdf", options);

Blur

A fast blur algorithm that produces similar effect to a Gaussian blur

let options = {
   effects: [
              {
                name: 'blur',
                config: {
                    pixels: 50
                }
              }
            ]
  };

Rotate

Rotates the image clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.

let options = {
   effects: [
              {
                name: 'rotate',
                config: {
                    ratio: 45
                }
              }
            ]
};

Brightness

let options = {
   effects: [
              {
                name: 'brightness',
                config: {
                    ratio: 0.1
                }
              }
            ]
};

Contrast

let options = {
   effects: [
              {
                name: 'contrast',
                config: {
                    ratio: 0.2
                }
              }
            ]
  };

Gaussian

let options = {
   effects: [
              {
                name: 'gaussian',
                config: {
                    ratio: 2
                }
              }
            ]
};

Posterize

let options = {
   effects: [
              {
                name: 'posterize',
                config: {
                    ratio: 100
                }
              }
            ]
};

Opacity

let options = {
   effects: [
              {
                name: 'opacity',
                config: {
                    ratio: 0.1
                }
              }
            ]
};

Sepia

let options = {
   effects: [
              {
                name: 'sepia'
              }
            ]
};

Quality

let options = {
   effects: [
              {
                name: 'quality',
                config: {
                    ratio: 10
                }
              }
            ]
};

Fade

let options = {
   effects: [
              {
                name: 'fade',
                config: {
                    ratio: 0.1
                }
              }
            ]
};

Pixelate

let options = {
   effects: [
              {
                name: 'pixelate',
                config: {
                    ratio: 50
                }
              }
            ]
};

Normalize

let options = {
   effects: [
              {
                name: 'normalize',
                config: {
                    ratio: 50
                }
              }
            ]
};

Threshold

let options = {
   effects: [
              {
                name: 'threshold',
                config: { max: 200, replace: 200, autoGreyscale: false }
              }
            ]
};

multiple effects

you can combine effects by using below code:

let options = {
   effects: [
            {
                name: 'quality',
                config: {
                    ratio: 10
                }
            },
            {
                name: 'contrast',
                config: {
                    ratio: 0.2
                }
            },
            {
              name: 'threshold',
              config: { max: 200 }
            }
          ]
};

Add watermarks

you can add watermark to all images and merge them as single pdf by set below option path: watermark image path position: watermark position (center,right,right-bottom,center-bottom,left-top,left-bottom)

options = {
  watermark: {
            type: 'image',
            path: '../logo1.jpg',
            ratio: 0.2,
            opacity: 0.2,
            position: 'left-bottom'
  }
}

Convert pdf to images

this feature let you convert your pdf into multiple images.

filepix.PDF2img('./inputImagesDir/input.pdf', "./outputImageDir");

Convert pdf to word document

NOTE: this method using OCR so first, you need to install the Tesseract project. Instructions for installing Tesseract for all platforms can be found on the project site.

after installing Tesseract you can easily convert your pdf into file as docx format by calling below code:

await filepix.pdf2docx('./inputImageDir/input.pdf', './outputImageDir/output.docx');

Custom Language

1- find your LangCode from here 2- download proper .traineddata file from here and copy it on your local machine in Tesseract-OCR/tessdata directory 3- finally use below code:

await filepix.pdf2docx('./inputImageDir/input.pdf', './outputImageDir/output.docx',  options = { lang: "deu" });

Convert png to jpg

convert png format into jpg even you can compress your image.

await filepix.png2jpeg('./input.png', './output.jpg'
, options = {
  quality: 50
});

base64 to jpg or png

convert base64 to png or jpg by calling below method.

await filepix.base64ToImg('base64Str', './outputImageDir/output.png', { extension: 'png' });

Support

Contributors

if your pull requests makes documentation changes, please update readme file.

License

This project is licensed under the terms of the MIT license