Code Monkey home page Code Monkey logo

node-images's Introduction

images logo

Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Node.js
Node.js轻量级跨平台图像编解码库

var images = require("images");

images("input.jpg")                     //Load image from file 
                                        //加载图像文件
    .size(400)                          //Geometric scaling the image to 400 pixels width
                                        //等比缩放图像到400像素宽
    .draw(images("logo.png"), 10, 10)   //Drawn logo at coordinates (10,10)
                                        //在(10,10)处绘制Logo
    .save("output.jpg", {               //Save the image to a file, with the quality of 50
        quality : 50                    //保存图片到文件,图片质量为50
    });

Support 支持情况

if node >= 10.x, please install images@latest

Platform Architecture Node Version
Windows x64 8, 9, 10, 11, 12
OSX X64 8, 9, 10, 11, 12
Linux* x64 8, 9, 10, 11, 12
  • The 32-bit system is not supported for the time being.

if node <= 9.x, please install [email protected]

Platform Architecture Node Version
Windows x86 & x64 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 10
OSX X64 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 9, 10
Linux* x86 & x64 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 10

Features 功能特性

  • Lightweight: no need to install any image processing library.
  • 轻量级:无需安装任何图像处理库。
  • Cross-platform: Released a compiled .node file on windows, just download and start.
  • 跨平台:Windows下发布了编译好的.node文件,下载就能用。
  • Easy-to-use: Provide jQuery-like chaining API. Simple and reliable!
  • 方便用:jQuery风格的API,简单可依赖。

Installation 安装

$ npm install images

API 接口

node-images provide jQuery-like Chaining API,You can start the chain like this:
node-images 提供了类似jQuery的链式调用API,您可以这样开始:

/* Load and decode image from file */
/* 从指定文件加载并解码图像 */
images(file)

/* Create a new transparent image */
/* 创建一个指定宽高的透明图像 */
images(width, height)

/* Load and decode image from a buffer */
/* 从Buffer数据中解码图像 */
images(buffer[, start[, end]])

/* Copy from another image */
/* 从另一个图像中复制区域来创建图像 */
images(image[, x, y, width, height])

images(file)

Load and decode image from file
从指定文件加载并解码图像

images(width, height)

Create a new transparent image
创建一个指定宽高的透明图像

images(buffer[, start[, end]])

Load and decode image from a buffer
从Buffer数据中解码图像

images(image[, x, y, width, height])

Copy from another image
从另一个图像中复制区域来创建图像

.fill(red, green, blue[, alpha])

eg:images(200, 100).fill(0xff, 0x00, 0x00, 0.5) Fill image with color
以指定颜色填充图像

.draw(image, x, y)

Draw image on the current image position( x , y )
在当前图像( x , y )上绘制 image 图像

.encode(type[, config])

eg:images("input.png").encode("jpg", {operation:50}) Encode image to buffer, config is image setting.
以指定格式编码当前图像到Buffer,config为图片设置,目前支持设置JPG图像质量
Return buffer
返回填充好的Buffer
Note:The operation will cut off the chain
注意:该操作将会切断调用链
See:.save(file[, type[, config]]) 参考:.save(file[, type[, config]])

.save(file[, type[, config]])

eg:images("input.png").encode("output.jpg", {operation:50}) Encoding and save the current image to a file, if the type is not specified, type well be automatically determined according to the file, config is image setting. eg: { operation:50 }
编码并保存当前图像到 file ,如果type未指定,则根据 file 自动判断文件类型,config为图片设置,目前支持设置JPG图像质量

.size([width[, height]])

Get size of the image or set the size of the image,if the height is not specified, then scaling based on the current width and height
获取或者设置图像宽高,如果height未指定,则根据当前宽高等比缩放

.resize(width[, height])

Set the size of the image,if the height is not specified, then scaling based on the current width and height
设置图像宽高,如果height未指定,则根据当前宽高等比缩放, 默认采用 bicubic 算法。

.width([width])

Get width for the image or set width of the image
获取或设置图像宽度

.height([height])

Get height for the image or set height of the image
获取或设置图像高度

images.setLimit(width, height)

Set the limit size of each image
设置库处理图片的大小限制,设置后对所有新的操作生效(如果超限则抛出异常)

