Giter Club home page Giter Club logo

imagemagick-stream's People

Contributors

artur-krueger avatar awenger avatar choas avatar eivindfjeldstad avatar greenkeeper[bot] avatar timsuchanek avatar varunnayal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

imagemagick-stream's Issues

Annotating

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?

Resize + crop

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

Stream 'end' event sometimes not emitted

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:

  • Starting with stream from an HTTP request (specifically, an uploaded file from multiparty component)
  • This stream is piped into 4 streams:
    • "A" - used for parsing EXIF information out of an uploaded image, not with imagemagick
    • "B" - passed to AWS SDK as-is for upload to S3
    • "C" - used for image resizing. It is piped into imagemagick-stream, and the result is further piped into "C1" and "C2". Then, "C1" is used to get the resulting byte size (I just count the total chunk.length on C1.'data' events), and when I get C1.'end' I use the C2 stream to upload to S3 (because unfortunately, S3 requires up-front knowledge of the file size being uploaded)
    • "D" - used for image resizing, exaclty as "C" but with a different image size (also piped to imagemagick-stream, then to D1/D2, etc)

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?

Cannot read property 'prototype' of undefined

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?

+profile "*"

how to avoid the warning:"convert: invalid profile length"?

No way to log the final command

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

pipe breaks?

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.

screen shot 2015-12-01 at 13 13 24

Can't issue "+" options?

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?

Cannot create a canvas

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

errnoException

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)

Support for converting pdf to png

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!

code=ENOENT, errno=ENOENT, syscall=spawn convert, path=convert, spawnargs=[-, -resize, 40x40, -]

@eivindfjeldstad

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?

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .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.

More information on this issue

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 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Error: convert.im6

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.