meteor-imagemagick icon indicating copy to clipboard operation
meteor-imagemagick copied to clipboard

Created File After Convert

Open nspangler opened this issue 11 years ago • 7 comments

I'm really enjoying meteor-imagemagick. It is very useful in my image processing meteor application. However I am having a trouble using the Imagemagick.convert command. In my application I read in a file from a url then after the image is processed I need to save it. I have been using meteor-imagemagick along side collectionFS (https://github.com/CollectionFS/Meteor-CollectionFS). The Imagemagick.resize and .crop have been working perfectly for me. However I want to use the convert -brightness-contrast feature that imagemagick offers to brighten up a dark photo. I use the command as proposed in the readme from inside a collectionFS filehandler. My code:

var image = "http://localhost:3000/cfs/contacts/sQnQPyGLfez2tY498_default1.jpg"; Imagemagick.convert([image, '-brightness-contrast', '+50', 'image-bright.jpg']);

However I don't understand where the file is being stored once being manipulated by imagemagick. Maybe it's not being saved? Thanks for the help.

nspangler avatar Oct 29 '13 16:10 nspangler

The thing is that this package just calls the imagemagick executable on your machine, it can only work with actual files on the filesystem. So using an URL is not correct. (even though I will take a look at why there's no error thrown)

My advice would be to save your image to a temp folder, then processing it with Imagemagick.

sylvaingi avatar Oct 31 '13 14:10 sylvaingi

@sylvaingi thanks for the quick response. It makes sense that using an URL is incorrect. I have decided to save the image in my meteor public folder then use the convert command on it. I can access the image saved in the public directory like:

var image = ../../../../../public/mac.png Imagemagick.identify([image]);

nspangler avatar Oct 31 '13 16:10 nspangler

Be careful with the file path of the public/ folder, I think it is not consistent whether you are in development or production (meteor deploy or bundle). Otherwise, is your issue solved?

sylvaingi avatar Oct 31 '13 18:10 sylvaingi

The problem is resolved locally. However where is the public/folder path in the deployed meteor project path?

nspangler avatar Nov 06 '13 16:11 nspangler

I think it is something like programs/client/app/, but I am not sure it is a best practice to reference this directory.

You shoud consider using the Assets API: http://docs.meteor.com/#assets Basically it gives you access on the server to files stored in the private folder. You could just grab your image data, write it to a temp file and then using imagemagick.

sylvaingi avatar Nov 06 '13 18:11 sylvaingi

Thanks for all the help, I will look into using and implementing assests.

After investigation I have found this excerpt from the meteor documentation: "Meteor gathers any files under the private subdirectory and makes the contents of these files available to server code via the Assets API. The private subdirectory is the place for any files that should be accessible to server code but not served to the client, like private data files."

Since I want to have these images accessible to the client, I cannot use the Assests API. So I guess I will stick with the public folder.

nspangler avatar Nov 06 '13 23:11 nspangler

@nspangler Unfortunately, writing in the public folder will cause the reboot of meteor! (also in production) I solved it by writing to a directory outside of the Meteor and then serving the file using external http server.

but now is tunerd out another problem with imagemagick crop function! https://github.com/sylvaingi/meteor-imagemagick/issues/4

I don't understand how I can debug it! :-(

stefanocudini avatar Jul 19 '14 20:07 stefanocudini