images.setGCThreshold(value)

Set the garbage collection threshold
设置图像处理库自动gc的阈值(当新增内存使用超过该阈值时,执行垃圾回收)

images.getUsedMemory()

Get used memory (in bytes)
得到图像处理库占用的内存大小(单位为字节)

images.gc()

Forced garbage collection
强制调用V8的垃圾回收机制

node-images's People

Contributors

2betop avatar funky81 avatar hemstreet avatar inu1255 avatar kong-lau avatar oxund avatar tc-imba avatar wshxbqq avatar zhangyuanwei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-images's Issues

处理超过30000像素的图片的时候,报告了一个错误

/home/weihj/node_modules/images/index.js:45
return this._handle.toBuffer(type, config);
^
Error: ../src/Image.cc:380 Encode fail.
at WrappedImage.prototype.encode (/home/weihj/node_modules/images/index.js:45:29)
at WrappedImage. (/home/weihj/node_modules/images/index.js:89:34)
at WrappedImage.prototype.save (/home/weihj/node_modules/images/index.js:52:37)
at WrappedImage.save (/home/weihj/node_modules/images/index.js:89:34)
at DeepZoom.DumpImages (/home/weihj/DeepZoom.js:235:47)
at /home/weihj/node_modules/async/lib/async.js:249:17
at replenish (/home/weihj/node_modules/async/lib/async.js:194:21)
at /home/weihj/node_modules/async/lib/async.js:206:33
at /home/weihj/node_modules/async/lib/async.js:251:21
at DeepZoom.DumpImages (/home/weihj/DeepZoom.js:236:9)

save或encode为 gif 时出错

F:\ABen鏂囦欢\project\node-ab-ccss\demo\node_modules\node-ab-ccss\node_modules\i
mages\index.js:45
        return this._handle.toBuffer(type, config);
                            ^
Error: ..\src\Image.cc:380 Encode fail.
    at WrappedImage.prototype.encode (F:\ABen鏂囦欢\project\node-ab-ccss\demo\no
de_modules\node-ab-ccss\node_modules\images\index.js:45:29)
    at WrappedImage.<anonymous> (F:\ABen鏂囦欢\project\node-ab-ccss\demo\node_mo
dules\node-ab-ccss\node_modules\images\index.js:89:34)
    at WrappedImage.prototype.save (F:\ABen鏂囦欢\project\node-ab-ccss\demo\node
_modules\node-ab-ccss\node_modules\images\index.js:52:37)
    at WrappedImage.save (F:\ABen鏂囦欢\project\node-ab-ccss\demo\node_modules\n
ode-ab-ccss\node_modules\images\index.js:89:34)
    at deal4Img (F:\ABen鏂囦欢\project\node-ab-ccss\demo\node_modules\node-ab-cc
ss\abc-mod-deal4Img.js:186:17)
    at process.<anonymous> (F:\ABen鏂囦欢\project\node-ab-ccss\demo\node_modules
\node-ab-ccss\index.js:137:17)
    at process.EventEmitter.emit (events.js:117:20)
    at handleMessage (child_process.js:318:10)
    at Pipe.channel.onread (child_process.js:345:11)

暂时测试到在 window 7 下,将 jpg、png 混合生成 gif 时,出现 encode 错误,请问如何解决

Using ubuntu server 15.04 with binding.node

Hi,

Can someone help with this.
wen using popcorntv i have this error wen open a movie

Debug: === Generating Fanart ===
Debug: === Getting Fanart ===
Debug: https://api-v2launch.trakt.tv/movies/tt0470752?extended=images
Debug: https://walter.trakt.us/images/movies/000/163/375/fanarts/original/5db1e19703.jpg
/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:21
    this._handle = new _Image(width, height);
                   ^
TypeError: undefined is not a function
    at new WrappedImage (/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:21:20)
    at WrappedImage (/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:14:49)
    at Function.images.loadFromBuffer (/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:167:12)
    at Function.images.loadFromFile (/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:159:19)
    at images (/home/balves/popcorn/PopcornTV-master/node_modules/images/index.js:127:24)
    at WriteStream.<anonymous> (/home/balves/popcorn/PopcornTV-master/fanartGenerator.js:27:25)
    at WriteStream.emit (events.js:129:20)
    at finishMaybe (_stream_writable.js:484:14)
    at afterWrite (_stream_writable.js:362:3)
    at onwrite (_stream_writable.js:352:7)

