
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dom-copy-image
Advanced tools
npm install --save dom-copy-image
<!DOCTYPE html>
<html>
<head>
<title>dom copy!</title>
</head>
<body>
<button>Copy Image</button>
<button id="make-thumb">Make thumbnail</button>
<p></p>
<script>
var copyImage = require('dom-copy-image'),
path = require('path');
document.querySelector('button').addEventListener('click', function(e){
copyImage('original.jpg', 'new.png').then(function(data){
console.log(data.file+' was copied.');
document.querySelector('p').innerHTML = data.file+' was copied.';
});
});
document.querySelector('#make-thumb').addEventListener('click', function(e){
//Make a small image copy
copyImage('original.jpg', 'thumb.png', {width: 100}).then(function(data){
var img = document.createElement('img');
img.src = 'thumb.png';
document.querySelector('body').appendChild(img);
});
});
</script>
</body>
</html>
The destination, and options arguments are optional.
value.file = String;
value.dataURL = String;
value.destination = String;
Sets the output dimensions. These should be integers in pixels. Only one needs to be set.
The default is true. Should the output preserve it's dimension ratio?
The default is image/png. What image type should the output be?
An integer between 0, and 1. What quality should the output image have?
This module only works in a client DOM environment that can use node/iojs modules. For instance it will work well with electron.
It can copy images, but if you don't specify a destination you can just use it as a resize function getting back a dataURL from the resolved promise to use as a img tag src.
FAQs
Copy an image file in a DOM environment
We found that dom-copy-image 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.