Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Asynchronous GraphicsMagick For Node

Asynchronous GraphicsMagick For Node

Problem

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 to achieve what I am looking for.

One idea that comes to my mind is to write a function with callback and have the GraphicsMagick processing done inside it. And use .nextTick() function to achieve asynchronous flow. But I am not totally sure if this is fine. And also are there any asynchronous functions for GraphicsMagick.

Please help me and an example code would be very appreciated as to how to get asynchronous functions from graphicsmagick.

Problem courtesy of: Saransh Mohapatra

Solution

Sorry my observation was mistaken, though the GraphicsMagick module seems as synchronous function but they are not. They spawn child process each time manipulation is done. And this has been confirmed here.

So anyone else looking for this problem, GraphicsMagick functions are Asynchronous. And you don't have to do anything from your part. Its a very good module and worth checking out.

Thanks.

Solution courtesy of: Saransh Mohapatra

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Asynchronous GraphicsMagick For Node

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×