
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
resize-canvas
Advanced tools
change dimensions of an html5 canvas element, resizing from a relative position on canvas (center by default) and preserving image data
Change dimensions of an html5 canvas element, resizing from a relative position on canvas (center by default) and preserving image data
Similar to how you can change resolution of an image in photoshop, but with granular control of the from position. Adjust with an absolute new size or a relative change. This new version resizes the canvas in place instead of returning you a new canvas with the different size. To get a new canvas, supply a copy of the original.
Download node at nodejs.org and install it, if you haven't already.
npm install resize-canvas --save
import resizeCanvas from 'resize-canvas'
let canvas = document.createElement('canvas')
// set height and width
canvas.width = 300
canvas.height = 200
// add to dom
document.body.appendChild(canvas)
// draw a circle
let ctx = canvas.getContext('2d')
ctx.beginPath()
ctx.arc(150, 100, 50, 0, 2 * Math.PI)
ctx.stroke()
// change size from [300, 200] to [300, 250] from center
resizeCanvas({
canvas: canvas,
size: [100, 50] // absolute size adjustment
})
// or by size difference adding to the top and left sides
resizeCanvas({
canvas: canvas,
diff: [-50, 150], // relative size adjustment
from: [canvas.width, canvas.height] // from bottom right
})
canvas.width // 50
canvas.height // 200
resizeCanvas( { canvas, diff, size, from } )
Arguments
ISC
FAQs
change dimensions of an html5 canvas element, resizing from a relative position on canvas (center by default) and preserving image data
The npm package resize-canvas receives a total of 13 weekly downloads. As such, resize-canvas popularity was classified as not popular.
We found that resize-canvas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.