
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
FS-Props is a Javascript library that helps to parse image, audio, video or any file and folder and give its stats and properties of the respective file.
It uses exifreader node package for image properties and fluent-ffmpeg for audio and video properties.
File Name
and Extension
.
File or Folder Size
.
File Mime Type
.
Folders Contains
.
Image Dimensions
, Resolution
, Bit Depth
, Color Type
, Sub Sampling
, Compression
, Filter
, Resource URL
.
File or Folder Workspace
, Directory
and Location
.
Audio Title
, Album
, Artist
, Composer
, Genre
, Bit Rate
, Channels
, Year
, Duration
.
Video Dimensions
, Frame Rate
, Bit Rate
, Ratio
, Duration
.
Timestamp of created
, changed
, modified
, accessed
with relative timestamp.
const fp = require("fs-props");
fp.props("/path/to/file/or/folder").then((properties) => {
console.log(properties);
});
// using async and await
(async () => {
const properties = await fp.props("/path/to/file/or/folder");
console.log(properties);
})();
These are the following useful methods
fp.props()
- Get all properties like file or folder sizes, timestamps, image or video dimensions, audio or video durations etc...fp.stat()
, fp.statSync()
- Get only file or folder stats. This will not return image or audio or video properties.fp.deepStat()
, fp.deepStatSync()
- Get stat list of all the files in a directory and its subdirectoriesfp.timeStamp()
, fp.timeStampSync()
- It returns an object with the file's creation, change, modification, and access timestamps.fp.imageProps()
- It returns image properties like dimensions, resolution, width, height etc.. If the given file path is a image file.fp.audioProps()
- It returns audio properties like artist, album, composer, durations etc.. If the given file path is a audio file.fp.videoProps()
- It returns video properties like dimensions, durations, width, height etc.. If the given file path is a video file.fp.ffprobePromise()
- It takes a file path as a string, and returns a promise that resolves to the metadata of the audio or video filefp.convertBytes()
- It takes a number of bytes and returns a string with the number of bytes in a human readable format.fp.humanizeDuration()
- It takes a duration in milliseconds and returns a human readable string.fs-props [path]
[path/to/save/properties]
fs-props "/path/to/file/or/folder" "/path/to/save/properties.json"
{
"fileName": "FS Props",
"baseName": "FS Props",
"directory": "C:/Users/MYCOU/Work_Space/GitRepos",
"location": "C:/Users/MYCOU/Work_Space/GitRepos/FS Props",
"size": 177462033, // accumulation of all the nested file sizes from the given folder
"sizePretty": "169.24 MB (177462033 bytes)",
"type": "Folder",
"isFile": false,
"isDirectory": true,
"containedFiles": 5622,
"containedFolders": 623,
"containsPretty": "5622 Files, 623 Folders",
"contains": { "files": 5622, "folders": 623 },
/* ... timestamp properties */
"stats": { /* ... fs stats */ }
}
{
"fileName": "package.json",
"baseName": "package",
"extension": ".json",
"directory": "C:/Users/MYCOU/Work_Space/GitRepos/FS Props",
"location": "C:/Users/MYCOU/Work_Space/GitRepos/FS Props/package.json",
"size": 1350,
"sizePretty": "1.32 KB (1350 bytes)",
"type": "File",
"mimeType": "application/json",
"isFile": true,
"isDirectory": false,
"timestamps": {
/* ... */
},
"stats": {
/* ... */
}
}
This timestamp object will be there for any file or folder
{
/* ... File or Folder properties */
"created": "2022-11-18T05:19:45.711Z",
"changed": "2022-11-18T16:15:52.365Z",
"modified": "2022-11-18T16:15:52.365Z",
"accessed": "2022-11-18T17:10:42.824Z",
"createdMs": 1668748785710.9785,
"changedMs": 1668788152365.1013,
"modifiedMs": 1668788152365.1013,
"accessedMs": 1668791442823.701,
"createdLocal": "18/11/2022, 10:49:45 am",
"changedLocal": "18/11/2022, 9:45:52 pm",
"modifiedLocal": "18/11/2022, 9:45:52 pm",
"accessedLocal": "18/11/2022, 10:40:42 pm",
"createdRelative": "12 hours ago",
"changedRelative": "an hour ago",
"modifiedRelative": "an hour ago",
"accessedRelative": "a few seconds ago"
}
This is node stats that returned using fs.stat()
method.
{
/* ... File or Folder properties */
/* ... timestamp properties */
"stats": {
"dev": 3569872940,
"mode": 33206,
"nlink": 1,
"uid": 0,
"gid": 0,
"rdev": 0,
"blksize": 4096,
"ino": 6192449487773464,
"size": 1350,
"blocks": 8,
"atimeMs": 1668791442823.701,
"mtimeMs": 1668788152365.1013,
"ctimeMs": 1668788152365.1013,
"birthtimeMs": 1668748785710.9785,
"atime": "2022-11-18T17:10:42.824Z",
"mtime": "2022-11-18T16:15:52.365Z",
"ctime": "2022-11-18T16:15:52.365Z",
"birthtime": "2022-11-18T05:19:45.711Z"
}
}
isImage
is set to true if the given file is a image.{
/* ... File or Folder properties */
/* ... timestamp properties */
/* ... Fs Stats properties */
"isImage": true,
"dimensions": "3840 x 2160 pixels",
"width": 3840,
"height": 2160,
"resolution": "72 x 72 Dpi",
"xResolution": 72,
"yResolution": 72,
"orientation": "top-left",
"bitDepth": "8",
"colorType": "RGB ",
"subSampling": "YCbCr4:4:4 (1 1)",
"compression": 1,
"resourceURL": "https://stsci-opo.org/STScI-01FMN25HSDCX1M8BZTK69ZE1JP.jpg",
"metadata": {
/* ... from exif library. */
}
}
Note
: Themetadata
is the full object from exifreader node package. For sample object please click here.
metadata
may be undefined if the given image file is not recognizable by the exifreader.metadata
can be undefined but still we can see the dimensions
, width
and height
of the image.isAudio
is set to true if the given file is a audio file.{
/* ... File or Folder properties */
/* ... timestamp properties */
/* ... Fs Stats properties */
"isAudio": true,
"title": "Yolo You Only Live Once - TamilTunes.com",
"album": "Anegan (2014)",
"artist": "Shail Hada,Ramya NSK,Richard,MC Vickey,Eden",
"composer": "Harris Jayaraj",
"year": "2014",
"duration": 278.987755,
"durationPretty": "4 minutes, 38.98 seconds",
"bitRate": 299170,
"bitRatePretty": "292.16 kbps",
"channels": "2 (stereo)",
"metadata": {
/* ... from fluent-ffmpeg library. */
}
}
Note
: Themetadata
is the full object from fluent-ffmpeg node package. For sample object please click here.
metadata
may be undefined if the given audio file is not recognizable by the fluent-ffmpeg.isVideo
is set to true if the given file is a video file.{
/* ... File or Folder properties */
/* ... timestamp properties */
/* ... Fs Stats properties */
"isVideo": true,
"dimensions": "1280 x 720 pixels",
"width": 1280,
"height": 720,
"resolution": "1280 x 720 pixels",
"duration": 6774.562,
"durationPretty": "1 hour, 52 minutes, 54.56 seconds",
"bitRate": 95316,
"bitRatePretty": "93.08 kbps",
"frameRate": 29.97,
"frameRatePretty": "29.97 fps",
"framesPerSecond": "29.97 fps",
"ratio": "16:9",
"metadata": {
/* ... from fluent-ffmpeg library. */
}
}
Note
: Themetadata
is the full object from fluent-ffmpeg node package. For sample object please click here.
metadata
may be undefined if the given video file is not recognizable by the fluent-ffmpeg.Sivaraman - sendmsg2siva.siva@gmail.com
MIT
FAQs
Get fs stats, image dimensions, audio and video metada
The npm package fs-props receives a total of 6 weekly downloads. As such, fs-props popularity was classified as not popular.
We found that fs-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.