Merge pull request #14 from pierreinglebert/feature-magickloader

Add support for many other input files via the *magick libraries
This commit is contained in:
Lovell Fuller 2014-04-02 22:26:38 +01:00
commit 3703ee41aa
2 changed files with 12 additions and 6 deletions

View File

@ -26,7 +26,7 @@ This module is powered by the blazingly fast [libvips](https://github.com/jcupit
### Install libvips on Mac OS ### Install libvips on Mac OS
brew install homebrew/science/vips --with-webp brew install homebrew/science/vips --with-webp --with-graphicsmagick
The _gettext_ dependency of _libvips_ [can lead](https://github.com/lovell/sharp/issues/9) to a `library not found for -lintl` error. If so, please try: The _gettext_ dependency of _libvips_ [can lead](https://github.com/lovell/sharp/issues/9) to a `library not found for -lintl` error. If so, please try:

View File

@ -33,7 +33,8 @@ typedef enum {
JPEG, JPEG,
PNG, PNG,
WEBP, WEBP,
TIFF TIFF,
MAGICK
} ImageType; } ImageType;
unsigned char MARKER_JPEG[] = {0xff, 0xd8}; unsigned char MARKER_JPEG[] = {0xff, 0xd8};
@ -98,25 +99,30 @@ class ResizeWorker : public NanAsyncWorker {
(baton->err).append("Unsupported input buffer"); (baton->err).append("Unsupported input buffer");
return; return;
} }
} else if (is_jpeg(baton->file_in)) { } else if (vips_foreign_is_a("jpegload", baton->file_in.c_str())) {
if (vips_jpegload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) { if (vips_jpegload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) {
return resize_error(baton, in); return resize_error(baton, in);
} }
} else if (is_png(baton->file_in)) { } else if (vips_foreign_is_a("pngload", baton->file_in.c_str())) {
inputImageType = PNG; inputImageType = PNG;
if (vips_pngload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) { if (vips_pngload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) {
return resize_error(baton, in); return resize_error(baton, in);
} }
} else if (is_webp(baton->file_in)) { } else if (vips_foreign_is_a("webpload", baton->file_in.c_str())) {
inputImageType = WEBP; inputImageType = WEBP;
if (vips_webpload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) { if (vips_webpload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) {
return resize_error(baton, in); return resize_error(baton, in);
} }
} else if (is_tiff(baton->file_in)) { } else if (vips_foreign_is_a("tiffload", baton->file_in.c_str())) {
inputImageType = TIFF; inputImageType = TIFF;
if (vips_tiffload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) { if (vips_tiffload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) {
return resize_error(baton, in); return resize_error(baton, in);
} }
} else if(vips_foreign_is_a("magickload", (baton->file_in).c_str())) {
inputImageType = MAGICK;
if (vips_magickload((baton->file_in).c_str(), &in, "access", baton->access_method, NULL)) {
return resize_error(baton, in);
}
} else { } else {
resize_error(baton, in); resize_error(baton, in);
(baton->err).append("Unsupported input file " + baton->file_in); (baton->err).append("Unsupported input file " + baton->file_in);