@@ -537,6 +537,43 @@ class Image extends ImageAutodoc implements \ArrayAccess
537
537
'openexrload ' => 'VipsForeignLoadOpenexr '
538
538
];
539
539
540
+ /**
541
+ * Combine takes an array of blend modes, passed to libvips as an array of
542
+ * int. Because libvips does now know they should be enums, we have to do
543
+ * the string->int conversion ourselves. We ought to introspect to find the
544
+ * mapping, but until we have the machinery for that, we just hardwire the
545
+ * mapping here.
546
+ *
547
+ * @internal
548
+ */
549
+ private static $ blendModeToInt = [
550
+ BlendMode::CLEAR => 0 ,
551
+ BlendMode::SOURCE => 1 ,
552
+ BlendMode::OVER => 2 ,
553
+ BlendMode::IN => 3 ,
554
+ BlendMode::OUT => 4 ,
555
+ BlendMode::ATOP => 5 ,
556
+ BlendMode::DEST => 6 ,
557
+ BlendMode::DEST_OVER => 7 ,
558
+ BlendMode::DEST_IN => 8 ,
559
+ BlendMode::DEST_OUT => 9 ,
560
+ BlendMode::DEST_ATOP => 10 ,
561
+ BlendMode::XOR => 11 ,
562
+ BlendMode::ADD => 12 ,
563
+ BlendMode::SATURATE => 13 ,
564
+ BlendMode::MULTIPLY => 14 ,
565
+ BlendMode::SCREEN => 15 ,
566
+ BlendMode::OVERLAY => 16 ,
567
+ BlendMode::DARKEN => 17 ,
568
+ BlendMode::LIGHTEN => 18 ,
569
+ BlendMode::COLOUR_DODGE => 19 ,
570
+ BlendMode::COLOUR_BURN => 20 ,
571
+ BlendMode::HARD_LIGHT => 21 ,
572
+ BlendMode::SOFT_LIGHT => 22 ,
573
+ BlendMode::DIFFERENCE => 23 ,
574
+ BlendMode::EXCLUSION => 24
575
+ ];
576
+
540
577
/**
541
578
* The resource for the underlying VipsImage.
542
579
*
@@ -1013,6 +1050,8 @@ public static function newInterpolator(string $name)
1013
1050
*
1014
1051
* @param mixed $value The value to set each pixel to.
1015
1052
*
1053
+ * @throws Exception
1054
+ *
1016
1055
* @return Image A new Image.
1017
1056
*/
1018
1057
public function newFromImage ($ value ): Image
@@ -1483,6 +1522,7 @@ public function offsetGet($offset): Image
1483
1522
* @param Image $value The band to insert
1484
1523
*
1485
1524
* @throws \BadMethodCallException if the offset is not integer or null
1525
+ * @throws Exception
1486
1526
*
1487
1527
* @return void
1488
1528
*/
@@ -1528,6 +1568,7 @@ public function offsetSet($offset, $value)
1528
1568
*
1529
1569
* @throws \BadMethodCallException if there is only one band left in
1530
1570
* the image
1571
+ * @throws Exception
1531
1572
*
1532
1573
* @return void
1533
1574
*/
@@ -1976,9 +2017,10 @@ public function composite($other, $mode, array $options = []): Image
1976
2017
$ mode = [$ mode ];
1977
2018
}
1978
2019
1979
- foreach ($ mode as &$ x ) {
1980
- $ x = BlendMode::TO_INT [$ x ];
1981
- }
2020
+ $ mode = array_map (function ($ x ) {
2021
+ // Use BlendMode::OVER if a non-existent value is given.
2022
+ return self ::$ blendModeToInt [$ x ] ?? BlendMode::OVER ;
2023
+ }, $ mode );
1982
2024
1983
2025
return self ::call (
1984
2026
'composite ' ,
0 commit comments