{"id":21525306,"url":"https://github.com/superraytin/image-to-slices","last_synced_at":"2025-11-01T06:03:49.490Z","repository":{"id":45697036,"uuid":"48537752","full_name":"superRaytin/image-to-slices","owner":"superRaytin","description":"Node.js module for converting image into slices with the given reference lines.","archived":false,"fork":false,"pushed_at":"2021-01-18T12:02:19.000Z","size":378,"stargazers_count":34,"open_issues_count":5,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-10T09:32:10.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/superRaytin.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}},"created_at":"2015-12-24T10:13:21.000Z","updated_at":"2025-07-03T15:13:54.000Z","dependencies_parsed_at":"2022-08-30T17:11:14.487Z","dependency_job_id":null,"html_url":"https://github.com/superRaytin/image-to-slices","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/superRaytin/image-to-slices","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fimage-to-slices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fimage-to-slices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fimage-to-slices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fimage-to-slices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/superRaytin","download_url":"https://codeload.github.com/superRaytin/image-to-slices/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fimage-to-slices/sbom","scorecard":{"id":859275,"data":{"date":"2025-08-11","repo":{"name":"github.com/superRaytin/image-to-slices","commit":"199394a820c3da9b298c67c474067025a56cb6cf"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T00:46:39.009Z","repository_id":45697036,"created_at":"2025-08-24T00:46:39.009Z","updated_at":"2025-08-24T00:46:39.009Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278518898,"owners_count":26000177,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-24T01:34:24.823Z","updated_at":"2025-10-05T20:56:32.571Z","avatar_url":"https://github.com/superRaytin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp style=\"text-align: center\"\u003e\n    \u003cimg src=\"example/images/demonstrate.png\" width=\"880\" alt=\"image-to-slices\"\u003e\n\u003c/p\u003e\n\n# image-to-slices\n\u003e Node.js module for converting image into slices with the given reference lines. Backed by [Slices](https://github.com/superRaytin/slices) and [image-clipper](https://github.com/superRaytin/image-clipper).\n\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![Bower version][bower-image]][bower-url]\n[![Build Status](https://travis-ci.org/superRaytin/image-to-slices.svg?branch=master)](https://travis-ci.org/superRaytin/image-to-slices)\n\n[![image-to-slices](https://nodei.co/npm/image-to-slices.png)](https://npmjs.org/package/image-to-slices)\n\n[npm-url]: https://npmjs.org/package/image-to-slices\n[downloads-image]: http://img.shields.io/npm/dm/image-to-slices.svg\n[npm-image]: http://img.shields.io/npm/v/image-to-slices.svg\n[bower-url]:http://badge.fury.io/bo/image-to-slices\n[bower-image]: https://badge.fury.io/bo/image-to-slices.svg\n\n# Installation\n\n### Node.js\n\n```\nnpm install image-to-slices\n```\n\n\u003e Since the server-side Node.js doesn't natively support Canvas, you'll need previously install [Cairo](http://cairographics.org/) which is depended by [node-canvas](https://github.com/Automattic/node-canvas), see [node-canvas#Installation](https://github.com/Automattic/node-canvas#installation) for detail.\n\n```\nnpm install canvas\n```\n\n### Bower\n\n```\nbower install image-to-slices\n```\n\n# Quick Start\n\n```js\nvar imageToSlices = require('image-to-slices');\n\nvar lineXArray = [100, 200];\nvar lineYArray = [100, 200];\nvar source = '/path/to/image.jpg'; // width: 300, height: 300\n\nimageToSlices(source, lineXArray, lineYArray, {\n    saveToDir: '/path/to/'\n}, function() {\n    console.log('the source image has been sliced into 9 sections!');\n});\n```\n\n## Client-side (browser)\n\nSimply download the latest minified version from the `dist/` folder. All APIs are available in a global object called `imageToSlices`.\n\n```html\n\u003cscript src=\"./dist/image-to-slices.js\"\u003e\u003c/script\u003e\n```\n\n```js\nvar imageToSlices = window.imageToSlices;\nimageToSlices(source, lineXArray, lineYArray, {\n    saveToDataUrl: true\n}, function(dataUrlList) {\n    console.log('sliced', dataUrlList);\n});\n```\n\nYou can also use `image-to-slices` via AMD or CMD.\n\n## Command Line Interface\n\n```\nUsage: image-to-slices [options]\n\nOptions:\n\n-h, --help                             output usage information\n-v, --version                          output the version number\n-s, --source \u003csource file\u003e             the path where the source image file\n-x, --lineX \u003cx1,x2,...\u003e                reference lines of the X axis\n-y, --lineY \u003cy1,y2,...\u003e                reference lines of the Y axis\n-m, --middleBoundaryMode \u003ctrue|false\u003e  enable middle boundary mode. Default is false\n-o, --output \u003coutput directory\u003e        the directory where the image slices will be saved. Default is the current working directory of the process\n```\n\nBelow is an example:\n\n```\n$ image-to-slices -s ./example/images/building.png -x 20,100 -y 100 -o ./example/\n```\n\n\u003e Note that the CLI usage require node-canvas.\n\n# Example\n\nOnline example: [http://superraytin.github.io/image-to-slices/](http://superraytin.github.io/image-to-slices/)\n\n# API\n\n```js\nvar imageToSlices = require('image-to-slices');\n```\n\n### imageToSlices(source, lineXArray, lineYArray [, options], callback)\n\n- **source:** the path where the source image. Keep in mind that [origin policies](https://en.wikipedia.org/wiki/Same-origin_policy) apply to the image source, and you may not use cross-domain images without [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing).\n- **lineXArray:** reference lines of the X axis\n- **lineYArray:** reference lines of the Y axis\n- **options:** slice with some optional parameters, see [options](#options) for detail.\n- **callback:** a function to be executed when slicing is complete.\n\n### imageToSlices.configure(options)\n\nConfigure properties for global, properties changed by the `imageToSlices.configure` method will take effect for every instance created after the change.\n\n```js\nvar imageToSlices = require('image-to-slices');\nimageToSlices.configure({\n    clipperOptions: {\n        canvas: require('canvas')\n    }\n});\n```\n\nSee [Options](#options) for available properties.\n\n## Options\n\n### saveToDir\n\nThe directory path where the image slices will be saved.\n\n\u003e Note that the path must be really exists.\n\n### middleBoundaryMode\n\nEither true or false, default is false.\n\nIf set to true, this will put spaces between each two X axis as parent-block,\nthe areas between the first Y axis and last Y axis will be children of the parent-block, and it will generate boundary data.\n\nSee [Slices#middleBoundaryMode](https://github.com/superRaytin/slices#middleboundarymode) for detail.\n\n### clipperOptions\n\nConfiguration properties for the [image-clipper](https://github.com/superRaytin/image-clipper).\n\nSee [image-clipper#configure-options](https://github.com/superRaytin/image-clipper#clipperconfigureoptions) for available properties.\n\n### saveToDataUrl\n\nYou should use either `saveToDir: true` or `saveToDataUrl: true`, default is false.\n\nIf set to true, then it will doesn't save the image slices as file but rather return data URI of the slices, and callback will be passed the result data URI.\n\nBelow is an example:\n\n```js\nImageToSlices('path/to/image.jpg', [100], [100], {\n  saveToDataUrl: true\n}, function(dataUrlList) {\n  console.log('sliced!', dataUrlList);\n});\n```\n\nThe `dataUrlList` returned will be like below:\n\n```js\n[\n    { width: 100, height: 100, x: 0, y: 0, dataURI: 'data:image/jpeg;base64,....' },\n    { width: 400, height: 100, x: 100, y: 0, dataURI: 'data:image/jpeg;base64,....' },\n    { width: 100, height: 400, x: 0, y: 100, dataURI: 'data:image/jpeg;base64,....' },\n    { width: 400, height: 400, x: 100, y: 100, dataURI: 'data:image/jpeg;base64,....' }\n]\n```\n\nBelow is another example which `middleBoundaryMode` is set to true:\n\n```js\nImageToSlices('path/to/image.jpg', [100, 300], [100, 200, 300], {\n  saveToDataUrl: true,\n  middleBoundaryMode: true\n}, function(dataUrlList) {\n  console.log('sliced!', dataUrlList);\n});\n```\n\nAnd the `dataUrlList` returned will be like below:\n\n```js\n[\n    {\n        \"width\": 500,\n        \"height\": 100,\n        \"x\": 0,\n        \"y\": 0,\n        dataURI: 'data:image/jpeg;base64,....',\n        \"children\": [\n            {\n                \"width\": 100,\n                \"height\": 100,\n                \"x\": 100,\n                \"y\": 0,\n                \"left\": 0,\n                \"top\": 0,\n                \"parentBlockIndex\": 0,\n                \"index\": 0,\n                dataURI: 'data:image/jpeg;base64,....',\n            },\n            {\n                \"width\": 100,\n                \"height\": 100,\n                \"x\": 200,\n                \"y\": 0,\n                \"left\": 100,\n                \"top\": 0,\n                \"parentBlockIndex\": 0,\n                \"index\": 1,\n                dataURI: 'data:image/jpeg;base64,....',\n            }\n        ],\n        \"boundary\": {\n            \"leftTop\": {\n                \"x\": 100,\n                \"y\": 0\n            },\n            \"rightBottom\": {\n                \"x\": 300,\n                \"y\": 100\n            }\n        }\n    },\n    ...\n]\n```\n\n## Where is this library used?\n\nIf you are using this library in one of your projects, add it in this list :)\n\n- [Puzzler](https://github.com/superRaytin/puzzler)\n\n# Testing\n\n```\nnpm test\n```\n\n# License\n\nMIT, see the [LICENSE](/LICENSE) file for detail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperraytin%2Fimage-to-slices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperraytin%2Fimage-to-slices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperraytin%2Fimage-to-slices/lists"}