Use magenta as a transparency key for trim

This commit is contained in:
DarthSim
2021-06-07 15:05:29 +06:00
parent 9d061c6f3e
commit 0fa36db813
3 changed files with 6 additions and 2 deletions
+2
View File
@@ -1,6 +1,8 @@
# Changelog
## [Unreleased]
### Change
- Use magenta (ff00ff) as a transparency key in `trim`.
## [2.16.3] - 2021-04-05
### Fix
+3 -1
View File
@@ -207,7 +207,9 @@ Removes surrounding background.
**⚠️Warning:** Trimming requires an image to be fully loaded into memory. This disables scale-on-load and significantly increases memory usage and processing time. Use it carefully with large images.
**📝Note:** If you know background color of your images then setting it explicitly via `color` will also save some resources because libvips won't detect it automatically.
**📝Note:** If you know background color of your images then setting it explicitly via `color` will also save some resources because imgproxy won't detect it automatically.
**📝Note:** Use `color` value of `FF00FF` for trimming transparent background as imgproxy uses magenta as a transparency key.
**📝Note:** Trimming of animated images is not supported.
+1 -1
View File
@@ -470,7 +470,7 @@ vips_trim(VipsImage *in, VipsImage **out, double threshold,
VipsImage *tmp;
if (vips_image_hasalpha(in)) {
if (vips_flatten(in, &tmp, NULL))
if (vips_flatten_go(in, &tmp, 255.0, 0, 255.0))
return 1;
} else {
if (vips_copy(in, &tmp, NULL))