B
B
Boogie19892016-07-29 18:37:46
JavaScript
Boogie1989, 2016-07-29 18:37:46

How to cut an image using JS?

I have an AngularJS application. Do I need to cut the picture into 9 or 16 equal parts and put them in an array? Plus, you need the ability to rotate the resulting pieces. Preferably without jQuery. How can I do that?
I have coordinates for drawing a piece of the picture

_stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, xPos, yPos, _pieceWidth, _pieceHeight);

but I don’t need to draw, but I need to turn it into dataUrl so that this piece can be inserted into the tag like a normal src.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Minisol, 2016-07-29
@AmadeyMinisol

www.html5canvastutorials.com/tutorials/html5-canva... - here is an example
and the image can then be put into a blob

X
Xbbv1, 2016-07-29
@Xbbv1

Maybe you can somehow decode to base64 and cut it .. I think you can’t do without canvas. There is a discussion here stackoverflow.com/questions/6150289/how-to-convert...

M
Man from Kazakhstan, 2016-07-29
@LenovoId

codepen.io/Geyan/pen/EypkPZ like this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question