Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Splits an image

License

NotificationsYou must be signed in to change notification settings

achimoraites/image-splitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is it

split-images is a simple package that allows you to split an image to chunksthe chunks are returned as an Array (Array of buffers) of the image type provided.

Supported Images

Image paths, urls and buffers can be used, supported image types are jpeg, png, bmp, tiff and gif.

npm

npm i split-images --save

Node versions

Node >= 7.10

Methods

imageToChunks(image,chunkSize)

Splits the image horizontaly depending of the chunkSize

  • image can be a path, a url or a buffer
  • chunkSize the height in pixels each chunk will be

returnsArray<Buffer>

Examples

Read from a local file

const fs = require('fs');const { imageToChunks } = require('split-images');(async()=> {try {  const chunckSize = 1000;  const chuncks = await imageToChunks('imgs/test.png',chunckSize);  console.log('Number of chunks', chuncks.length);  let i = 0;  chuncks.forEach(c => {    i++;    fs.writeFileSync(`slice_${i}.png`,c);  });} catch (e) {  console.log(e);}})();

Read from a url

const fs = require('fs');const { imageToChunks } = require('split-images');(async()=> {try {  const chunckSize = 1000;  const chuncks = await imageToChunks('http://example.com/images/test.png',chunckSize);  console.log('Number of chunks', chuncks.length);  let i = 0;  chuncks.forEach(c => {    i++;    fs.writeFileSync(`slice_${i}.png`,c);  });} catch (e) {  console.log(e);}})();

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp