Giter Club home page Giter Club logo

is-image's Introduction

is-image

Check if a file path is an image

It just checks the extension. Use image-type if you want to check the actual file.

Install

npm install is-image

Usage

import isImage from 'is-image';

isImage('source/unicorn.png');
//=> true

isImage('source/unicorn.txt');
//=> false

Related

is-image's People

Contributors

appleboy avatar bendingbender avatar bobbyg603 avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

is-image's Issues

HEIC file recognition error

const isImage = require('is-image');

isImage('2022-02-23-044507.HEIC'); // => false

This file is a picture

Handle filename with dots

Just found the case, when I have a file with a dots before the actual extention.
Example:

const isImage = require('is-image');
isImage('file.with.dots.mp3'); // => false

@sindresorhus what if such case will be handled by is-image lib?

Error while importing

Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Instead change the require of index.js in validator.js to a dynamic import() which is available in all CommonJS modules.
at Object. ( validator.js:1:21) {
code: 'ERR_REQUIRE_ESM'
}

Needs more test cases

Thanks for this module. I just noticed some failed tests

The url example.png is not an image, but is-image says it is an image

The url example.png?size=1&color=b is an image, but is-image says that it is not an image, and I think its because of the query string

Error when compiling with webpack -p.

This causes an error when it's included in a project and you are bundling with webpack -p.

This is the error.
ERROR in bundle.js from UglifyJs
Unexpected token: operator (>) [bundle.js:75024,27]

[Bug report] Dependency 'node:path' was not found

While using [email protected], I got the error:

This dependency was not found:

* node:path in ./node_modules/is-image/index.js

To install it, you can run: npm install --save node:path

ERROR in ./node_modules/is-image/index.js
Module not found: Error: Can't resolve 'node:path' in '/path/to/node_modules/is-image'

Downgrade to [email protected] and everything is fine.

Version of My Node.js is v16.15.1.

Useless

Hello.
This module is useless. You just check the extension. Better check the magic numbers of the file for this to work.

Webpack -p Build Error

This causes an error when it's included in a project and you are bundling with webpack -p.

This is the error.
ERROR in bundle.js from UglifyJs
Unexpected token: operator (>) [bundle.js:75024,27]

I'm using all sorts of ES2015 in my code without issue.
The webpack config I'm running is using babel to transpile with these presets:
presets: ['env', 'stage-0', 'react', 'es2015']

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.