sharp 0.28.3 → 0.29.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/binding.gyp +12 -9
- package/install/dll-copy.js +6 -6
- package/install/libvips.js +4 -8
- package/lib/channel.js +11 -7
- package/lib/colour.js +42 -1
- package/lib/constructor.js +18 -31
- package/lib/input.js +45 -3
- package/lib/is.js +19 -5
- package/lib/libvips.js +4 -19
- package/lib/operation.js +28 -5
- package/lib/output.js +147 -16
- package/lib/sharp.js +31 -0
- package/lib/utility.js +3 -2
- package/package.json +18 -15
- package/src/common.cc +67 -11
- package/src/common.h +25 -5
- package/src/libvips/cplusplus/VConnection.cpp +0 -26
- package/src/libvips/cplusplus/VImage.cpp +54 -16
- package/src/libvips/cplusplus/VInterpolate.cpp +0 -13
- package/src/libvips/cplusplus/vips-operators.cpp +185 -1
- package/src/metadata.cc +14 -0
- package/src/metadata.h +1 -0
- package/src/operations.cc +29 -3
- package/src/operations.h +13 -2
- package/src/pipeline.cc +103 -35
- package/src/pipeline.h +23 -3
- package/src/utilities.cc +1 -1
|
@@ -110,19 +110,6 @@ VSource::new_from_options( const char *options )
|
|
|
110
110
|
return( out );
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
VOption *
|
|
114
|
-
VOption::set( const char *name, const VSource value )
|
|
115
|
-
{
|
|
116
|
-
Pair *pair = new Pair( name );
|
|
117
|
-
|
|
118
|
-
pair->input = true;
|
|
119
|
-
g_value_init( &pair->value, VIPS_TYPE_SOURCE );
|
|
120
|
-
g_value_set_object( &pair->value, value.get_source() );
|
|
121
|
-
options.push_back( pair );
|
|
122
|
-
|
|
123
|
-
return( this );
|
|
124
|
-
}
|
|
125
|
-
|
|
126
113
|
VTarget
|
|
127
114
|
VTarget::new_to_descriptor( int descriptor )
|
|
128
115
|
{
|
|
@@ -162,17 +149,4 @@ VTarget::new_to_memory()
|
|
|
162
149
|
return( out );
|
|
163
150
|
}
|
|
164
151
|
|
|
165
|
-
VOption *
|
|
166
|
-
VOption::set( const char *name, const VTarget value )
|
|
167
|
-
{
|
|
168
|
-
Pair *pair = new Pair( name );
|
|
169
|
-
|
|
170
|
-
pair->input = true;
|
|
171
|
-
g_value_init( &pair->value, VIPS_TYPE_TARGET );
|
|
172
|
-
g_value_set_object( &pair->value, value.get_target() );
|
|
173
|
-
options.push_back( pair );
|
|
174
|
-
|
|
175
|
-
return( this );
|
|
176
|
-
}
|
|
177
|
-
|
|
178
152
|
VIPS_NAMESPACE_END
|
|
@@ -51,6 +51,12 @@
|
|
|
51
51
|
|
|
52
52
|
VIPS_NAMESPACE_START
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* \namespace vips
|
|
56
|
+
*
|
|
57
|
+
* General docs for the vips namespace.
|
|
58
|
+
*/
|
|
59
|
+
|
|
54
60
|
std::vector<double>
|
|
55
61
|
to_vectorv( int n, ... )
|
|
56
62
|
{
|
|
@@ -140,6 +146,20 @@ VOption::set( const char *name, int value )
|
|
|
140
146
|
return( this );
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
// input guint64
|
|
150
|
+
VOption *
|
|
151
|
+
VOption::set( const char *name, guint64 value )
|
|
152
|
+
{
|
|
153
|
+
Pair *pair = new Pair( name );
|
|
154
|
+
|
|
155
|
+
pair->input = true;
|
|
156
|
+
g_value_init( &pair->value, G_TYPE_UINT64 );
|
|
157
|
+
g_value_set_uint64( &pair->value, value );
|
|
158
|
+
options.push_back( pair );
|
|
159
|
+
|
|
160
|
+
return( this );
|
|
161
|
+
}
|
|
162
|
+
|
|
143
163
|
// input double
|
|
144
164
|
VOption *
|
|
145
165
|
VOption::set( const char *name, double value )
|
|
@@ -167,35 +187,37 @@ VOption::set( const char *name, const char *value )
|
|
|
167
187
|
return( this );
|
|
168
188
|
}
|
|
169
189
|
|
|
170
|
-
// input image
|
|
190
|
+
// input vips object (image, source, target, etc. etc.)
|
|
171
191
|
VOption *
|
|
172
|
-
VOption::set( const char *name, const
|
|
192
|
+
VOption::set( const char *name, const VObject value )
|
|
173
193
|
{
|
|
174
194
|
Pair *pair = new Pair( name );
|
|
195
|
+
VipsObject *object = value.get_object();
|
|
196
|
+
GType type = G_OBJECT_TYPE( object );
|
|
175
197
|
|
|
176
198
|
pair->input = true;
|
|
177
|
-
g_value_init( &pair->value,
|
|
178
|
-
g_value_set_object( &pair->value,
|
|
199
|
+
g_value_init( &pair->value, type );
|
|
200
|
+
g_value_set_object( &pair->value, object );
|
|
179
201
|
options.push_back( pair );
|
|
180
202
|
|
|
181
203
|
return( this );
|
|
182
204
|
}
|
|
183
205
|
|
|
184
|
-
// input
|
|
206
|
+
// input int array
|
|
185
207
|
VOption *
|
|
186
|
-
VOption::set( const char *name, std::vector<
|
|
208
|
+
VOption::set( const char *name, std::vector<int> value )
|
|
187
209
|
{
|
|
188
210
|
Pair *pair = new Pair( name );
|
|
189
211
|
|
|
190
|
-
|
|
212
|
+
int *array;
|
|
191
213
|
unsigned int i;
|
|
192
214
|
|
|
193
215
|
pair->input = true;
|
|
194
216
|
|
|
195
|
-
g_value_init( &pair->value,
|
|
196
|
-
|
|
217
|
+
g_value_init( &pair->value, VIPS_TYPE_ARRAY_INT );
|
|
218
|
+
vips_value_set_array_int( &pair->value, NULL,
|
|
197
219
|
static_cast< int >( value.size() ) );
|
|
198
|
-
array =
|
|
220
|
+
array = vips_value_get_array_int( &pair->value, NULL );
|
|
199
221
|
|
|
200
222
|
for( i = 0; i < value.size(); i++ )
|
|
201
223
|
array[i] = value[i];
|
|
@@ -205,21 +227,21 @@ VOption::set( const char *name, std::vector<double> value )
|
|
|
205
227
|
return( this );
|
|
206
228
|
}
|
|
207
229
|
|
|
208
|
-
// input
|
|
230
|
+
// input double array
|
|
209
231
|
VOption *
|
|
210
|
-
VOption::set( const char *name, std::vector<
|
|
232
|
+
VOption::set( const char *name, std::vector<double> value )
|
|
211
233
|
{
|
|
212
234
|
Pair *pair = new Pair( name );
|
|
213
235
|
|
|
214
|
-
|
|
236
|
+
double *array;
|
|
215
237
|
unsigned int i;
|
|
216
238
|
|
|
217
239
|
pair->input = true;
|
|
218
240
|
|
|
219
|
-
g_value_init( &pair->value,
|
|
220
|
-
|
|
241
|
+
g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE );
|
|
242
|
+
vips_value_set_array_double( &pair->value, NULL,
|
|
221
243
|
static_cast< int >( value.size() ) );
|
|
222
|
-
array =
|
|
244
|
+
array = vips_value_get_array_double( &pair->value, NULL );
|
|
223
245
|
|
|
224
246
|
for( i = 0; i < value.size(); i++ )
|
|
225
247
|
array[i] = value[i];
|
|
@@ -619,6 +641,22 @@ VImage::new_from_source( VSource source, const char *option_string,
|
|
|
619
641
|
return( out );
|
|
620
642
|
}
|
|
621
643
|
|
|
644
|
+
VImage
|
|
645
|
+
VImage::new_from_memory_steal( void *data, size_t size,
|
|
646
|
+
int width, int height, int bands, VipsBandFormat format )
|
|
647
|
+
{
|
|
648
|
+
VipsImage *image;
|
|
649
|
+
|
|
650
|
+
if( !(image = vips_image_new_from_memory( data, size,
|
|
651
|
+
width, height, bands, format )) )
|
|
652
|
+
throw( VError() );
|
|
653
|
+
|
|
654
|
+
g_signal_connect( image, "postclose",
|
|
655
|
+
G_CALLBACK( vips_image_free_buffer ), data);
|
|
656
|
+
|
|
657
|
+
return( VImage( image ) );
|
|
658
|
+
}
|
|
659
|
+
|
|
622
660
|
VImage
|
|
623
661
|
VImage::new_matrix( int width, int height )
|
|
624
662
|
{
|
|
@@ -60,17 +60,4 @@ VInterpolate::new_from_name( const char *name, VOption *options )
|
|
|
60
60
|
return( out );
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
VOption *
|
|
64
|
-
VOption::set( const char *name, const VInterpolate value )
|
|
65
|
-
{
|
|
66
|
-
Pair *pair = new Pair( name );
|
|
67
|
-
|
|
68
|
-
pair->input = true;
|
|
69
|
-
g_value_init( &pair->value, VIPS_TYPE_INTERPOLATE );
|
|
70
|
-
g_value_set_object( &pair->value, value.get_interpolate() );
|
|
71
|
-
options.push_back( pair );
|
|
72
|
-
|
|
73
|
-
return( this );
|
|
74
|
-
}
|
|
75
|
-
|
|
76
63
|
VIPS_NAMESPACE_END
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// bodies for vips operations
|
|
2
|
-
//
|
|
2
|
+
// Wed May 12 11:30:00 AM CEST 2021
|
|
3
3
|
// this file is generated automatically, do not edit!
|
|
4
4
|
|
|
5
5
|
VImage VImage::CMC2LCh( VOption *options ) const
|
|
@@ -1065,6 +1065,18 @@ VImage VImage::fitsload( const char *filename, VOption *options )
|
|
|
1065
1065
|
return( out );
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
|
+
VImage VImage::fitsload_source( VSource source, VOption *options )
|
|
1069
|
+
{
|
|
1070
|
+
VImage out;
|
|
1071
|
+
|
|
1072
|
+
call( "fitsload_source",
|
|
1073
|
+
(options ? options : VImage::option())->
|
|
1074
|
+
set( "out", &out )->
|
|
1075
|
+
set( "source", source ) );
|
|
1076
|
+
|
|
1077
|
+
return( out );
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1068
1080
|
void VImage::fitssave( const char *filename, VOption *options ) const
|
|
1069
1081
|
{
|
|
1070
1082
|
call( "fitssave",
|
|
@@ -1656,6 +1668,70 @@ VImage VImage::join( VImage in2, VipsDirection direction, VOption *options ) con
|
|
|
1656
1668
|
return( out );
|
|
1657
1669
|
}
|
|
1658
1670
|
|
|
1671
|
+
VImage VImage::jp2kload( const char *filename, VOption *options )
|
|
1672
|
+
{
|
|
1673
|
+
VImage out;
|
|
1674
|
+
|
|
1675
|
+
call( "jp2kload",
|
|
1676
|
+
(options ? options : VImage::option())->
|
|
1677
|
+
set( "out", &out )->
|
|
1678
|
+
set( "filename", filename ) );
|
|
1679
|
+
|
|
1680
|
+
return( out );
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
VImage VImage::jp2kload_buffer( VipsBlob *buffer, VOption *options )
|
|
1684
|
+
{
|
|
1685
|
+
VImage out;
|
|
1686
|
+
|
|
1687
|
+
call( "jp2kload_buffer",
|
|
1688
|
+
(options ? options : VImage::option())->
|
|
1689
|
+
set( "out", &out )->
|
|
1690
|
+
set( "buffer", buffer ) );
|
|
1691
|
+
|
|
1692
|
+
return( out );
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
VImage VImage::jp2kload_source( VSource source, VOption *options )
|
|
1696
|
+
{
|
|
1697
|
+
VImage out;
|
|
1698
|
+
|
|
1699
|
+
call( "jp2kload_source",
|
|
1700
|
+
(options ? options : VImage::option())->
|
|
1701
|
+
set( "out", &out )->
|
|
1702
|
+
set( "source", source ) );
|
|
1703
|
+
|
|
1704
|
+
return( out );
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
void VImage::jp2ksave( const char *filename, VOption *options ) const
|
|
1708
|
+
{
|
|
1709
|
+
call( "jp2ksave",
|
|
1710
|
+
(options ? options : VImage::option())->
|
|
1711
|
+
set( "in", *this )->
|
|
1712
|
+
set( "filename", filename ) );
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
VipsBlob *VImage::jp2ksave_buffer( VOption *options ) const
|
|
1716
|
+
{
|
|
1717
|
+
VipsBlob *buffer;
|
|
1718
|
+
|
|
1719
|
+
call( "jp2ksave_buffer",
|
|
1720
|
+
(options ? options : VImage::option())->
|
|
1721
|
+
set( "in", *this )->
|
|
1722
|
+
set( "buffer", &buffer ) );
|
|
1723
|
+
|
|
1724
|
+
return( buffer );
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
void VImage::jp2ksave_target( VTarget target, VOption *options ) const
|
|
1728
|
+
{
|
|
1729
|
+
call( "jp2ksave_target",
|
|
1730
|
+
(options ? options : VImage::option())->
|
|
1731
|
+
set( "in", *this )->
|
|
1732
|
+
set( "target", target ) );
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1659
1735
|
VImage VImage::jpegload( const char *filename, VOption *options )
|
|
1660
1736
|
{
|
|
1661
1737
|
VImage out;
|
|
@@ -1727,6 +1803,70 @@ void VImage::jpegsave_target( VTarget target, VOption *options ) const
|
|
|
1727
1803
|
set( "target", target ) );
|
|
1728
1804
|
}
|
|
1729
1805
|
|
|
1806
|
+
VImage VImage::jxlload( const char *filename, VOption *options )
|
|
1807
|
+
{
|
|
1808
|
+
VImage out;
|
|
1809
|
+
|
|
1810
|
+
call( "jxlload",
|
|
1811
|
+
(options ? options : VImage::option())->
|
|
1812
|
+
set( "out", &out )->
|
|
1813
|
+
set( "filename", filename ) );
|
|
1814
|
+
|
|
1815
|
+
return( out );
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
VImage VImage::jxlload_buffer( VipsBlob *buffer, VOption *options )
|
|
1819
|
+
{
|
|
1820
|
+
VImage out;
|
|
1821
|
+
|
|
1822
|
+
call( "jxlload_buffer",
|
|
1823
|
+
(options ? options : VImage::option())->
|
|
1824
|
+
set( "out", &out )->
|
|
1825
|
+
set( "buffer", buffer ) );
|
|
1826
|
+
|
|
1827
|
+
return( out );
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
VImage VImage::jxlload_source( VSource source, VOption *options )
|
|
1831
|
+
{
|
|
1832
|
+
VImage out;
|
|
1833
|
+
|
|
1834
|
+
call( "jxlload_source",
|
|
1835
|
+
(options ? options : VImage::option())->
|
|
1836
|
+
set( "out", &out )->
|
|
1837
|
+
set( "source", source ) );
|
|
1838
|
+
|
|
1839
|
+
return( out );
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
void VImage::jxlsave( const char *filename, VOption *options ) const
|
|
1843
|
+
{
|
|
1844
|
+
call( "jxlsave",
|
|
1845
|
+
(options ? options : VImage::option())->
|
|
1846
|
+
set( "in", *this )->
|
|
1847
|
+
set( "filename", filename ) );
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
VipsBlob *VImage::jxlsave_buffer( VOption *options ) const
|
|
1851
|
+
{
|
|
1852
|
+
VipsBlob *buffer;
|
|
1853
|
+
|
|
1854
|
+
call( "jxlsave_buffer",
|
|
1855
|
+
(options ? options : VImage::option())->
|
|
1856
|
+
set( "in", *this )->
|
|
1857
|
+
set( "buffer", &buffer ) );
|
|
1858
|
+
|
|
1859
|
+
return( buffer );
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
void VImage::jxlsave_target( VTarget target, VOption *options ) const
|
|
1863
|
+
{
|
|
1864
|
+
call( "jxlsave_target",
|
|
1865
|
+
(options ? options : VImage::option())->
|
|
1866
|
+
set( "in", *this )->
|
|
1867
|
+
set( "target", target ) );
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1730
1870
|
VImage VImage::labelregions( VOption *options ) const
|
|
1731
1871
|
{
|
|
1732
1872
|
VImage mask;
|
|
@@ -2284,6 +2424,18 @@ VImage VImage::niftiload( const char *filename, VOption *options )
|
|
|
2284
2424
|
return( out );
|
|
2285
2425
|
}
|
|
2286
2426
|
|
|
2427
|
+
VImage VImage::niftiload_source( VSource source, VOption *options )
|
|
2428
|
+
{
|
|
2429
|
+
VImage out;
|
|
2430
|
+
|
|
2431
|
+
call( "niftiload_source",
|
|
2432
|
+
(options ? options : VImage::option())->
|
|
2433
|
+
set( "out", &out )->
|
|
2434
|
+
set( "source", source ) );
|
|
2435
|
+
|
|
2436
|
+
return( out );
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2287
2439
|
void VImage::niftisave( const char *filename, VOption *options ) const
|
|
2288
2440
|
{
|
|
2289
2441
|
call( "niftisave",
|
|
@@ -2316,6 +2468,18 @@ VImage VImage::openslideload( const char *filename, VOption *options )
|
|
|
2316
2468
|
return( out );
|
|
2317
2469
|
}
|
|
2318
2470
|
|
|
2471
|
+
VImage VImage::openslideload_source( VSource source, VOption *options )
|
|
2472
|
+
{
|
|
2473
|
+
VImage out;
|
|
2474
|
+
|
|
2475
|
+
call( "openslideload_source",
|
|
2476
|
+
(options ? options : VImage::option())->
|
|
2477
|
+
set( "out", &out )->
|
|
2478
|
+
set( "source", source ) );
|
|
2479
|
+
|
|
2480
|
+
return( out );
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2319
2483
|
VImage VImage::pdfload( const char *filename, VOption *options )
|
|
2320
2484
|
{
|
|
2321
2485
|
VImage out;
|
|
@@ -3388,6 +3552,18 @@ VImage VImage::vipsload( const char *filename, VOption *options )
|
|
|
3388
3552
|
return( out );
|
|
3389
3553
|
}
|
|
3390
3554
|
|
|
3555
|
+
VImage VImage::vipsload_source( VSource source, VOption *options )
|
|
3556
|
+
{
|
|
3557
|
+
VImage out;
|
|
3558
|
+
|
|
3559
|
+
call( "vipsload_source",
|
|
3560
|
+
(options ? options : VImage::option())->
|
|
3561
|
+
set( "out", &out )->
|
|
3562
|
+
set( "source", source ) );
|
|
3563
|
+
|
|
3564
|
+
return( out );
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3391
3567
|
void VImage::vipssave( const char *filename, VOption *options ) const
|
|
3392
3568
|
{
|
|
3393
3569
|
call( "vipssave",
|
|
@@ -3396,6 +3572,14 @@ void VImage::vipssave( const char *filename, VOption *options ) const
|
|
|
3396
3572
|
set( "filename", filename ) );
|
|
3397
3573
|
}
|
|
3398
3574
|
|
|
3575
|
+
void VImage::vipssave_target( VTarget target, VOption *options ) const
|
|
3576
|
+
{
|
|
3577
|
+
call( "vipssave_target",
|
|
3578
|
+
(options ? options : VImage::option())->
|
|
3579
|
+
set( "in", *this )->
|
|
3580
|
+
set( "target", target ) );
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3399
3583
|
VImage VImage::webpload( const char *filename, VOption *options )
|
|
3400
3584
|
{
|
|
3401
3585
|
VImage out;
|
package/src/metadata.cc
CHANGED
|
@@ -90,6 +90,9 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
90
90
|
baton->subifds = image.get_int(VIPS_META_N_SUBIFDS);
|
|
91
91
|
}
|
|
92
92
|
baton->hasProfile = sharp::HasProfile(image);
|
|
93
|
+
if (image.get_typeof("background") == VIPS_TYPE_ARRAY_DOUBLE) {
|
|
94
|
+
baton->background = image.get_array_double("background");
|
|
95
|
+
}
|
|
93
96
|
// Derived attributes
|
|
94
97
|
baton->hasAlpha = sharp::HasAlpha(image);
|
|
95
98
|
baton->orientation = sharp::ExifOrientation(image);
|
|
@@ -209,6 +212,17 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
209
212
|
if (baton->subifds > 0) {
|
|
210
213
|
info.Set("subifds", baton->subifds);
|
|
211
214
|
}
|
|
215
|
+
if (!baton->background.empty()) {
|
|
216
|
+
if (baton->background.size() == 3) {
|
|
217
|
+
Napi::Object background = Napi::Object::New(env);
|
|
218
|
+
background.Set("r", baton->background[0]);
|
|
219
|
+
background.Set("g", baton->background[1]);
|
|
220
|
+
background.Set("b", baton->background[2]);
|
|
221
|
+
info.Set("background", background);
|
|
222
|
+
} else {
|
|
223
|
+
info.Set("background", baton->background[0]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
212
226
|
info.Set("hasProfile", baton->hasProfile);
|
|
213
227
|
info.Set("hasAlpha", baton->hasAlpha);
|
|
214
228
|
if (baton->orientation > 0) {
|
package/src/metadata.h
CHANGED
package/src/operations.cc
CHANGED
|
@@ -112,6 +112,19 @@ namespace sharp {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Produce the "negative" of the image.
|
|
117
|
+
*/
|
|
118
|
+
VImage Negate(VImage image, bool const negateAlpha) {
|
|
119
|
+
if (HasAlpha(image) && !negateAlpha) {
|
|
120
|
+
// Separate alpha channel
|
|
121
|
+
VImage alpha = image[image.bands() - 1];
|
|
122
|
+
return RemoveAlpha(image).invert().bandjoin(alpha);
|
|
123
|
+
} else {
|
|
124
|
+
return image.invert();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
115
128
|
/*
|
|
116
129
|
* Gaussian blur. Use sigma of -1.0 for fast blur.
|
|
117
130
|
*/
|
|
@@ -169,7 +182,8 @@ namespace sharp {
|
|
|
169
182
|
0.0, 0.0, 0.0, 1.0));
|
|
170
183
|
}
|
|
171
184
|
|
|
172
|
-
VImage Modulate(VImage image, double const brightness, double const saturation,
|
|
185
|
+
VImage Modulate(VImage image, double const brightness, double const saturation,
|
|
186
|
+
int const hue, double const lightness) {
|
|
173
187
|
if (HasAlpha(image)) {
|
|
174
188
|
// Separate alpha channel
|
|
175
189
|
VImage alpha = image[image.bands() - 1];
|
|
@@ -177,7 +191,7 @@ namespace sharp {
|
|
|
177
191
|
.colourspace(VIPS_INTERPRETATION_LCH)
|
|
178
192
|
.linear(
|
|
179
193
|
{ brightness, saturation, 1},
|
|
180
|
-
{
|
|
194
|
+
{ lightness, 0.0, static_cast<double>(hue) }
|
|
181
195
|
)
|
|
182
196
|
.colourspace(VIPS_INTERPRETATION_sRGB)
|
|
183
197
|
.bandjoin(alpha);
|
|
@@ -186,7 +200,7 @@ namespace sharp {
|
|
|
186
200
|
.colourspace(VIPS_INTERPRETATION_LCH)
|
|
187
201
|
.linear(
|
|
188
202
|
{ brightness, saturation, 1 },
|
|
189
|
-
{
|
|
203
|
+
{ lightness, 0.0, static_cast<double>(hue) }
|
|
190
204
|
)
|
|
191
205
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
|
192
206
|
}
|
|
@@ -282,4 +296,16 @@ namespace sharp {
|
|
|
282
296
|
return image.linear(a, b);
|
|
283
297
|
}
|
|
284
298
|
}
|
|
299
|
+
|
|
300
|
+
/*
|
|
301
|
+
* Ensure the image is in a given colourspace
|
|
302
|
+
*/
|
|
303
|
+
VImage EnsureColourspace(VImage image, VipsInterpretation colourspace) {
|
|
304
|
+
if (colourspace != VIPS_INTERPRETATION_LAST && image.interpretation() != colourspace) {
|
|
305
|
+
image = image.colourspace(colourspace,
|
|
306
|
+
VImage::option()->set("source_space", image.interpretation()));
|
|
307
|
+
}
|
|
308
|
+
return image;
|
|
309
|
+
}
|
|
310
|
+
|
|
285
311
|
} // namespace sharp
|
package/src/operations.h
CHANGED
|
@@ -45,6 +45,11 @@ namespace sharp {
|
|
|
45
45
|
*/
|
|
46
46
|
VImage Gamma(VImage image, double const exponent);
|
|
47
47
|
|
|
48
|
+
/*
|
|
49
|
+
* Produce the "negative" of the image.
|
|
50
|
+
*/
|
|
51
|
+
VImage Negate(VImage image, bool const negateAlpha);
|
|
52
|
+
|
|
48
53
|
/*
|
|
49
54
|
* Gaussian blur. Use sigma of -1.0 for fast blur.
|
|
50
55
|
*/
|
|
@@ -93,9 +98,15 @@ namespace sharp {
|
|
|
93
98
|
VImage Recomb(VImage image, std::unique_ptr<double[]> const &matrix);
|
|
94
99
|
|
|
95
100
|
/*
|
|
96
|
-
* Modulate brightness, saturation and
|
|
101
|
+
* Modulate brightness, saturation, hue and lightness
|
|
102
|
+
*/
|
|
103
|
+
VImage Modulate(VImage image, double const brightness, double const saturation,
|
|
104
|
+
int const hue, double const lightness);
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* Ensure the image is in a given colourspace
|
|
97
108
|
*/
|
|
98
|
-
VImage
|
|
109
|
+
VImage EnsureColourspace(VImage image, VipsInterpretation colourspace);
|
|
99
110
|
|
|
100
111
|
} // namespace sharp
|
|
101
112
|
|