diff --git a/npmextra.json b/npmextra.json index 6915293..43fc004 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,30 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartjimp", - "description": "a tool fr working with images in TypeScript", + "description": "A TypeScript library for image processing combining both sharp and jimp libraries.", "npmPackagename": "@push.rocks/smartjimp", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "image processing", + "TypeScript", + "sharp", + "jimp", + "resize image", + "convert image format", + "image caching", + "buffer manipulation", + "AVIF", + "WEBP", + "PNG" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index f809229..f10c5f0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartjimp", "version": "1.0.18", "private": false, - "description": "a tool fr working with images in TypeScript", + "description": "A TypeScript library for image processing combining both sharp and jimp libraries.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", @@ -52,5 +52,18 @@ "bugs": { "url": "https://gitlab.com/push.rocks/smartjimp/issues" }, - "homepage": "https://gitlab.com/push.rocks/smartjimp#readme" -} + "homepage": "https://gitlab.com/push.rocks/smartjimp#readme", + "keywords": [ + "image processing", + "TypeScript", + "sharp", + "jimp", + "resize image", + "convert image format", + "image caching", + "buffer manipulation", + "AVIF", + "WEBP", + "PNG" + ] +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index a9d2029..53b5591 100644 --- a/readme.md +++ b/readme.md @@ -1,37 +1,105 @@ # @push.rocks/smartjimp a tool fr working with images in TypeScript -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartjimp) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartjimp) -* [github.com (source mirror)](https://github.com/pushrocks/smartjimp) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartjimp/) +## Install -## Status for master +To install `@push.rocks/smartjimp`, use the following command in your project directory: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartjimp/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartjimp/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartjimp)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartjimp)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartjimp)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartjimp)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartjimp)](https://lossless.cloud) +```bash +npm install @push.rocks/smartjimp --save +``` ## Usage -Use TypeScript for best in class intellisense +`@push.rocks/smartjimp` is a comprehensive TypeScript library for handling image processing with ease and efficiency. It leverages powerful image processing libraries such as `sharp` and `jimp`, providing a unified interface for performing common image manipulation tasks. This documentation aims to guide you through the installation and various functionalities of `@push.rocks/smartjimp`, ensuring you have the knowledge to integrate image processing capabilities into your TypeScript project effectively. -## Contribution +### Getting Started -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +First, import the `SmartJimp` class from the package: -For further information read the linked docs at the top of this readme. +```typescript +import { SmartJimp } from '@push.rocks/smartjimp'; +``` -## Legal -> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +Next, create an instance of `SmartJimp` by specifying the preferred image processing mode (`sharp` or `jimp`): + +```typescript +const imageProcessor = new SmartJimp({ mode: 'sharp' }); +``` + +### Processing Images + +#### From Buffer + +You can process images from a buffer. This is particularly useful when you have image data already available in your application, such as uploaded images. + +```typescript +import { SmartFile } from '@push.rocks/smartfile'; + +// Assuming you have an image buffer `imageBuffer` +let imageBuffer: Buffer; + +// Convert the buffer to a SmartFile instance +const smartfileInstance = await SmartFile.fromBuffer(imageBuffer); + +// Process the image, for example, resizing it to width 500px +const resizedImageBuffer = await imageProcessor.getFromSmartfile(smartfileInstance, { + width: 500, +}); +``` + +#### Creating Specific Formats + +`@push.rocks/smartjimp` supports creating images in various formats, including AVIF, WebP, and PNG. + +```typescript +// For forcing a format, specify the `format` in the options, like 'png' +const pngBuffer = await imageProcessor.getFromSmartfile(smartfileInstance, { + width: 500, + format: 'png', +}); +``` + +### Advanced Image Manipulation + +#### Inversion + +You can invert the colors of an image as follows: + +```typescript +const invertedImageBuffer = await imageProcessor.getFromSmartfile(smartfileInstance, { + invert: true, +}); +``` + +### Performance and Caching + +`@push.rocks/smartjimp` employs caching mechanisms to enhance performance. Caching is handled internally, ensuring that repeated processing requests for the same image and settings are served faster by retrieving the processed image from the cache. + +### Mode: Sharp vs. Jimp + +- **Sharp**: Recommended for performance-critical applications. It is faster and supports a broader range of image formats. However, it relies on native libraries, which may need additional setup in certain environments. +- **Jimp**: A pure JavaScript image processing library. While not as fast as Sharp, it guarantees compatibility across all Node.js environments without the need for additional native dependencies. + +### Conclusion + +`@push.rocks/smartjimp` makes image processing in TypeScript applications highly accessible and efficient. Whether you need to resize, convert formats, or perform other image manipulations, `@push.rocks/smartjimp` provides a powerful yet simple API to accomplish these tasks with minimal effort. By abstracting away the complexities of direct interactions with libraries like `sharp` and `jimp`, it allows developers to focus more on building the core features of their applications. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.