Skip to content
/ cutImg Public

A minimalist javascript library for immutably cutting images into smaller rectangular sections

Notifications You must be signed in to change notification settings

Quoteme/cutImg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

cutImg.js

A minimalist javascript library for cutting images into smaller rectangular sections / copying them

Command Effect
cut(img, x, y, width, height) returns a cut version of the previous image
split(img, tileWidth, tileHeight) returns a tilemap of the image based on the tilesize entered
join(a,b,x,y) join two images together (2nd image is offset by x and y)
mirror(img, x,y) mirror an image along one or two specified axes (if x or y = true)

as a module module

	// this file must be loaded as a module:
	// <script src="path/to/cutImg.mjs" type="module"></script>
	import * as CUTIMG from 'lib/cutImg/cutImg.mjs';

	originalImage = new Image();
	originalImage.src = "url/to/image.png";
	newImage = CUTIMG.cut(originalImage, 100, 200, 450, 600);

as a script

<head>
	<!-- [...] -->
	<script src="path/to/cutImg.js"></script>
	<!-- [...] -->
</head>
originalImage = new Image();
originalImage.src = "url/to/image.png";

newImage = cutImg(originalImage, 100, 200, 450, 600);

original image cut image

About

A minimalist javascript library for immutably cutting images into smaller rectangular sections

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published