我应该在Node.JS上使用哪个库进行服务器端图像处理? [英] Which library should I use for server-side image manipulation on Node.JS?

查看:79
本文介绍了我应该在Node.JS上使用哪个库进行服务器端图像处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Node上找到了一个非常大型可用库列表。 JS wiki但我不确定哪些更成熟并提供更好的性能。基本上我想做以下事情:

I found a quite large list of available libraries on Node.JS wiki but I'm not sure which of those are more mature and provide better performance. Basically I want to do the following:


  1. 从外部来源将一些图像加载到服务器

  2. 将它们放在一个大画布上

  3. 裁剪并掩盖它们

  4. 应用一个或两个过滤器

  5. 调整最终图像的大小并给出一个链接

  1. load some images to a server from external sources
  2. put them onto one big canvas
  3. crop and mask them a bit
  4. apply a filter or two
  5. Resize the final image and give a link to it

如果节点包同时适用于Linux 和Windows

Big plus if the node package works on both Linux and Windows.

推荐答案

回答我自己的问题

我花了两天时间挖掘Node.js图形库。

I spent two days digging through Node.js graphics libraries.

node-canvas


  • 我先尝试过,因为我'我非常熟悉< canvas> API。这对图书馆来说是一个巨大的优势。

  • 它需要Cairo,它没有简单的Windows下载。我发现它在GTK +发行版中。

  • 此外它需要在模块安装时编译本机库绑定代码。它使用的Node-Waf尚未移植到Windows。

  • I tried it first since I'm quite familiar with <canvas> API. It's a huge plus for a library.
  • it requires Cairo which doesn't have an easy Windows download. I found it in GTK+ distribution though.
  • moreover it needs native library binding code to be compiled on module installation. It uses Node-Waf which hasn't being ported to Windows yet.

gm


  • 成熟

  • 顺利在Windows上运行

  • docs ok 但不彻底:我不得不查看源代码以找出API可用

  • 遗憾的是,没有简单的方法将图像与gm结合起来。也许有一些方法可以达到这个目的,但我花了两个小时才发现它。

  • mature
  • runs on Windows smoothly
  • docs are ok but not thorough: I had to look up into source code to figure out what API is available
  • unfortunately there's no easy way to combine images with gm. Maybe there's some way to achieve that but I haven't found one after two hours spent with it.

node-imagemagick


  • 官方回购包含的基本ImageMagick命令很少,但我使用了这个分支(NPM可以直接从git存储库中提取库)。它具有蒙太奇的绑定,这正是我所需要的。

  • ImageMagick非常慢,虽然它适用于Windows。

  • The official repo has very few basic ImageMagick commands covered but I used this fork (good thing that NPM can pull libraries directly from git repositories). It has bindings for montage which does exactly what I need.
  • ImageMagick is quite slow, though it works on Windows.

Node-Vips


  • 巨大的加号:它使用了令人难以置信的 VIPS图书馆,我很熟悉。 VIPS速度非常快,并针对大图像进行了优化。使用硬件资源非常聪明:如果您的计算机有大量RAM,它将在内存中进行所有处理,但如果内存不足或其他应用程序需要,则会切换到硬盘驱动器缓存。

  • 与node-canvas相同,它需要Node-Waf,因此它还不适用于Windows。

  • Huge plus: it uses an incredible VIPS library which I'm familiar with. VIPS is very fast and optimized for large images. It's very smart about utilizing hardware resources: if your machine has a lot of RAM it'll do all processing in memory but will switch to hard-drive caches if memory is scarce or required for other applications.
  • same as node-canvas it requires Node-Waf so it's not available for Windows yet.

我还查看了其他库从列表中,但大多数是非常不成熟或不适合我的用例。当Node-Waf被移植到Windows时,我真的想尝试迁移到Node-Canvas或Node-Vips,但在那之前我会坚持使用node-imagemagick。

I also looked at other libraries from the list but most of them are either very immature or do not suit my use case. I would really like to try migrating to either Node-Canvas or Node-Vips when Node-Waf gets ported to Windows but until then I'll stick to node-imagemagick.

这篇关于我应该在Node.JS上使用哪个库进行服务器端图像处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