Skip to content

Replace gm with sharp lib #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Replace gm with sharp lib #2

wants to merge 1 commit into from

Conversation

oaleynik
Copy link

Replaces graphicsmagic with sharp library as it has native nodejs bindings, optimized for image resizing (benchmarks) and has promisified API. Follow sharp installation guidelines to install libvips - image processing library used under the hood

@oaleynik oaleynik changed the title feat(process-image) replace gm with sharp lib Replace gm with sharp lib Dec 27, 2014
@coolaj86
Copy link
Owner

This looks pretty cool.

Is GIF a supported output format?

@coolaj86
Copy link
Owner

The install process via brew is very slow though... it's been running for about 5 minutes now on my 2012 macbook pro.

Hopefully it's a bit faster on Ubuntu where there are some prebuilt binaries. Testing that next...

@oaleynik
Copy link
Author

@coolaj86 I have not been using it for gifs. But quick test throws Buffer contains an unsupported image format. JPEG, PNG, WebP and TIFF are currently supported.. So it seems like answer is no, but per sharp's readme:

It also supports reading images of many other types from the filesystem via libmagick++ or libgraphicsmagick++ if present.

So probably there are solutions for gifs. At least fallback to gm could be used

@coolaj86
Copy link
Owner

So it turns out that the preinstall script downloads hundreds of dependencies to compile libvips on Ubuntu. I've merged your changes into the "production" branch and I'll note that it's more performant in the master branch, but due to the overhead of dependencies (read: difficulty for the average user to install) I'm gonna keep gm in master for now.

I'm really excited that you updated the code, but one of the goals for this is that if someone already has node installed it should take them < 5 minutes to get it set up and that won't be the case with libvips as a dependency.

@coolaj86
Copy link
Owner

I also put it in npm as [email protected]

@oaleynik
Copy link
Author

Sharp has a thread of how to reduce the dependencies to install vips lovell/sharp#42
At the moment all proposed solutions are based on provision scripts for docker, heroku and other similar platforms. Probably there is a way to fetch precompiled vips version using homebrew instead of compiling from the source..

Anyway, if there will be any update or the way how to reduce time and simplify Sharp installation - I will let you know or will send new pull request.

@coolaj86
Copy link
Owner

Sounds good.

Here are the vids I made showing how to use it with the libvips:

Watch the Setup a Digital Ocean VPS ScreenCast on YouTube.

Watch the Ubuntu VPS ScreenCast on YouTube.

And the original:

Watch the OS X ScreenCast on YouTube.

@oaleynik
Copy link
Author

@coolaj86 thanks AJ, awesome vids!

Basing on Dockerfile for vips https://github.com/marcbachmann/dockerfile-libvips I've created Dockerfile for resize-as-a-service. It simplifies a bit installation process. For instance, on Digital Ocean instead of simple Ubuntu dropplet we can use build with Docker app (look into Applications section). Than run of sudo docker build -t <your username>/resize-as-a-service-vips . will prepare docker container with everything installed (it installs all dependencies, fetches resize-as-a-service-expample, installs npm packages and runs). Than we can just run sudo docker run -p 49160:3000 -d <your username>/resize-as-a-service-vips and service will be available at port 49160. Check it out https://gist.github.com/oaleynik/a6e8b787b3a6bdca7ad6 . I'm testing it at the moment so will be keeping you informed.

@oaleynik
Copy link
Author

@oaleynik
Copy link
Author

I've pushed docker image to docker hub.
So now all we need is create dropplet on Digital Ocean with Docker installed, login and run docker run -p 8080:3000 -t oaleynik/resize-as-a-service-vips. Service will be available on port 8080. Now it can be installed everywhere With just one command

P.S. it took about 5 minutes to get it running

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

Successfully merging this pull request may close these issues.

2 participants