{"id":23284150,"url":"https://github.com/kyr0/lightningimg-node","last_synced_at":"2026-02-11T22:13:41.094Z","repository":{"id":268768690,"uuid":"905337531","full_name":"kyr0/lightningimg-node","owner":"kyr0","description":"A transparent, fast and safe image converter for Node.js, written in Rust. Encodes PNG, JPG, TIFF to WebP","archived":false,"fork":false,"pushed_at":"2024-12-24T12:37:08.000Z","size":1289,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T14:45:42.101Z","etag":null,"topics":["converter","image","image-processing","jpg","nodejs","png","rust","tiff","webp"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyr0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-18T16:12:22.000Z","updated_at":"2024-12-24T12:37:12.000Z","dependencies_parsed_at":"2024-12-18T20:27:28.437Z","dependency_job_id":"55533ae8-a52e-4841-9ea5-5fd7763e6f71","html_url":"https://github.com/kyr0/lightningimg-node","commit_stats":null,"previous_names":["kyr0/lightningimg-node"],"tags_count":1,"template":false,"template_full_name":"napi-rs/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyr0%2Flightningimg-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyr0%2Flightningimg-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyr0%2Flightningimg-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyr0%2Flightningimg-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyr0","download_url":"https://codeload.github.com/kyr0/lightningimg-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238550156,"owners_count":19490840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","image","image-processing","jpg","nodejs","png","rust","tiff","webp"],"created_at":"2024-12-20T01:38:19.435Z","updated_at":"2026-02-11T22:13:41.052Z","avatar_url":"https://github.com/kyr0.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lightningimg-node\n\n\u003e Gone are the days when image conversion with Node.js was a hassle.\n\n## Install\n\n`npm install lightningimg-node`\n\n## API\n\nIt's super simple! Take a look at the [`./example`](./example/index.js) folder.\nPlease keep in mind to install `lightningimg-node` as a dependency in your project (see [`./example/package.json`](./example/package.json)).\n\n```js\nimport { processDirectoryDestructive, processDirectory, convertToWebp } from 'lightningimg-node'\n\n// Process all images in the test_images directory and save the output in the test_output directory\nprocessDirectory('./test_images', './test_output')\n\n// Overwrite the original images with the processed images, keeping the original image's file extensions\n// (this is only useful when working with bundlers for static site generators like Gatsby, Next.js, Astro, etc.)\nprocessDirectoryDestructive('./test_images', /* keep original file names */ true)\n\n// --- convert an image at runtime\n\n// read the image file into a buffer\nconst imageBuffer = readFileSync('test_data/defuss_logo_jpg.JPEG');\n\n// convert the image buffer to WebP format\nconst webpBuffer = convertToWebp(imageBuffer, 'jpeg', {\n  quality: 80, // example quality\n  dimensions: [400, 300], // resize to specific dimensions\n  maintain_aspect_ratio: false // no aspect ratio maintenance, set it to true to zoom in and center\n})\n\n// write the webpBuffer to a file named 'liveconvert.webp' in the 'test_output' directory\nwriteFileSync('test_output/liveconvert.webp', webpBuffer);\n```\n\n## Support matrix\n\n### Operating Systems\n\n|                  | node14 | node16 | node18 | node20 |\n| ---------------- | ------ | ------ | ------ | ------ |\n| Windows x64      | ✓      | ✓      | ✓      | ✓      |\n| Windows x32      | ✓      | ✓      | ✓      | ✓      |\n| Windows arm64    | ✓      | ✓      | ✓      | ✓      |\n| macOS x64        | ✓      | ✓      | ✓      | ✓      |\n| macOS arm64      | ✓      | ✓      | ✓      | ✓      |\n| Linux x64 gnu    | ✓      | ✓      | ✓      | ✓      |\n| Linux x64 musl   | ✓      | ✓      | ✓      | ✓      |\n| Linux arm gnu    | ✓      | ✓      | ✓      | ✓      |\n| Linux arm64 gnu  | ✓      | ✓      | ✓      | ✓      |\n| Linux arm64 musl | ✓      | ✓      | ✓      | ✓      |\n| Android arm64    | ✓      | ✓      | ✓      | ✓      |\n| Android armv7    | ✓      | ✓      | ✓      | ✓      |\n| FreeBSD x64      | ✓      | ✓      | ✓      | ✓      |\n\n## Contribute (for library developers)\n\n### Install\n\n- `yarn install`\n\n### Building\n\nAfter `yarn build/npm run build` command, you can see `lightningimg-node.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).\n\nDebug builds:\n\n- `yarn run build:debug`\n\nRelease builds:\n\n- `yarn run build`\n\n### Testing\n\nWith [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.\n\n### Benchmarking\n\n- `yarn run bench`\n\n### Linting\n\n- `yarn run lint`\n\n### CI\n\nWith GitHub Actions, each commit and pull request will be built and tested automatically in [`node@14`, `node@16`, `@node18`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.\n\n### Release\n\nRelease native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.\n\nWith `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.\n\nThe other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror).\n\nIn this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm.\n\n`NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details.\n\n### Development requirements\n\n- Install the latest `Rust`\n- Install `Node.js@10+` which fully supported `Node-API`\n- Install `yarn@1.x`\n\n### Test locally\n\n- yarn\n- yarn build\n- yarn test\n\nAnd you will see:\n\n```bash\n$ ava --verbose\n\n  ✔ sync function from native code\n  ✔ sleep function from native code (201ms)\n  ─\n\n  2 tests passed\n✨  Done in 1.12s.\n```\n\n### Release the package\n\n```\nyarn version 0.3.3 # just an example, change version!\ngit add .\ngit commit -m \"0.3.3\"\ngit push\n```\n\nGitHub Actions will do the rest for us.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyr0%2Flightningimg-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyr0%2Flightningimg-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyr0%2Flightningimg-node/lists"}