@@ -638,15 +638,17 @@ class PipelineWorker : public Napi::AsyncWorker {
638638 std::tie (image, background) = sharp::ApplyAlpha (image, baton->extendBackground , shouldPremultiplyAlpha);
639639 }
640640 image = sharp::StaySequential (image, nPages > 1 || baton->extendWith != VIPS_EXTEND_BACKGROUND );
641- auto options = VImage::option ()->set (" extend" , baton->extendWith );
642- if (baton->extendWith == VIPS_EXTEND_BACKGROUND ) {
643- options->set (" background" , background);
641+ if (nPages > 1 ) {
642+ image = sharp::EmbedMultiPage (image,
643+ baton->extendLeft , baton->extendTop , baton->width , baton->height ,
644+ baton->extendWith , background, nPages, &targetPageHeight);
645+ } else {
646+ auto options = VImage::option ()->set (" extend" , baton->extendWith );
647+ if (baton->extendWith == VIPS_EXTEND_BACKGROUND ) {
648+ options->set (" background" , background);
649+ }
650+ image = image.embed (baton->extendLeft , baton->extendTop , baton->width , baton->height , options);
644651 }
645- image = nPages > 1
646- ? sharp::EmbedMultiPage (image,
647- baton->extendLeft , baton->extendTop , baton->width , baton->height ,
648- baton->extendWith , background, nPages, &targetPageHeight)
649- : image.embed (baton->extendLeft , baton->extendTop , baton->width , baton->height , options);
650652 if (baton->keepGainMap ) {
651653 gainMap = gainMap.embed (baton->extendLeft / gainMapScaleFactor, baton->extendTop / gainMapScaleFactor,
652654 baton->width / gainMapScaleFactor, baton->height / gainMapScaleFactor, VImage::option ()
@@ -1468,7 +1470,7 @@ class PipelineWorker : public Napi::AsyncWorker {
14681470 // ECMAScript ArrayBuffer with Uint8Array view
14691471 Napi::TypedArrayOf<uint8_t > data = Napi::Buffer<char >::Copy (env,
14701472 static_cast <char *>(baton->bufferOut ), baton->bufferOutLength );
1471- sharp::FreeCallback (static_cast <char *>(baton->bufferOut ), nullptr );
1473+ sharp::FreeCallback (nullptr , static_cast <char *>(baton->bufferOut ));
14721474 Callback ().SHARP_CALLBACK_FN_NAME (Receiver ().Value (), { env.Null (), data, info });
14731475 } else {
14741476 // Node.js Buffer
0 commit comments