Image commands now use optimizeTransparency instead of optimizeImageLayers

This commit is contained in:
TheEssem 2021-02-12 18:22:36 -06:00
parent e7ffa23411
commit 3d85389638
27 changed files with 70 additions and 92 deletions

View file

@ -14,7 +14,6 @@ class BlurWorker : public Napi::AsyncWorker {
void Execute() {
list <Image> frames;
list <Image> coalesced;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -26,9 +25,9 @@ class BlurWorker : public Napi::AsyncWorker {
for_each(coalesced.begin(), coalesced.end(), magickImage(type));
optimizeImageLayers(&result, coalesced.begin(), coalesced.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(coalesced.begin(), coalesced.end());
if (delay != 0) for_each(coalesced.begin(), coalesced.end(), animationDelayImage(delay));
writeImages(coalesced.begin(), coalesced.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class BlurpleWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> blurpled;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -23,12 +22,12 @@ class BlurpleWorker : public Napi::AsyncWorker {
image.threshold(49151.25);
image.levelColors("#7289DA", "white");
image.magick(type);
image.animationDelay(delay == 0 ? image.animationDelay() : delay);
blurpled.push_back(image);
}
optimizeImageLayers(&result, blurpled.begin(), blurpled.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(blurpled.begin(), blurpled.end());
writeImages(blurpled.begin(), blurpled.end(), &blob);
}
void OnOK() {

View file

@ -44,8 +44,8 @@ class CaptionWorker : public Napi::AsyncWorker {
captioned.push_back(appended);
}
optimizeImageLayers(&result, captioned.begin(), captioned.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(captioned.begin(), captioned.end());
writeImages(captioned.begin(), captioned.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> captioned;
list <Image> result;
Blob caption_blob;
readImages(&frames, in_path);
@ -43,8 +42,8 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
captioned.push_back(appended);
}
optimizeImageLayers(&result, captioned.begin(), captioned.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(captioned.begin(), captioned.end());
writeImages(captioned.begin(), captioned.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class CircleWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -25,9 +24,9 @@ class CircleWorker : public Napi::AsyncWorker {
blurred.push_back(image);
}
optimizeImageLayers(&result, blurred.begin(), blurred.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(blurred.begin(), blurred.end());
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
writeImages(blurred.begin(), blurred.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class CropWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -26,9 +25,9 @@ class CropWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class ExplodeWorker : public Napi::AsyncWorker {
list<Image> frames;
list<Image> coalesced;
list<Image> blurred;
list<Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -25,9 +24,9 @@ class ExplodeWorker : public Napi::AsyncWorker {
blurred.push_back(image);
}
optimizeImageLayers(&result, blurred.begin(), blurred.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(blurred.begin(), blurred.end());
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
writeImages(blurred.begin(), blurred.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class FlagWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read(overlay_path);
@ -31,9 +30,9 @@ class FlagWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class FlipWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -25,9 +24,9 @@ class FlipWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class GamexplainWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/gamexplain.png");
@ -30,9 +29,9 @@ class GamexplainWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class GlobeWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image distort;
Image overlay;
readImages(&frames, in_path);
@ -43,13 +42,13 @@ class GlobeWorker : public Napi::AsyncWorker {
i++;
}
optimizeImageLayers(&result, mid.begin(), mid.end());
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) {
for_each(result.begin(), result.end(), animationDelayImage(delay));
for_each(mid.begin(), mid.end(), animationDelayImage(delay));
} else if (type != "GIF") {
for_each(result.begin(), result.end(), animationDelayImage(5));
for_each(mid.begin(), mid.end(), animationDelayImage(5));
}
writeImages(result.begin(), result.end(), &blob);
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class InvertWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -27,9 +26,9 @@ class InvertWorker : public Napi::AsyncWorker {
// Magick::ChannelType(Magick::CompositeChannels ^ Magick::AlphaChannel)
for_each(mid.begin(), mid.end(), magickImage(type));
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -30,6 +30,7 @@ class LeakWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}

View file

@ -15,7 +15,6 @@ class MagikWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -27,9 +26,9 @@ class MagikWorker : public Napi::AsyncWorker {
blurred.push_back(image);
}
optimizeImageLayers(&result, blurred.begin(), blurred.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(blurred.begin(), blurred.end());
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
writeImages(blurred.begin(), blurred.end(), &blob);
}
void OnOK() {

View file

@ -56,6 +56,7 @@ class MemeWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}

View file

@ -15,7 +15,6 @@ class MirrorWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
MagickCore::GravityType gravity;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -53,8 +52,8 @@ class MirrorWorker : public Napi::AsyncWorker {
mid.push_back(final);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class SwirlWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -25,9 +24,9 @@ class SwirlWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class MotivateWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image top;
Image bottom;
readImages(&frames, in_path);
@ -60,8 +59,8 @@ class MotivateWorker : public Napi::AsyncWorker {
mid.push_back(final);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class ResizeWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> blurred;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -32,9 +31,9 @@ class ResizeWorker : public Napi::AsyncWorker {
blurred.push_back(image);
}
optimizeImageLayers(&result, blurred.begin(), blurred.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(blurred.begin(), blurred.end());
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
writeImages(blurred.begin(), blurred.end(), &blob);
}
void OnOK() {

View file

@ -14,7 +14,6 @@ class ReverseWorker : public Napi::AsyncWorker {
void Execute() {
list<Image> frames;
list<Image> coalesced;
list<Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -28,9 +27,9 @@ class ReverseWorker : public Napi::AsyncWorker {
for_each(coalesced.begin(), coalesced.end(), magickImage("GIF"));
optimizeImageLayers(&result, coalesced.begin(), coalesced.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(coalesced.begin(), coalesced.end());
if (delay != 0) for_each(coalesced.begin(), coalesced.end(), animationDelayImage(delay));
writeImages(coalesced.begin(), coalesced.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class ScottWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/scott.png");
@ -35,8 +34,8 @@ class ScottWorker : public Napi::AsyncWorker {
mid.push_back(watermark_new);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class SpinWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -37,13 +36,13 @@ class SpinWorker : public Napi::AsyncWorker {
i++;
}
optimizeImageLayers(&result, mid.begin(), mid.end());
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) {
for_each(result.begin(), result.end(), animationDelayImage(delay));
for_each(mid.begin(), mid.end(), animationDelayImage(delay));
} else if (type != "GIF") {
for_each(result.begin(), result.end(), animationDelayImage(5));
for_each(mid.begin(), mid.end(), animationDelayImage(5));
}
writeImages(result.begin(), result.end(), &blob);
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class TileWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -40,8 +39,8 @@ class TileWorker : public Napi::AsyncWorker {
mid.push_back(frame);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class TrumpWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/trump.png");
@ -35,8 +34,8 @@ class TrumpWorker : public Napi::AsyncWorker {
mid.push_back(watermark_new);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class WallWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
readImages(&frames, in_path);
coalesceImages(&coalesced, frames.begin(), frames.end());
@ -32,9 +31,9 @@ class WallWorker : public Napi::AsyncWorker {
mid.push_back(image);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
if (delay != 0) for_each(result.begin(), result.end(), animationDelayImage(delay));
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -16,7 +16,6 @@ class WatermarkWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read(water_path);
@ -51,8 +50,8 @@ class WatermarkWorker : public Napi::AsyncWorker {
mid.push_back(final);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {

View file

@ -15,7 +15,6 @@ class WdtWorker : public Napi::AsyncWorker {
list <Image> frames;
list <Image> coalesced;
list <Image> mid;
list <Image> result;
Image watermark;
readImages(&frames, in_path);
watermark.read("./assets/images/whodidthis.png");
@ -30,8 +29,8 @@ class WdtWorker : public Napi::AsyncWorker {
mid.push_back(watermark_new);
}
optimizeImageLayers(&result, mid.begin(), mid.end());
writeImages(result.begin(), result.end(), &blob);
optimizeTransparency(mid.begin(), mid.end());
writeImages(mid.begin(), mid.end(), &blob);
}
void OnOK() {