Mac OS X

[562] > npm install
npm WARN package.json [email protected] No README.md file found!
npm http GET https://registry.npmjs.org/images
npm http 200 https://registry.npmjs.org/images
npm http GET https://registry.npmjs.org/images/-/images-1.1.3.tgz
npm http 200 https://registry.npmjs.org/images/-/images-1.1.3.tgz

[email protected] install /Users/akhoury/code/img2pdf/node_modules/images
node install.js

CXX(target) Release/obj.target/images/src/Image.o
make: c++: No such file or directory
make: *** [Release/obj.target/images/src/Image.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:786:12)
gyp ERR! System Darwin 12.3.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/akhoury/code/img2pdf/node_modules/images
gyp ERR! node -v v0.10.3
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok
npm ERR! [email protected] install: node install.js
npm ERR! sh "-c" "node install.js" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the images package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls images
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/akhoury/code/img2pdf
npm ERR! node -v v0.10.3
npm ERR! npm -v 1.2.17
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/akhoury/code/img2pdf/npm-debug.log
npm ERR! not ok code 0

Forking and Credit?

Hello there! I absolutely love your project, it is amazing and works flawlessly. While building my desktop application I ended up needing some bindings for nwjs. I forked the repository, added my bindings, and then re-published it here: https://github.com/PopcornTV/node-images and here: https://www.npmjs.com/package/ptv-images

I saw that your License (MIT) was only in the package.json file, and as such I wanted to reach out to you to see if this was ok for me to do. If it is not then I will gladly make some pull requests and close down my branch. I just know that my users will need quite a few bindings and because of that, I felt that I could maintain my branch.

Is the statement that I added to the top of the readme enough to give proper credit back to you? Is there something else that I can do?

Let me know!

Thanks.

ubuntu12.04安装失败

需要哪些包?有版本限制?看其他issue说需要giflib等包,这些包搜不到啊

nodejs 0.12.0 不能直接用

我的ubuntu服务器安装的是0.12.0的nodejs,直接使用node-images启动不了,找不到.node文件。我也试过在ubuntu编译源码,错误太多过不了,请问能不能提供一个0.12.0的编译好的.node文件,或者告诉我怎么在ubuntu编译,谢谢

uncaughtException: Can't load the addon.

I started getting the following error:

{"level":"error","message":"on uncaughtException: Can't load the addon. please try to run `node install.js` command.,\n\nError: Can't load the addon. please try to run `node install.js` command.\n    at Object.<anonymous> (D:\\home\\site\\wwwroot\\node_modules\\images\\binding.js:4:11)\n    at Module._compile (module.js:460:26)\n    at Object.Module._extensions..js (module.js:478:10)\n    at Module.load (module.js:355:32)\n    at Function.Module._load (module.js:310:12)\n    at Module.require (module.js:365:17)\n    at require (module.js:384:17)\n    at Object.<anonymous> (D:\\home\\site\\wwwroot\\node_modules\\images\\index.js:4:15)\n    at Module._compile (module.js:460:26)\n    at Object.Module._extensions..js (module.js:478:10)","timestamp":"2015-02-15T09:54:39.208Z"}

.size()方法报错:Image uninitialized

Hello,你好,十分感谢你提供了一个如此简单易用的图像处理包。我在使用Images时遇到了如下问题:.size()方法报错:Image uninitialized,不知道你能否给出一个比较好的解决办法,谢谢。

  • 我的代码如下:
var images = require('images');
var targetFileName = 'image.jpg';
var img = images(targetFilename);

var w = img.width();
var h = img.height();

img.size(215, 215);
  • 我遇到的问题:
  1. 当我保存图片时就会报错;
  2. 当我把代码改成下面这样(其实就是调换了一下三行代码的位置),就不报错了;
img.size(215, 215);

var w = img.width();
var h = img.height();

请问width()或height()在size()之前为什么会报错呢?

期待你的回复,谢谢~

electron 中报错

