eivindfjeldstad / imagemagick-stream Goto Github PK
View Code? Open in Web Editor NEWStreaming Imagemagick API
License: MIT License
Streaming Imagemagick API
License: MIT License
If we use a bigger input file, by the time the 'finish' event is emitted the output file is still emtpy.
I've changed the tests to check for file size > 0 and added a bigger test image. Please have a look:
With that change all 3 test fail.
I added im().set('annotate', '+0+20 "text'")
. But it says
Error: convert: invalid argument for option
-annotate': +0+20 "text"`
how do we do this?
Also does adding higher density while streaming work?
Hi, sorry to bother you
but what's the syntax to resize + crop an image ?
I want to do like:
easyimg.rescrop({
src:'kitten.jpg', dst:'./output/kitten-thumbnail.jpg',
width:500,//
cropwidth:128, cropheight:128,
x:0, y:0
}).then(
function(image) {
console.log('Resized and cropped: ' + image.width + ' x ' + image.height);
},
function (err) {
console.log(err);
}
);
Thanks in advance.
var resize =im().resize('200x200').gravity('Center').crop('50x150').quality(90);
the code is executed without errors but than in the browser
I get
The image cannot be displayed because it contains errors
I'm using hapi and also with this code
var name = data.file.hapi.filename;
var ext = Path.extname(name);
var thumb = Math.random().toString(36).slice(2);
var path = Config.uploadsPath + '/' + thumb + ext;
var resize = Im().resize('150x150').quality(90);
var file = Fs.createWriteStream(path);
file.on('error', function (err) {
return reply(Boom.badImplementation(err));
});
data.file.pipe(resize).pipe(file);
data.file.on('end', function (err) {
var res = {
filename: data.file.hapi.filename,
thumb: thumb + ext,
headers: data.file.hapi.headers
}
reply(res);
})
I get that error
so I'm wondering If I do something wrong
I ran into a case when I'm not getting an 'end' event from the stream returned from imagemagick-stream. Unfortunately, I don't have a small repro, but my setup is something like this:
In this setup, for large enough images, everything works fine except that I never get the D1.'end' event (even though I get C1.'end')! It's not 100% reproducible but pretty close to it.
It seems that imagemagick-stream is not emitting the 'end' event for some reason. I added the following code to ImageMagick.prototype.spawn and this fixes the issue:
var self=this;
proc.on('close', function() {
self.emit('end');
});
See https://github.com/eugeneos/imagemagick-stream/blob/FixStreamEndBug/index.js
If this is an ok fix, I'd be happy to open a pull request. Or perhaps I'm doing something wrong?
I receive this error when using the code in the README.md
/node_modules/imagemagick-stream/index.js:19
proto: Duplex.prototype,
^
TypeError: Cannot read property 'prototype' of undefined
at Object. (/home/sigi/Dev/resize-poc/node_modules/imagemagick-stream/index.js:19:20)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/home/sigi/Dev/resize-poc/app.js:1:72)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
Which stream module are you using here require('stream').Duplex?
how to avoid the warning:"convert: invalid profile length"?
I believe u meant npm install imagemagick-stream :)
It would be great to have an option to return a string showing what the actual command that will be run against imagemagick is.
Trying different .set() .op() calls etc. etc. doesn't allow me to see what the actual command line options are that will be passed on.
Steve
I have a weird issue which I assume has something to do with imagemagick-stream (correct me if I am wrong). When converting multiple images it looks like the pipe breaks. The images are resized but are cut. I assume this has something to do with an over load on a stream (either imagemagick or fs). I am using node-gallery which uses this npm module.
The code that initiates the write stream can be found here:
https://github.com/cianclarke/node-gallery/blob/master/lib/middleware.js
I would be grateful for any pointers on how to debug or somebody who have had similar issues.
I'm trying to do a crop, followed by a rotate, followed by another crop. However, for the last crop to work, I need a "+repage" right before it. I can't see any way to do this, as both "set" and "op" insert a "-" and nothing I can see inserts a "+" before the command.
Is there some other way I can get it to work?
Currently the library has no way to create a canvas.
For example ...
The command
'convert -size 64x64 canvas:lightblue ./images/thumb.png'
will create a lightblue canvas from the command line. However there is no way to pass in the canvas:lightblue option to this library as both the op() and set() prefix the keys with '-'
Steve
working on gm v2, and it basically has the same API. hadn't had time to work on it lately though, especially since i just use execFile
in my own stuff. do you want admin access?
https://github.com/jonathanong/gm2
from what i remember last time, i had issues with the child process stuff. raw commands worked in https://github.com/stream-utils/duplex-child-process but didn't in gm2 for whatever reason
Well, I think it is a bug in nodejs
child_process.js:935
throw errnoException(process._errno, 'spawn');
^
Error: spawn EMFILE
at errnoException (child_process.js:988:11)
at ChildProcess.spawn (child_process.js:935:11)
at exports.spawn (child_process.js:723:9)
at ImageMagick.spawn (/.........../node_modules/imagemagick-stream/index.js:230:14)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Hi @eivindfjeldstad ,
Does imagemagick-stream support converting PDFs to images?
I wrote a test for the same :
const im = require('imagemagick-stream');
const fs = require('fs');
const read = fs.createReadStream(__dirname + '/pdfs/samplePdf.pdf');
const write = fs.createWriteStream(__dirname + '/pdfs/image-resized.png');
const resize = im();
read.pipe(resize).pipe(write);
Unfortunately I got this error:
events.js:141
throw er; // Unhandled 'error' event
^
Error: convert: no decode delegate for this image format ' @ error/constitute.c/ReadImage/508. convert: no images defined
-' @ error/convert.c/ConvertImageCommand/3235.
at ImageMagick.onerror (/srv/package/node_modules/imagemagick-stream/index.js:273:31)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at Pipe.onread (net.js:523:20)
I tried to use convert which got installed as part of imagemagick through cli and I could successfully convert it.
Any ideas?
Thanks!
I download file from S3 and try to resize and got this error:
code=ENOENT, errno=ENOENT, syscall=spawn convert, path=convert, spawnargs=[-, -resize, 40x40, -]
2016-11-16T22:03:20.958Z - error: uncaughtException: dest.end is not a function
Here is my code:
var read = Streamifier.createReadStream(result.Body);
var resize = im().resize(self.width.toString() + 'x' + self.height.toString());
var write = new stream();
write.writable = true;
read.pipe(resize).pipe(write);
Do you know what is wrong here?
I am sometimes starting with a buffer of image data (from a blob in a database). At the moment I'm turning this into a stream with https://github.com/samcday/node-stream-buffer but I have a feeling this may be inefficient. Perhaps I'm wrong, but if I'm not it'd be nice to be able to supply a buffer.
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Well...whats is this?
events.js:72
throw er; // Unhandled 'error' event
^
Error: convert.im6: Too many IDAT's found `/tmp/magick-U-0S9kiM' @ error/png.c/MagickPNGErrorHandler/1728
at ReaDuplexer.ImageMagick.onerror (/home/pol/Work/node_modules/imagemagick-stream/index.js:241:30)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at Pipe.onread (net.js:526:21)
Do you have any plans to mitigate this vulnerability?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.