Skip to content
forked from meituan/imghdr

The imghdr module determines the type of image contained in a file or octet streams(obj of Buffer).

License

Notifications You must be signed in to change notification settings

zhiyelee/imghdr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imghdr

The imghdr module determines the type of image contained in a file or octet-streams(object of Buffer), inspired by Python's imghdr module.

The imghdr module defines the following function:

imghdr.what(imgPath)

Tests the image data contained in the file named by imgPath, and returns a string describing the image type. imgPath can be a object of Buffer.

Value Image format
"png" Portable Network Graphics
"jpeg","jpg" JPEG data in JFIF or Exif formats
"gif" GIF 87a and 89a Files
"tiff" Tagged Image File Format
"bmp" BMP files
"webp" WebP files

You can extend the list of file types imghdr can recognize by appending to this variable:

imghdr.tests

A list of functions performing the individual tests. Each function takes a argument: the octet-streams(object of Buffer).The test function should return a string describing the image type if the test succeeded, or flase if it failed.

Reference

About

The imghdr module determines the type of image contained in a file or octet streams(obj of Buffer).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%