var img = require('images')
var image = '/path/to.jpg'
console.log(img(image).size())

/Users/tcdona/electron/electron.app/Contents/Resources/textcraft/node_modules/images/binding.js:47 Uncaught Error: Can't load the addon. Issue to: https://github.com/zhangyuanwei/node-images/issues

mac osx 10.10

编译安装的方法

最近发现很多 Linux glibc 由于内核不同 glibc 版本匹配有误,导致已经提供的二进制包加载不起来,如果遇到此种情况,可以按照以下的方法进行编译安装;

编译方法

  $ git clone https://github.com/zhangyuanwei/node-images
  $ cd node-images
  $ git submodule init
  $ git submodule update
  $ cd gyp
  $ sh third-party.sh
  $ cd ..
  $ npm install
  $ node-gyp rebuild

大概四个步骤

  • Clone 代码,包括主代码和依赖gyp
  • 执行 sh third-party.sh 来下载 gyp 用到的所有的源码包,可能会由于墙之类的下载会比较吃力,请自备梯子。另外需要 cmake 请安装它 sudo apt-get install cmake
  • 安装 nannpm install
  • 编译, node-gyp rebuild;可能你没有 node-gyp 请安装它 npm install -g node-gyp

Errors when trying to build bindings

I'm trying to build the bindings from scratch (specifically because i'd like to use node-images in an NW.js project and I need to compile a version for io.js instead of node.js). I'm running into this error when i try to run 'node-gyp build' :

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/libjpeg-turbo/gyp/third-party/libjpeg-turbo/bmp.o
In file included from ../gyp/third-party/libjpeg-turbo/bmp.c:33:
In file included from ../gyp/third-party/libjpeg-turbo/cdjpeg.h:17:
../gyp/third-party/libjpeg-turbo/jpeglib.h:67:9: error: unknown type name 'JSAMPLE'
typedef JSAMPLE JSAMPROW; / ptr to one image row of pixel samples. /
^
../gyp/third-party/libjpeg-turbo/jpeglib.h:656:3: error: unknown type name 'JSAMPLE'
JSAMPLE * sample_range_limit; /
table for fast range-limiting /
^
../gyp/third-party/libjpeg-turbo/bmp.c:128:2: error: use of undeclared identifier 'JPEG_LIB_VERSION'
jpeg_create_compress(&cinfo);
^
../gyp/third-party/libjpeg-turbo/jpeglib.h:899:34: note: expanded from macro 'jpeg_create_compress'
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION,
^
../gyp/third-party/libjpeg-turbo/bmp.c:168:17: warning: incompatible pointer types passing 'JSAMPROW' (aka 'int *') to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
pixelconvert(src->buffer[i], srcpf, 0, outbuf, dstpf, bottomup, *w,
^~~~~~~~~~~~~~
../gyp/third-party/libjpeg-turbo/bmp.c:75:41: note: passing argument to parameter 'srcbuf' here
static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
^
../gyp/third-party/libjpeg-turbo/bmp.c:212:2: error: use of undeclared identifier 'JPEG_LIB_VERSION'
jpeg_create_decompress(&dinfo);
^
../gyp/third-party/libjpeg-turbo/jpeglib.h:902:36: note: expanded from macro 'jpeg_create_decompress'
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION,
^
../gyp/third-party/libjpeg-turbo/bmp.c:256:41: warning: incompatible pointer types passing 'JSAMPROW' (aka 'int *') to parameter of type 'unsigned char *' [-Wincompatible-pointer-types]
pixelconvert(inbuf, srcpf, bottomup, dst->buffer[i], dstpf, 0, w,
^~~~~~~~~~~~~~
../gyp/third-party/libjpeg-turbo/bmp.c:76:17: note: passing argument to parameter 'dstbuf' here
unsigned char *dstbuf, int dstpf, int dstbottomup, int w, int h)
^
2 warnings and 4 errors generated.
make: *
* [Release/obj.target/libjpeg-turbo/gyp/third-party/libjpeg-turbo/bmp.o] Error 1

Note: I've tried running it with node-gyp and nw-gyp just to be sure it's not because of nw-gyp.
Have you ever encountered this sort of error when trying to compile libjpeg-turbo?
I'm trying to compile this for OSX v10.10.3 x64 if that helps

是否能添加一个将图片保存为png8格式的功能

我是一前端工程师,经常需要将一些png24图片通过tinypng.com压缩为png8以减少图片体积,找了好久也没有找到类似的功能,是否可以提供一个?我现在没有好的吧办法只能写一个程序调用那个网站的功能区压缩,但这样太慢了。

centos5.9安装失败

execvp(): No such file or directory

events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)

