Gathering detailed insights and metrics for @rtiodev/lightning-image
Gathering detailed insights and metrics for @rtiodev/lightning-image
Get lightning fast information about images with little resources.
npm install @rtiodev/lightning-image
Typescript
Module System
Node Version
NPM Version
72
Supply Chain
99.4
Quality
75.3
Maintenance
100
Vulnerability
81.3
License
TypeScript (86.53%)
JavaScript (13.47%)
Total Downloads
1,159
Last Day
1
Last Week
3
Last Month
16
Last Year
668
4 Stars
42 Commits
2 Watching
7 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
@rtiodev/lightning-image@1.0.1
Unpacked Size
7.15 MB
Size
1.92 MB
File Count
57
NPM Version
9.8.1
Node Version
18.14.1
Publised On
16 Aug 2023
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
3
Compared to previous week
Last month
-85.8%
16
Compared to previous month
Last year
36%
668
Compared to previous year
An efficient and flexible image format detection and processing library. With Lightning Image
, you can effortlessly obtain the dimensions of images, determine their format, and even check if they are animated, all from just a few bytes of data!
Lightning Image
is not just about handling large images; it's about doing it right. Some browsers have limitations with big pixel images, leading to not just processing issues but potential security vulnerabilities.
By relying on native methods, you may be forced to pass the image through the server for evaluation, opening the door to various risks. Lightning Image
addresses these concerns by fetching only the first 1000 bytes of the image data, validating the format, and obtaining dimensions even for immense images that other methods might struggle with.
If you're looking for a powerful image processing library specifically tailored for backend environments, you might want to explore Sharp, a high-performance Node.js image processing library. Lightning Image
is designed with browser environments in mind and offers unique solutions for front-end challenges.
With Lightning Image
, your image processing is not only lightning-fast but also secure and user-friendly. It's about making big feel small and safe! âĄī¸đ¨đĄī¸
Please note that currently the AVIF and TIFF image formats are behaving unexpectedly with some images. See the test file for details.
1npm install lightning-image
1import { getImageDimensions, getImageFormat, isAnimated } from 'lightning-image'; 2 3const imageURL = 'path_to_image/image.png'; 4 5// Get image dimensions 6getImageDimensions(imageURL).then(dimensions => { 7 console.log(dimensions); 8 // { width: 100, height: 200, type: 'PNG' } 9}); 10 11// Get image format 12getImageFormat(imageURL).then(format => { 13 console.log(format); // e.g., 'PNG' 14}); 15 16// Check if the image is animated 17isAnimated(imageURL).then(animated => { 18 console.log(animated); // e.g., true 19});
If you'd like to include Lightning Image
directly in your HTML file, you can do so using the UMD build. Here's how:
If hosting locally:
1<script src="path_to_local_directory/lightning-image.js"></script>
Or, if using a CDN (this is just a placeholder link):
1<script src="https://cdn.example.com/lightning-image/latest/lightning-image.js"></script>
Once you've included the script, the library's functions will be available under a global namespace, e.g., LightningImage
:
1<script>
2 const imageURL = 'path_to_image/image.png';
3
4 // Get image dimensions
5 LightningImage.getImageDimensions(imageURL).then(dimensions => {
6 console.log(dimensions); // { width: 100, height: 200, type: 'PNG' }
7 });
8
9 // Get image format
10 LightningImage.getImageFormat(imageURL).then(format => {
11 console.log(format); // e.g., 'PNG'
12 });
13
14 // Check if the image is animated
15 LightningImage.isAnimated(imageURL).then(animated => {
16 console.log(animated); // e.g., true
17 });
18</script>
The project provides various builds suitable for different environments getting leverage from UMD (Universal Module Definition).
If you'd like to contribute to the development of Lightning Image, please follow these steps:
Remember, if you're planning a significant refactor or introducing breaking changes, your PR might not be approved.
Once your PR is approved, it will be merged, and a new version will be released.
Certainly, let's add a development section to guide contributors through setting up the development environment and making changes.
Clone the repository:
1git clone https://github.com/yourusername/lightning-image.git 2cd lightning-image
Install dependencies:
Ensure you have Node.js and npm installed. Once you've cloned the project, install the required dependencies:
1npm install
Understanding the project structure:
The main library logic is housed in lightning.ts
, and specific format checkers for each image type are in their respective files, e.g., png.ts
, jpeg.ts
, etc. Configuration for bundling is in webpack.config.js
.
Branching:
Always create a new branch for your changes:
1git checkout -b feature/my-new-feature
Code Style:
Please adhere to the existing coding style in the project. Proper naming, indentation, and comments are appreciated.
Testing:
If you introduce new features or changes, make sure they don't break existing functionality. If possible, add tests that cover your changes.
Building:
Before submitting your changes, build the project to ensure everything works:
1npm run build
This will run the configurations specified in webpack.config.js
and produce builds in the dist
directory.
Committing Changes:
Keep your commit messages descriptive and concise. Group smaller changes into a single commit. This makes it easier to track changes and revert if needed:
1git commit -m "Added a new feature to detect XYZ format"
Pushing and Creating a Pull Request:
Once you've committed your changes, push them to your branch:
1git push origin feature/my-new-feature
Then, head to the GitHub repository and create a new Pull Request. Fill in the PR template with details about your change.
Feedback:
Maintainers will review your PR. Address any comments or feedback they might have. Once everything is approved, your changes will be merged.
If you run into issues or need guidance, feel free to open an issue or contact the maintainers.
This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
No vulnerabilities found.
No security vulnerabilities found.