graphicsmagick

Need help understanding the ImageMagick/Graphicsmagick -colors option

孤街浪徒 提交于 2019-12-23 04:22:15
问题 I am trying to programmatically reduce (lossy) the file size of PNG and GIF files. As part of this I need to reduce the number of colors in the images. I don't want to reduce all the images to a single colors value, so what I am doing is; get the number of unique colors in the image, then; divide this number by 2 to reduce the number of colors by half. The problem is this does not work. Using ImageMagic it is way too slow and doesn't reduce the file size unless the image has under a few

gm stream stdout pipe throwing unhandled error

烂漫一生 提交于 2019-12-23 04:05:07
问题 I am trying to take an image url get the image then write it to the filesystem then resize it. At the end of the resizing I would like to return it back to the response so the client gets the image. Right now the stdout.pipe(res) is not returning and I get an events.js:72 error: throw er; // Unhandled 'error' event. Am I missing anything obvious? exports.getImage = function(req, res, next) { var fileId = Math.uuid(); var i = request.get(req.params.image).pipe(fs.createWriteStream(fileId)); i

Stitching images with append() in graphicsmagick

↘锁芯ラ 提交于 2019-12-23 02:36:55
问题 I have a large number of images stored on a separate server that needs to be displayed on a single page as a mosaic of some sort where the individual elements may be shown or hidden dynamically. These images should be fetched, resized and then stitched together as a sprite, and used as background images on divs. Fetching and resizing is a non-issue at this point, as the biggest hurdle is understanding the append method, or rather how to add images to a set, in order to use said method.

Pipe stream to graphicsmagick/imagemagick child process

南笙酒味 提交于 2019-12-20 10:21:01
问题 I am trying to pipe data from a stream into a child process. var gm = spawn( 'gm convert - -thumbnail 220x165^ -gravity center -extent 220x165 thumb.jpg' ); var rs = fs.createReadStream( 'cow.jpg' ); rs.pipe( gm.stdin ) Do I need to call end on gm for it to work? Also in my real code I am getting the stream from a database. 回答1: Example of how to stream a request into imagemagick: var image = request.get(req.params.url); var size = req.params.size.split('x'); var args = ['-', '-thumbnail',

Error “non-conforming drawing primitive” when trying to draw text or images with graphics magick

大憨熊 提交于 2019-12-20 03:23:30
问题 I am migrating a javascript program that internally uses image magick, to a Windows batch file using graphics magick. I cannot succesfully use the convert -draw command. I have a couple of very simple test cases.The first one is gm convert -size 1920x1080 xc:white -draw 'text 8,8 "Hello, world"' test.jpg fails with the error message "non-conforming drawing primitive (text)". The other gm convert -size 1920x1080 xc:white -draw 'image over 8,8 0,0 "img.jpg"' test.jpg fails with "non-conforming

Graphicsmagick not working in Elastic Beanstalk with nodejs and S3

我们两清 提交于 2019-12-19 09:42:33
问题 I'm using nodejs and graphicsmagick to process images with text, then streaming the final jpg to S3. Using postman, I was able to test this flow on my localhost and everything works fine. However, I'm having issues now that I moved it to Elastic Beanstalk. When I post to the endpoint, it uploads a blank file to S3 and there are no errors logged in EB. I think it has something to do with the software but am a bit stuck. Any advice appreciated! Thanks! Top file is from localhost, bottom file is

Graphicsmagick for node not writing the whole jpg

只愿长相守 提交于 2019-12-19 09:23:43
问题 I am using https://github.com/aheckmann/gm to resize an image. var fs = require('fs'); var gm = require('gm'); var input = __dirname + '/input.jpg'; var output = __dirname + '/output.jpg'; gm(input) .resize(350) .stream( function(err, stdout, stderr) { var writeStream = fs.createWriteStream( output, { encoding: 'base64' } ); var i = ''; stdout.on( 'data', function(data){ i += data.toString('base64'); }); stdout.on('end', function(){ writeStream.write( new Buffer(i, 'base64') ); writeStream

Asynchronous GraphicsMagick For Node

亡梦爱人 提交于 2019-12-18 09:11:48
问题 I am using GraphicsMagick for node. I basically crop the photos and retrieve the exif data of the photos uploaded by the user. I don't want to block the flow of request waiting for these task to be completed, therefore I need to use asynchronous functions to be able to do so. And I think I should be able to as these are I/O operations which node.js makes async itself. But as I see all the functions in GraphicsMagick for node are synchronous functions. So I am not being able to sure as to how

Skipper in SailsJS (beta) image resize before upload

瘦欲@ 提交于 2019-12-17 20:34:56
问题 I'm using SailsJS (beta). I'm trying to find a way to use graphicsmagick to take the stream parsed by Skipper in SailsJS-beta to resize the image before calling the Skipper-function req.file('inputName').upload() . My goal is to take my large, original image, and resize it before uploading it. Sails beta have introduced the Skipper-file-parser which are poorly documented (at least I don't understand it). Please help me understand how to resize the image before upload. This works (code in my

PDF: How to Optimize Filesize & Convert to PNG (embedded fonts problem)

别来无恙 提交于 2019-12-13 15:47:23
问题 I have a PDF with embedded fonts that I can't seem to work with. Right now, I'm using GhostScript and trying to do 2 things: Minimize filesize of PDF: gswin32c -dSAFER -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf Convert PDF to PNG (super sample, to be used for creating other thumbnails): gswin32c -dSAFER -dBATCH -dNOPAUSE -dQUIET -dFirstPage=1 -dLastPage=1 -r288 -sDEVICE=png16m -sOutputFile=output.pdf input.pdf The above works well when working on scanned