graphicsmagick

Thumbnail the first page of a pdf from a stream in GraphicsMagick

独自空忆成欢 提交于 2019-12-08 05:47:15
问题 I know how to use GraphicsMagick to make a thumbnail of the first page of a pdf if I have a pdf file and am running gm locally. I can just do this: gm(pdfFileName + "[0]") .background("white") .flatten() .resize(200, 200) .write("output.jpg", (err, res) => { if (err) console.log(err); }); If I have a file called doc.pdf then passing doc.pdf[0] to gm works beautifully. But my problem is I am generating thumbnails on an AWS Lambda function, and the Lambda takes as input data streamed from a

How to convert selected pdf page with gm

两盒软妹~` 提交于 2019-12-08 04:07:32
问题 I am converting different images and pdf files with "gm" module for nodejs. Image types go successfully but when I want to convert PDF to image have problems. I need to covert only one selected page from pdf file to jpg/png. If I pass whole pdf file to "gm" it saves to image only first page, but I cannot find the way to save another page. gm(file).toBuffer(format.toUpperCase(), function (err, buffer) { // so in buffer now we have converted image } Thank you. 回答1: for only first pdf page use:

Thumbnail the first page of a pdf from a stream in GraphicsMagick

只愿长相守 提交于 2019-12-07 15:39:26
I know how to use GraphicsMagick to make a thumbnail of the first page of a pdf if I have a pdf file and am running gm locally. I can just do this: gm(pdfFileName + "[0]") .background("white") .flatten() .resize(200, 200) .write("output.jpg", (err, res) => { if (err) console.log(err); }); If I have a file called doc.pdf then passing doc.pdf[0] to gm works beautifully. But my problem is I am generating thumbnails on an AWS Lambda function, and the Lambda takes as input data streamed from a source S3 bucket. The relevant slice of my lambda looks like this: // Download the image from S3,

How to convert an image file from SVG to a multi-size ICO without blur (sharp)

社会主义新天地 提交于 2019-12-07 14:06:32
问题 I've been using ImageMagick, but it produces a very blurry result. convert -density 300 ../images/favicons/procensus.svg -background transparent -colors 256 -define icon:auto-resize favicon2.ico It seems to be rendering the image at 300 density, then resizing that with a Gaussian filter for all the other sizes in the icon. What I actually want it to do is re-render with shape-rendering="crispEdges" at each pixel size in the favicon. I want ImageMagick (or whatever other tool) to re-render the

How to convert selected pdf page with gm

◇◆丶佛笑我妖孽 提交于 2019-12-07 03:36:27
I am converting different images and pdf files with "gm" module for nodejs. Image types go successfully but when I want to convert PDF to image have problems. I need to covert only one selected page from pdf file to jpg/png. If I pass whole pdf file to "gm" it saves to image only first page, but I cannot find the way to save another page. gm(file).toBuffer(format.toUpperCase(), function (err, buffer) { // so in buffer now we have converted image } Thank you. for only first pdf page use: gm(file, 'pdf.pdf[0]').toBuffer(...) for only second pdf page use: gm(file, 'pdf.pdf[1]').toBuffer(...) gm

GraphicsMagick CgBI unknown critical chunk

帅比萌擦擦* 提交于 2019-12-07 01:21:31
问题 I am using GraphicsMagick and currently running into the following issue: when executing gm identify <filename>.png I'm getting the following error: gm identify: CgBI: unknown critical chunk (<filename>.png) gm identify: Request did not return an image. This is a png extracted from an iPhone. Though it may not contain an actual image, I do need the image info. Tried opening it with several editors: The png does open in Paint with the right height x width but as completely white. The png does

How can I extract the first frame of a GIF and save it as a PNG using GraphicsMagick on NodeJS?

本秂侑毒 提交于 2019-12-06 13:32:49
Here are the steps in which I want to do this: The user gives the server a link to an animated gif The server uses "request(url)" to retrieve the file The server generates a thumbnail of the gif's first frame The server uploads the thumbnail to Amazon S3 The problem exists in Step 3. I can't figure out a way to extract the gif's first frame. I would prefer to use GraphicsMagick but if there is another way you know of that works, I would be most grateful! NodeJS is being used. Lucio Mollinedo I don't know why this isn't in the documentation, but someone else answered this here on stackoverflow

how to pass image buffer data to gm in() GraphicsMagic

做~自己de王妃 提交于 2019-12-05 08:40:43
问题 var buf = require('fs').readFileSync('test.jpg'); gm().in('-page', '+0+0').in(buf,'test.jpg').write('output.jpg', function (err) { if (err) console.log(err); }) in this case i want to pass buffer data as input to the gm.in() method. Below is the link I'm referencing but in it, an image path is used as an input. I want to use buffer data as an input. How can I do this? Tile four images together using Node.js and GraphicsMagick 回答1: Without modifying the source of GraphicsMagick itself, you can

How to resize image only if width exceeds with Graphics/Image Magick

痴心易碎 提交于 2019-12-05 02:41:24
问题 As seen here: http://www.imagemagick.org/Usage/resize/#shrink the option: -resize 64x64> only resizes if width and height exceeds 64 px. But how about to do something like that if works: -resize 64>x or -resize 64x'ignores'> in other words if only width exceeds this size. Is this possible? 回答1: You can easily achieve that by using an 'unlikely large' height value: convert orig.png -resize '64x10000>' scaled.png This will resize the original PNG only if its width was larger than 64 pixels or

Resize and crop image and keeping aspect ratio NodeJS & gm

梦想与她 提交于 2019-12-04 07:46:17
问题 I've been trying to create some thumbnails using the gm package from NodeJS, but I'm out of lucky. I need to resize images bigger than 600x600 (could be any width/height, starting from the given one) but when I pass the size to gm, it creates an image that doesn't have the same size I requested. For example, given this code, I assume that running node app /path/to/image.png I'll receive an image with size of 200x100, but instead I got, say, an image of 180x100 or 200x90... gm(fileLocation)