Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created File After Convert #1

Open
nspangler opened this issue Oct 29, 2013 · 7 comments
Open

Created File After Convert #1

nspangler opened this issue Oct 29, 2013 · 7 comments

Comments

@nspangler
Copy link

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.

@sylvaingi
Copy link
Owner

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.

@nspangler
Copy link
Author

@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]);

@sylvaingi
Copy link
Owner

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?

@nspangler
Copy link
Author

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

@sylvaingi
Copy link
Owner

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.

@nspangler
Copy link
Author

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.

@stefanocudini
Copy link

@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!
#4

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants