Only set density option when using magick loader

to reduce number of warnings from libvips #352
This commit is contained in:
Lovell Fuller 2016-02-04 19:16:49 +00:00
parent 0e29c55d13
commit 736c04a7a4
3 changed files with 16 additions and 11 deletions

View File

@ -29,6 +29,10 @@
[#347](https://github.com/lovell/sharp/issues/347)
[@oaleynik](https://github.com/oaleynik)
* Ensure default crop gravity is center/centre.
[#351](https://github.com/lovell/sharp/pull/351)
[@joelmukuthu](https://github.com/joelmukuthu)
* Small optimisation when reducing by an integral factor to favour shrink over affine.
* Add support for gamma correction of images with an alpha channel.

View File

@ -39,6 +39,7 @@ using Nan::Equals;
using vips::VImage;
using vips::VInterpolate;
using vips::VOption;
using vips::VError;
using sharp::Composite;
@ -222,11 +223,11 @@ class PipelineWorker : public AsyncWorker {
inputImageType = DetermineImageType(baton->bufferIn, baton->bufferInLength);
if (inputImageType != ImageType::UNKNOWN) {
try {
image = VImage::new_from_buffer(
baton->bufferIn, baton->bufferInLength, nullptr, VImage::option()
->set("access", baton->accessMethod)
->set("density", baton->density.data())
);
VOption *option = VImage::option()->set("access", baton->accessMethod);
if (inputImageType == ImageType::MAGICK) {
option->set("density", baton->density.data());
}
image = VImage::new_from_buffer(baton->bufferIn, baton->bufferInLength, nullptr, option);
} catch (...) {
(baton->err).append("Input buffer has corrupt header");
inputImageType = ImageType::UNKNOWN;
@ -240,11 +241,11 @@ class PipelineWorker : public AsyncWorker {
inputImageType = DetermineImageType(baton->fileIn.data());
if (inputImageType != ImageType::UNKNOWN) {
try {
image = VImage::new_from_file(
baton->fileIn.data(), VImage::option()
->set("access", baton->accessMethod)
->set("density", baton->density.data())
);
VOption *option = VImage::option()->set("access", baton->accessMethod);
if (inputImageType == ImageType::MAGICK) {
option->set("density", baton->density.data());
}
image = VImage::new_from_file(baton->fileIn.data(), option);
} catch (...) {
(baton->err).append("Input file has corrupt header");
inputImageType = ImageType::UNKNOWN;

View File

@ -5,7 +5,7 @@
"author": "Lovell Fuller <npm@lovell.info>",
"description": "Benchmark and performance tests for sharp",
"scripts": {
"test": "node perf && node random && node parallel"
"test": "VIPS_WARNING=0 node perf && node random && node parallel"
},
"devDependencies": {
"async": "^1.5.2",