Skip to content

Instantly share code, notes, and snippets.

View wswebcreation's full-sized avatar
🤣
SaaS (Selles as a Service)

Wim Selles wswebcreation

🤣
SaaS (Selles as a Service)
View GitHub Profile
@Zyndoras
Zyndoras / rotate.js
Last active April 29, 2024 11:41
Rotate base64 image (Javascript)
function rotate(srcBase64, degrees, callback) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const image = new Image();
image.onload = function () {
canvas.width = degrees % 180 === 0 ? image.width : image.height;
canvas.height = degrees % 180 === 0 ? image.height : image.width;
ctx.translate(canvas.width / 2, canvas.height / 2);