Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
save-html-as-image-enhanced
Advanced tools
This can be used for a couple of things, it can save HTML (DOM) as an image (JPG,PNG) and it can convert SVG images to PNG. Converting SVG to PNG is useful for Safari Browser compatibility since it cannot render SVG images.
saveAsPng(NODE_ELEMENT, USER_OPTIONS, DOM_OPTIONS);
saveAsJpeg(NODE_ELEMENT, USER_OPTIONS, DOM_OPTIONS);
import { saveAsPng, saveAsJpeg } from 'save-html-as-image';
const node = document.getElementById('elementId');
//download the node as png. Image (2019-12-01).png
saveAsPng(node);
//download the node as png. Report (2019-12-01).png
saveAsPng(node, { filename: 'Report', printDate: true });
//download the node as jpeg. Album.jpeg
saveAsJpeg(node, { filename: 'Album', printDate: false });
//download the node as jpeg. Album50.jpeg (With 50% of quality)
saveAsJpeg(node,
{ filename: 'Album50', printDate: false },
{ quality: 0.5 }
);
//download the node as png and Add padding and center element
saveAsPng(
node,
{ filename: 'Report', printDate: true },
{
backgroundColor: 'rgba(101,198,185,0.5)',
style: {
padding: '4px',
display: 'flex',
justifyContent: 'center',
},
}
);
The options are:
Modify the DOM and IMAGE to download.
The options available are:
You can hide elements adding the class "hide-when-downloading".
Hide elements apply display: hidden
to the elements with this class;
<section>
<article>One..</article>
<article class="hide-when-downloading">Two...</article>
</section>
saveAsPng(node, { filename: 'News', printDate: true });
//Only the first article will be visible on the image
Note: The class "hide-when-downloading" must be on root element, That we want hide.
You can remove elements adding the class "remove-when-downloading".
Remove Elements apply display: none
to the elements. So the space into the element will remove.
You can show elements by adding the class "show-when-downloading".
Show elements apply display: inherit
to the elements with this class;
It's tested on the lasted Chrome (Chrome 76), Firefox and Safari.
We resolve the Safari support with a litte hack and replace svg with image. It's tested with FontAwesomeIcons svgs.
We use a collection of packages to generate and donwnload images, all in one action. The packages are:
FAQs
Save the html as image like png or jpg
The npm package save-html-as-image-enhanced receives a total of 7 weekly downloads. As such, save-html-as-image-enhanced popularity was classified as not popular.
We found that save-html-as-image-enhanced 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.