Comments (5)
Hello @jonathan-kosgei,
Your example should work, though shouldn't it be require('vips')
? I think vips-ffi
might be a different project.
I see:
#!/usr/bin/env node
'use strict';
var vips = require('vips');
var image = vips.Image.newFromFile(process.argv[2]);
image = image.shrink(50, 50);
image.writeToFile(process.argv[3]);
Then:
$ vipsheader ~/pics/wtc.jpg
/home/john/pics/wtc.jpg: 9372x9372 uchar, 3 bands, srgb, jpegload
$ time ./shrink.js ~/pics/wtc.jpg x.png
real 0m2.500s
user 0m2.994s
sys 0m0.619s
$ vipsheader x.png
x.png: 187x187 uchar, 3 bands, srgb, pngload
That's rather a slow way to shrink an image though. You'll find thumbnail
is a lot quicker:
var image = vips.Image.thumbnail(process.argv[2], 187);
image.writeToFile(process.argv[3]);
Gives:
$ time ./shrink.js ~/pics/wtc.jpg x.png
real 0m0.807s
user 0m0.807s
sys 0m0.025s
There are some examples here:
https://github.com/jcupitt/node-vips/tree/master/example
from node-vips.
Oh duh, you're right, it is vips-ffi
.
from node-vips.
Thanks! That worked well and was much faster. Is there a function that takes the height as well?
from node-vips.
Sure, thumbnail
has loads of options:
http://jcupitt.github.io/libvips/API/current/libvips-resample.html#vips-thumbnail
from node-vips.
Thanks!
from node-vips.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-vips.