git clone 后 node install.js 报错

内存无法释放

我使用这个模块,把我的图片都加上尺寸,发现跑了2000多张图片的时候内存暴涨,而且save之后也没发释放。请问有什么办法?

var im = images(path);
var fr = fs.readFileSync(path);
var picSize = im.size().width + "*" + im.size().height;
var fileSize = fr.length;
im = null;
fr = null;

[Window 7 Nodejs 4.1.1 64 Bit] Error: Can't load the addon

"C:\Program Files (x86)\JetBrains\PhpStorm 9.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" app.js
c:\ImageManipulationWeb_Nodejs\node_modules\images\binding.js:55
                throw new Error('Can\'t load the addon. Issue to: ' + bugUrl + ' ' + e.stack);
                ^

Error: Can't load the addon. Issue to: https://github.com/zhangyuanwei/node-images/issues Error: %1 is not a valid Win32 application.
c:\ImageManipulationWeb_Nodejs\node_modules\images\bindings\win32\x64\4.0.0\binding.node
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> 
..........

When I try to run on 64bit nodejs environment, the exception will be thrown. But It is able to run on 32bit nodejs environment.

怎么获取一个远程图片

images(http://d.hiphotos.baidu.com/image/pic/item/58ee3d6d55fbb2fb50264c994d4a20a44623dc2f.jpg)

这么写会出现异常,如下:

fs.js:427
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'http://d.hiphotos.baidu.com/image/pic/item/58ee3d6d55fbb2fb50264c994d4a20a44623dc2f.jpg'
    at Object.fs.openSync (fs.js:427:18)
    at Object.fs.readFileSync (fs.js:284:15)

Beyond the pixel size limit.

使用的时候报超出图片尺寸限制,不知道为什么?
其实我的图片大小才372*661,但是其实图片已经保存成功了~

[15:58:39] Error: ../src/Image.cc:412 Beyond the pixel size limit.
at WrappedImage.prototype.loadFromBuffer (/Users/windy/application/tianma/node_modules/auto-sprites/node_modules/node-images/index.js:18:22)
at WrappedImage.aliases.(anonymous function).forEach.target.(anonymous function) as loadFromBuffer
at Function.images.loadFromBuffer (/Users/windy/application/tianma/node_modules/auto-sprites/node_modules/node-images/index.js:153:27)
at Function.images.loadFromFile (/Users/windy/application/tianma/node_modules/auto-sprites/node_modules/node-images/index.js:145:19)

Unknow format error

Error: ../src/Image.cc:268 Unknow format
at WrappedImage.prototype.loadFromBuffer (/Users/aleksej/PhpstormProjects/node-socket-test/node_modules/images/index.js:18:22)
at WrappedImage.loadFromBuffer (/Users/aleksej/PhpstormProjects/node-socket-test/node_modules/images/index.js:89:34)
at Function.images.loadFromBuffer (/Users/aleksej/PhpstormProjects/node-socket-test/node_modules/images/index.js:159:27)
at Function.images.loadFromFile (/Users/aleksej/PhpstormProjects/node-socket-test/node_modules/images/index.js:151:19)
at images (/Users/aleksej/PhpstormProjects/node-socket-test/node_modules/images/index.js:119:24)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface. (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)

Throws at
var images = require('images')
images(PATH_TO_WORKING_JPEG_I_TRIED_MANY_OF_THEM)

Wtf?

giflib's `DGifOpen` updated to take an `Error` parameter

../src/Gif.cc: In function ‘ImageState decodeGif(PixelArray*, ImageData*)’:
../src/Gif.cc:82:51: error: too few arguments to function ‘GifFileType* DGifOpen(void*, InputFunc, int*)’
  if((gif = DGifOpen((void *) input, ReadFromMemory)) == NULL) goto RETURN;
                                                   ^
In file included from ../src/Gif.cc:11:0:
/usr/include/gif_lib.h:181:14: note: declared here
 GifFileType *DGifOpen(void *userPtr, InputFunc readFunc, int *Error);    /* new one (TVT) */
              ^

The DGifOpen function provided by giflib now takes a third int * parameter called Error. To get the old behaviour, pass in NULL for this parameter (see this commit to Enlightenment.)

(Sorry, I don't know chinese.)

我在ubuntu上面安装出现这个问题,10.04和12.04同样的问题。。请指教。。

gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.5.0-39-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/lonso/node_modules/images
gyp ERR! node -v v0.10.18
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

关于跨平台的问题

是否在本机编译完成后,用户机不用再编译就能使用?
用户机不需要安装xcode和gyp之类端?

win7 64 安装失败

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
以下为日志:

D:\imagestest>npm install images
npm http GET https://registry.npmjs.org/images
npm http 304 https://registry.npmjs.org/images

[email protected] install D:\imagestest\node_modules\images
node install.js

events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)
npm ERR! [email protected] install: node install.js
npm ERR! cmd "/c" "node install.js" failed with 8
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the images package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls images
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "images"
npm ERR! cwd D:\imagestest
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! D:\imagestest\npm-debug.log
npm ERR! not ok code 0

D:\imagestest>

Add webp support

This would be really great. Netflix is using it and I'd like to be able to do it in node also

描述冲突

Features 功能特性
Lightweight:no need to install any image processing library.
•轻量级:无需安装任何图像处理库。

Installation 安装$ npm install images
You will also need to install:
•giflib 4.x.x
•libpng 1.5.x
•jpeg-turbo 1.x.x

第一次使用,报如下错误:Can\'t load the addon

安装的话就使用了npm install images。
其他安装包
giflib 4.x.x
libpng 1.5.x
jpeg-turbo 1.x.x
自己手动编译安装。。。

/node_modules/images/binding.js:55
throw new Error('Can't load the addon. Issue to: ' + bugUrl +
^
Error: Can't load the addon. Issue to: https://github.com/zhangyuanwei/node-images/issues Error: Cannot find module './bindings/linux/ia32/0.12.0/binding.node'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/home/yangqw/spider/zhihuspider/node_modules/images/binding.js:52:34)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at Object. (/home/yangqw/spider/zhihuspider/node_modules/images/binding.js:55:23)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/home/yangqw/spider/zhihuspider/node_modules/images/index.js:4:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
error: Forever detected script exited with code: 1

图片缩放报错

..\src\Image.cc:173 Invalid argumentsArguments error

undefined

//原图
var image = images(path.join('public/upload_temp', paths[0]));
var saveTo = path.resolve(path.join('public/thumbs', path_name));
//试过好几次, 仅宽度报错, 宽度高度也报错, 源码里有个filter, 也不知道是什么类型的, 试了下字符串, 数字, 都报错...
var thumb = image.resize(w, h);

thumb.save(saveTo);

Linux下安装不上

  CXX(target) Release/obj.target/images/src/Png.o
../src/Png.cc: In function ‘ImageState decodePng(PixelArray*, ImageData*)’:
../src/Png.cc:94:18: error: ‘png_const_bytep’ was not declared in this scope
make: *** [Release/obj.target/images/src/Png.o] Error 1
make: Leaving directory `/home/travis/build/ijse/FED/node_modules/images/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/travis/.nvm/v0.8.22/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:256:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Linux 2.6.32-042stab061.2
gyp ERR! command "node" "/home/travis/.nvm/v0.8.22/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/travis/build/ijse/FED/node_modules/images
gyp ERR! node -v v0.8.22
gyp ERR! node-gyp -v v0.8.5
gyp ERR! not ok 
npm ERR! [email protected] install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the images package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls images
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-042stab061.2
npm ERR! command "/home/travis/.nvm/v0.8.22/bin/node" "/home/travis/.nvm/v0.8.22/bin/npm" "install"
npm ERR! cwd /home/travis/build/ijse/FED
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/travis/build/ijse/FED/npm-debug.log
npm ERR! not ok code 0
The command "npm install" failed and exited with 1 during install.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.