-
Notifications
You must be signed in to change notification settings - Fork 27
affine should have a background parameter, and not have jaggy edges #58
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
Comments
I agree, the jagged edges are ugly, they should be fixed. In the meantime, you can add a one-pixel border around the input image, the same colour as the background for similarity (ie. always black). You're right, a parameter to set the background for You can use 8.6 has a new |
I've made this into an enhancement issue for |
Thanks for the answer, looking forward to the enhancements. Was also thinking about adding a border before rotating. What's the best way to do this? (I hope my questions aren't too basic, but I couldn't figure that one out) I assume flatten doesn't help in this case, since the background can have transparency as well, which I'd like to keep. But hopefully composite will solve my problems. |
Use https://jcupitt.github.io/php-vips/docs/classes/Jcupitt.Vips.ImageAutodoc.html#method_embed The C docs have more detail: https://jcupitt.github.io/libvips/API/current/libvips-conversion.html#vips-embed However, I think the right place to fix this would be in libvips. Let me see if I can address this in 8.6, and then you can avoid adding ugly workarounds to your code. |
There's an issue on the main libvips repo to track this improvement. |
It seems to be fixed in this branch: https://github.com/jcupitt/libvips/tree/fix-affine-jaggies With this command:
I see: Would you be able to test this? |
btw, can confirm that the composite works, eg:
works nicely, also with alpha channels. Looking forward to see #55 implemented to have consts for those ints. |
It wasn't premultiplying alpha, which can add edges on resampling. Could you test again? Funny how fiddly it can be to get all the edge cases out. |
The borders are fine now, but the background (apart from the direct border pixels) is now always totally transparent, even with for example ['background' => [0,0,0,255]]. On purpose, so I should composite a background in? |
perfect. thanks a lot, looking forward to 8.6 |
Thank you very much for testing this. I'll merge to master and add stuff for this to the test suite. |
I try to rotate an image by arbitrary angle. Basically works fine with just
similarity
, but the borders look pretty jagged, compared to what for example imagick produces.Any hints to make them smoother?


With VIPS:
With IMagick:
I'd also like to have a user-definable "background" layer instead of just an fully transparent alpha channel. For now I do this with:
But I assume this doesn't really work nicely, in case I happen to have smooth borders with hopefully also smoothness on the alpha channel for the rotated image. How would I put the rotated image on top of the background image (which can have an alpha channel as well)? Basically a
compositeImage
operation in IMagick, I assume.The text was updated successfully, but these errors were encountered: