Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick.
Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick.
npm install pdf-image
Ensure you have convert
, gs
, and pdfinfo
(part of poppler) commands.
sudo apt-get install imagemagick ghostscript poppler-utils
brew install imagemagick ghostscript poppler
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage("/tmp/slide.pdf");
pdfImage.convertPage(0).then(function (imagePath) {
// 0-th page (first page) of the slide.pdf is available as slide-0.png
fs.existsSync("/tmp/slide-0.png") // => true
});
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage("/tmp/slide.pdf");
pdfImage.convertFile().then(function (imagePaths) {
// [ /tmp/slide-0.png, /tmp/slide-1.png ]
});
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage("/tmp/slide.pdf", {
combinedImage: true
});
pdfImage.convertFile().then(function (imagePaths) {
// /tmp/slide.png
});
Following example shows an example of pdf-image in Express, which gives
URLs for each pages of a PDF like
http://example.com:3000/tmp/slide.pdf/0.png
.
app.get(/(.*\.pdf)\/([0-9]+).png$/i, function (req, res) {
var pdfPath = req.params[0];
var pageNumber = req.params[1];
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage(pdfPath);
pdfImage.convertPage(pageNumber).then(function (imagePath) {
res.sendFile(imagePath);
}, function (err) {
res.send(err, 500);
});
});
Following example shows an example of how to add imagemagick command-line options (you can find the complete list here -> http://www.imagemagick.org/script/convert.php):
var pdfImage = new PDFImage(pdfPath, {
convertOptions: {
"-resize": "2000x2000",
"-quality": "75"
}
});
FAQs
Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick.
The npm package pdf-image receives a total of 3,733 weekly downloads. As such, pdf-image popularity was classified as popular.
We found that pdf-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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.