-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gray line on the edges in the multiply process #400
Comments
Hi @JohnAnon9771, could you upload your overlay and base images too? |
Sure! @jcupitt Positions: base_image: art_image: |
I think your art image has been premultiplied -- ie. the alpha has already been blended into the RGB layer. If I run:
I get: Which looks better to me. You can either save your art image as unpremultiplied (PNG images are supposed to be unpremultiplied), or pass the |
Oh, maybe not, I tried unpremultiplying your art image and it looks bad. But I looked at the sources again and I can't see anything wrong with MULTIPLY :( Puzzling! |
It seems Pixman does (if I understand correctly): instead of: (i.e. the equation documented at https://www.cairographics.org/operators/) So, there's a missing Details--- a/libvips/conversion/composite.cpp
+++ b/libvips/conversion/composite.cpp
@@ -488,7 +488,6 @@ vips_composite_base_blend(VipsCompositeBase *composite,
double aR;
double t1;
double t2;
- double t3;
double f[MAX_BANDS + 1];
/* Load and scale the pixel to 0 - 1.
@@ -701,9 +700,8 @@ vips_composite_base_blend(VipsCompositeBase *composite,
t1 = 1 - aB;
t2 = 1 - aA;
- t3 = aA * aB;
for (int b = 0; b < bands; b++)
- B[b] = t1 * A[b] + t2 * B[b] + t3 * f[b];
+ B[b] = t1 * A[b] + t2 * B[b] + f[b];
break;
}
@@ -732,7 +730,6 @@ vips_composite_base_blend3(VipsCompositeSequence *seq,
float aR;
float t1;
float t2;
- float t3;
v4f f;
v4f g;
@@ -934,8 +931,7 @@ vips_composite_base_blend3(VipsCompositeSequence *seq,
t1 = 1 - aB;
t2 = 1 - aA;
- t3 = aA * aB;
- B = t1 * A + t2 * B + t3 * f;
+ B = t1 * A + t2 * B + f;
break;
} When running: $ vips composite2 base_image.jpg art_image.png x-multiply.png multiply --x=-448 --y=395 |
Ah great detective work. But how strange! That will change all 11 of the PDF blend modes, won't it? You'd think we'd have noticed this before. |
Indeed, that will change all 11 separable PDF blend modes. :( Perhaps the instead of just: |
Looking at this comment, it seems that this problem has already been seen. |
Hmm, for --- a/cairo.c
+++ b/cairo.c
@@ -17,7 +17,7 @@ main(int argc, char *argv[])
cairo_set_source_rgba(cr, 0.7, 0, 0, 0.8);
cairo_fill(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_MULTIPLY);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SCREEN);
cairo_rectangle(cr, 40, 30, 120, 90);
cairo_set_source_rgba(cr, 0, 0, 0.9, 0.8); --- a/vips.py
+++ b/vips.py
@@ -10,5 +10,5 @@ overlay = (pyvips.Image.black(120, 190)
.new_from_image([0, 0, 230, 204])
.embed(40, 30, 160, 120))
-im = base.composite2(overlay, 'multiply')
+im = base.composite2(overlay, 'screen', premultiplied=True)
im.write_to_file('vips.png') If you don't do this, it will produce:
Perhaps the separable PDF blend modes in Cairo always operates on unpremultiplied values? |
Describe the bug
When I try to perform a composite process with multiply, for some reason the overlay image gets a gray border. This is only happening with the multiply process. When checking with Photoshop, this issue does not occur, and the image appears without the border as it should from the beginning.
To Reproduce
Resulting image:
Expected image:
Additional context
To solve this problem, I applied a white background instead of transparent, but I'm not sure if this is the correct way to do it...
The text was updated successfully, but these errors were encountered: