Some tweaks
This commit is contained in:
parent
5072c6ea10
commit
551c7294b5
5 changed files with 15 additions and 28 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue