Optimize dithering (#66)
This commit is contained in:
parent
928eb7fa16
commit
4842479001
27 changed files with 236 additions and 15 deletions
|
@ -26,7 +26,15 @@ class BlurWorker : public Napi::AsyncWorker {
|
||||||
for_each(coalesced.begin(), coalesced.end(), magickImage(type));
|
for_each(coalesced.begin(), coalesced.end(), magickImage(type));
|
||||||
|
|
||||||
optimizeTransparency(coalesced.begin(), coalesced.end());
|
optimizeTransparency(coalesced.begin(), coalesced.end());
|
||||||
if (delay != 0) for_each(coalesced.begin(), coalesced.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : coalesced) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(coalesced.begin(), coalesced.end(), &blob);
|
writeImages(coalesced.begin(), coalesced.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,15 @@ class BlurpleWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(blurpled.begin(), blurpled.end());
|
optimizeTransparency(blurpled.begin(), blurpled.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : blurpled) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
writeImages(blurpled.begin(), blurpled.end(), &blob);
|
writeImages(blurpled.begin(), blurpled.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,15 @@ class CaptionWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(captioned.begin(), captioned.end());
|
optimizeTransparency(captioned.begin(), captioned.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : captioned) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
writeImages(captioned.begin(), captioned.end(), &blob);
|
writeImages(captioned.begin(), captioned.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,14 @@ class CaptionTwoWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(captioned.begin(), captioned.end());
|
optimizeTransparency(captioned.begin(), captioned.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : captioned) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(captioned.begin(), captioned.end(), &blob);
|
writeImages(captioned.begin(), captioned.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@ class CircleWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(blurred.begin(), blurred.end());
|
optimizeTransparency(blurred.begin(), blurred.end());
|
||||||
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : blurred) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,15 @@ class CropWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@ class ExplodeWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(blurred.begin(), blurred.end());
|
optimizeTransparency(blurred.begin(), blurred.end());
|
||||||
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : blurred) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,15 @@ class FlagWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@ class FlipWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,15 @@ class GamexplainWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,12 @@ class GlobeWorker : public Napi::AsyncWorker {
|
||||||
} else if (type != "GIF") {
|
} else if (type != "GIF") {
|
||||||
for_each(mid.begin(), mid.end(), animationDelayImage(5));
|
for_each(mid.begin(), mid.end(), animationDelayImage(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,15 @@ class InvertWorker : public Napi::AsyncWorker {
|
||||||
for_each(mid.begin(), mid.end(), magickImage(type));
|
for_each(mid.begin(), mid.end(), magickImage(type));
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,15 @@ class LeakWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,15 @@ class MagikWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(blurred.begin(), blurred.end());
|
optimizeTransparency(blurred.begin(), blurred.end());
|
||||||
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : blurred) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,15 @@ class MemeWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,15 @@ class MirrorWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,15 @@ class SwirlWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,15 @@ class MotivateWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,15 @@ class ResizeWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(blurred.begin(), blurred.end());
|
optimizeTransparency(blurred.begin(), blurred.end());
|
||||||
if (delay != 0) for_each(blurred.begin(), blurred.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : blurred) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(blurred.begin(), blurred.end(), &blob);
|
writeImages(blurred.begin(), blurred.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,15 @@ class ReverseWorker : public Napi::AsyncWorker {
|
||||||
for_each(coalesced.begin(), coalesced.end(), magickImage("GIF"));
|
for_each(coalesced.begin(), coalesced.end(), magickImage("GIF"));
|
||||||
|
|
||||||
optimizeTransparency(coalesced.begin(), coalesced.end());
|
optimizeTransparency(coalesced.begin(), coalesced.end());
|
||||||
if (delay != 0) for_each(coalesced.begin(), coalesced.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : coalesced) {
|
||||||
|
image.quantizeDither(false);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(coalesced.begin(), coalesced.end(), &blob);
|
writeImages(coalesced.begin(), coalesced.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,15 @@ class ScottWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@ class SpinWorker : public Napi::AsyncWorker {
|
||||||
} else if (type != "GIF") {
|
} else if (type != "GIF") {
|
||||||
for_each(mid.begin(), mid.end(), animationDelayImage(5));
|
for_each(mid.begin(), mid.end(), animationDelayImage(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,15 @@ class TileWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,15 @@ class TrumpWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,15 @@ class WallWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
if (delay != 0) for_each(mid.begin(), mid.end(), animationDelayImage(delay));
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,15 @@ class WatermarkWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,15 @@ class WdtWorker : public Napi::AsyncWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
optimizeTransparency(mid.begin(), mid.end());
|
optimizeTransparency(mid.begin(), mid.end());
|
||||||
|
|
||||||
|
if (type == "gif") {
|
||||||
|
for (Image &image : mid) {
|
||||||
|
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
|
||||||
|
image.quantize();
|
||||||
|
if (delay != 0) image.animationDelay(delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writeImages(mid.begin(), mid.end(), &blob);
|
writeImages(mid.begin(), mid.end(), &blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue