customink/ruby-vips-lambda

How to use with NodeJS?

NhatAnh opened this issue · 6 comments

Hi,
I know this is lambda layer for Ruby, but it looks like it can be used for other runtimes also? The problem is I'm not sure how to invoke libvips: Do I use command line? I tried with "vips" command but it is not found.
Thanks!

Hey there! Usage for other Runtimes highly depends on how you want to use Libvips. This layer is technically meant for Ruby's ruby-vips gem (https://github.com/libvips/ruby-vips) which uses FFI which allows Ruby to execute Libvips C code directly from Ruby. If you are curious, I did a beginner guide to Lambda with Libvips and Ruby here to see how that works.

https://dev.to/aws-heroes/aws-lambda-microservice-workshop-using-s3-libvips-ruby-4o96

So if your language and more important package/gem etc can use the shared objects in this layer then yes, it should work for other runtimes. But as you noticed, there is no binary in this layer. Just shared objects. If you are interested in that, perhaps use Yumda? https://github.com/lambci/yumda

OH! If you want libvips with Node... I highly recommend using Sharp. You don't have to worry about layers at all, the Sharp package takes care of that for you. Check out their project. https://github.com/lovell/sharp

Thanks! The problem I have with Sharp is it does not retain the ICC profile of the image (lovell/sharp#1323). That's why I'm trying to use libvips directly. I'll look into yumda, or maybe just write the Lambda with Ruby.
Thanks again!

OH! Love to hear the Ruby usage :) BTW, you should have a working Lambda using Libvips and Ruby 2.7 using that workshop link I posted above in like 30m or so too. Have fun! I'd be interested in hearing how things go.

Will this work with golang?

Will this work with golang?

It depends on how golang builds its own package and/or links to Libvips. That said, this whole project is kind of defunct for a few reasons. First, the base image that we build from lambci/lambda:build-ruby2.7 is moot since AWS has their own Lambda images to pull from ECR using via public.ecr.aws/sam/build-${lang}${version} for the SAM/Build image and public.ecr.aws/lambda/${lang}:${version} for the Runtime. These images would be a stronger fit on what is actually used in production and can be linked or needed to be installed. Secondly, this project was written prior to Lambda Containers being a thing. So doing some yum installs of needed software and shipping a container is far far easier to get things working both for local development and production deploys.

Hope that helps. Closing this issue.