Some tweaks

This commit is contained in:
Essem 2022-06-25 12:45:42 -05:00
parent 5072c6ea10
commit 551c7294b5
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
5 changed files with 15 additions and 28 deletions

View file

@ -23,24 +23,11 @@ Napi::Value ToGif(const Napi::CallbackInfo &info) {
VOption *options = VImage::option()->set("access", "sequential");
VImage in =
VImage::new_from_buffer(data.Data(), data.Length(), "",
type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
int pageHeight = vips_image_get_page_height(in.get_image());
vector<VImage> img;
img.push_back(in);
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
final.set(VIPS_META_PAGE_HEIGHT, pageHeight + in.height());
VImage::new_from_buffer(data.Data(), data.Length(), "", options);
void *buf;
size_t length;
final.write_to_buffer(
("." + type).c_str(), &buf, &length, VImage::option()->set("dither", 0));
in.write_to_buffer(".gif", &buf, &length);
vips_thread_shutdown();