Code Monkey home page Code Monkey logo

img-man's Introduction

Img-man

What is?

This is a module that allows you to take control of what image extension are fetched by some functions that allows you for exaple know the image extensions that are avalible for some image.

How to use?

import the package by ESM.

import im from "img-man";

then use the function that you wanna use. Note that all the functions are asyncronous.

await im.detectFor("imgName","Dir");

detectFor

Return an object of the follow structure:

{
	"jpeg":{
		"dir":"some/path/fileName.jpeg"
	}
	"webp":{
		"dir":"some/path/fileName.webp"
	}
}

Takes three parameters.

await im.detectFor(fileName, root, extList);
  • fileName. That is the name of the image we are been looking for. Type String.
  • root. That is the path were we are been looking for the avalibe extensions. By default is setted to ".". Type String.
  • extList. That contains the extensions that we will been looking for.

***Note:***This method check every extension and fileName conbination.

bruteDetectFor

Return an object of the follow structure:

{
	"jpeg":{
		"dir":"some/path/fileName.jpeg"
	}
	"webp":{
		"dir":"some/path/fileName.webp"
	}
}

Takes two parameters.

await im.detectFor(fileName, root);
  • fileName. That is the name of the image we are been looking for. Type String.
  • root. That is the path were we are been looking for the avalibe extensions. By default is setted to ".". Type String.

***Note:***This method check every file in the root folder

getFirstExtFor

Return a string that contains the extension file. Ex. "png"

Takes three parameters:

await im.getFirstExtFor(fileName, list, root);
  • fileName. That is the name of the image we are been looking for. Type String.
  • list. Order in which the extension is preferred. Type Array.
  • root. That is the path were we are been looking for the avalibe extensions. By default is setted to ".". Type String.

Orders

lightExtSort

Its an array of extensions sorted by optimal compresion for the web.

const lightExtSort = ["webp","jpg","jpeg","png","gif","esp","bmp","tif","tiff","raw"]

img-man's People

Contributors

jglvega1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.