-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Using Imagemagick in Cloud Code #648
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
Comments
@christianmarth Thanks! E.g. in the first link example (EasyImage), how would you initialize an image from the response.buffer like I do in line 8 of my pasted code? |
@oyvindvol I wrote a wrapper for Parse.Image that has 100% compatibility with the original parse-image: https://github.com/flovilmart/parse-image. |
I was just getting to the point where I needed this too. Thanks @flovilmart ! |
@nitrag @oyvindvol the installation is automated on debian and OSX. Installation in Windows is not working yet. For heroku, you need to add a build pack (as explained in the README) |
@flovilmart Nice! So, to use this on a heroku based install of parse-server, i just add imagemagick , graphicsmagick and your parse-image to my package.json, and add |
@oyvindvol follow the instructions here: https://github.com/flovilmart/parse-image#heroku-installation then:
Given the code you provided, it seems that it should work right away. |
@flovilmart Ok, so now I did only the "Heroku installation" part, and after deploy the heroku logs say "Cannot find module 'parse-image'". Then I added 'parse-image' as a dependency in package.json, and I still get "cannot find module 'parse-image'" in the logs. |
Did you run |
@flovilmart On Heroku server? |
does it work locally with foreman? |
I haven`t tested locally, I am just trying to set it up on my parse-server-example that I deployed directly to Heroku. I configured the heroku-buildpack-graphicsmagick via git bash, and push to heroku master. I can see that the buildpack is installed, but am I also supposed to put something in my package.json for it to work in my cloud code? |
the build pack is installing the binaries required to parse-image to work correctly. |
Ok, starting from fresh. I added the buildpack in git bash. I remove everything regarding parse-image from my package.json, then i do
After deploy finished, this is the heroku logs:
|
it seems that your package.json is not properly updated, or that heroku don't like it..
Try to run on your machine: |
After adding parse-image to my package.json the module is found. But now I get this error:
|
Ok, thanks a lot so far @flovilmart! I tried console.logging the url to my uploaded ParseFile,
|
Is your response.buffer set? |
Yes |
Uhm... that's very very odd indeed. Did you try on you local machine, see if it's heroku related or something else? |
You should probably open an issue on parse-image instead of there. Closing for now. |
Well, initially this issue was about using the recommended Imagemagick in parse server cloud code. I am still interested in examples on that though.. |
OK, can you post an issue on parse-image I'll re-open in that case. |
I used jimp to replace |
@simonbengtsson That looks lightweight and good. Are you using jimp to e.g. save thumbnails via cloud code? I am having trouble getting that work. With the code provided below, everything seems OK, and the thumb is saved on the "Message" object, but viewing the thumb in the browser with the file URL is not working.
|
Yes we are generating thumbnails in cloud code using jimp. Your issue is probably that the string from return new Parse.Promise((resolve, reject) => {
image.resize(100, 100).getBuffer(Jimp.MIME_JPEG, (err, buffer) => {
if (err) return reject(err);
var file = new Parse.File('picture.jpg', {base64: buffer});
resolve(file.save());
});
}); |
@simonbengtsson Thanks! :) That worked.. |
Since it took me several hours to get this correct I'm posting here so the next guy has an easier time:
|
Thanks for sharing this pure js image module, here is the benchmarks I found for jimp in comparison with other libraries. It seems enough for common image processing cases. |
@flovilmart I tried your parse-image module on Heroku for a simple thumbnail generation. I did not need to change a single line of code, only added "parse-image": "~0.1.1" in my package.json dependencies, and it works fine so far. Great job! |
@nitrag Thanks for your post. Fwiw, I had to add a buffer.toString conversion before I could get everything to work.
|
This all seems to be working great for me using jimp until the part where I try to set it to the object in the beforeSave hook. I see the images showing up in S3 and it comes back correctly. I have other attributes that are getting set correctly as well. It is just the 'pictureThumbnail' that isn't. For some reason it just seems as if it's not updating the request.object. @rickkrauland Was there something you had to do different then what is documented in @nitrag 's example?
|
So... turns out that response.success doesn't want a string sent along with it. I removed "thumbnail saved" from response.success() and it worked. |
Hi,
This is not really an issue with Parse-Server, rather a cry for help with using Imagemagick instead of Parse-Image in my cloud code functions. Can anyone point me in the right direction to achieve the same as expressed in my old cloud code:
Any help will be much appreciated!
The text was updated successfully, but these errors were encountered: