Simplify flag, fix togif crash, update license

This commit is contained in:
Essem 2023-01-03 22:03:51 -06:00
parent 3c16599126
commit 5ba0336837
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
4 changed files with 7 additions and 17 deletions

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022 Essem Copyright (c) 2023 Essem
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,5 +1,3 @@
#include <map>
#include <string>
#include <vips/vips8> #include <vips/vips8>
#include "common.h" #include "common.h"
@ -37,18 +35,8 @@ char *Flag(string *type, char *BufferData, size_t BufferLength,
// this is a pretty cool line, just saying // this is a pretty cool line, just saying
overlayImage = overlayImage * vector<double>{1, 1, 1, 0.5}; overlayImage = overlayImage * vector<double>{1, 1, 1, 0.5};
} }
VImage replicated = overlayImage.replicate(1, nPages);
vector<VImage> img; VImage final = in.composite2(replicated, VIPS_BLEND_MODE_OVER);
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);
void *buf; void *buf;
final.write_to_buffer( final.write_to_buffer(

View file

@ -9,7 +9,9 @@ char *ToGif(string *type, char *BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t *DataSize) { ArgumentMap Arguments, size_t *DataSize) {
if (*type == "gif") { if (*type == "gif") {
*DataSize = BufferLength; *DataSize = BufferLength;
return BufferData; char *data = (char *)malloc(BufferLength);
memcpy(data, BufferData, BufferLength);
return data;
} else { } else {
VOption *options = VImage::option()->set("access", "sequential"); VOption *options = VImage::option()->set("access", "sequential");

View file

@ -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. // 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"; const fileExtension = object.params.type ? object.params.type.split("/")[1] : "png";
promise.then(buf => { promise.then(buf => {
object.params.data = buf; if (buf) object.params.data = buf;
const objectWithFixedType = Object.assign({}, object.params, { type: fileExtension }); const objectWithFixedType = Object.assign({}, object.params, { type: fileExtension });
if (objectWithFixedType.gravity) { if (objectWithFixedType.gravity) {
if (isNaN(objectWithFixedType.gravity)) { if (isNaN(objectWithFixedType.gravity)) {