diff --git a/LICENSE b/LICENSE index f26d3aa..2b01000 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Essem +Copyright (c) 2023 Essem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/natives/flag.cc b/natives/flag.cc index 5659be8..2c4a9a5 100644 --- a/natives/flag.cc +++ b/natives/flag.cc @@ -1,5 +1,3 @@ -#include -#include #include #include "common.h" @@ -37,18 +35,8 @@ char *Flag(string *type, char *BufferData, size_t BufferLength, // this is a pretty cool line, just saying overlayImage = overlayImage * vector{1, 1, 1, 0.5}; } - - vector img; - for (int i = 0; i < nPages; i++) { - VImage img_frame = - *type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in; - VImage composited = - img_frame.composite2(overlayImage, VIPS_BLEND_MODE_OVER); - img.push_back(composited); - } - - VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1)); - final.set(VIPS_META_PAGE_HEIGHT, pageHeight); + VImage replicated = overlayImage.replicate(1, nPages); + VImage final = in.composite2(replicated, VIPS_BLEND_MODE_OVER); void *buf; final.write_to_buffer( diff --git a/natives/togif.cc b/natives/togif.cc index 48c4c7f..16ff000 100644 --- a/natives/togif.cc +++ b/natives/togif.cc @@ -9,7 +9,9 @@ char *ToGif(string *type, char *BufferData, size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) { if (*type == "gif") { *DataSize = BufferLength; - return BufferData; + char *data = (char *)malloc(BufferLength); + memcpy(data, BufferData, BufferLength); + return data; } else { VOption *options = VImage::option()->set("access", "sequential"); diff --git a/utils/image-runner.js b/utils/image-runner.js index 1a93e7b..17948fd 100644 --- a/utils/image-runner.js +++ b/utils/image-runner.js @@ -38,7 +38,7 @@ export default function run(object) { // If no image type is given (say, the command generates its own image), make it a PNG. const fileExtension = object.params.type ? object.params.type.split("/")[1] : "png"; promise.then(buf => { - object.params.data = buf; + if (buf) object.params.data = buf; const objectWithFixedType = Object.assign({}, object.params, { type: fileExtension }); if (objectWithFixedType.gravity) { if (isNaN(objectWithFixedType.gravity)) {