Преглед изворни кода

Use magenta as a transparency key for trim

DarthSim пре 3 година
родитељ
комит
0fa36db813
3 измењених фајлова са 6 додато и 2 уклоњено
  1. 2 0
      CHANGELOG.md
  2. 3 1
      docs/generating_the_url_advanced.md
  3. 1 1
      vips.c

+ 2 - 0
CHANGELOG.md

@@ -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
docs/generating_the_url_advanced.md

@@ -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
vips.c

@@ -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))