mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Upgrade to libvips v8.12.0-rc1
This commit is contained in:
parent
1ff84b20b7
commit
079bd7b9f5
@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## v0.30 - *dresser*
|
||||
|
||||
Requires libvips v8.12.0
|
||||
|
||||
### v0.30.0 - TBD
|
||||
|
||||
* Reduce minimum Linux ARM64v8 glibc requirement to 2.17.
|
||||
|
||||
## v0.29 - *circle*
|
||||
|
||||
Requires libvips v8.11.3
|
||||
|
@ -18,7 +18,7 @@ const platform = require('../lib/platform');
|
||||
|
||||
const minimumGlibcVersionByArch = {
|
||||
arm: '2.28',
|
||||
arm64: '2.29',
|
||||
arm64: '2.17',
|
||||
x64: '2.17'
|
||||
};
|
||||
|
||||
@ -120,7 +120,7 @@ try {
|
||||
}
|
||||
|
||||
// Download to per-process temporary file
|
||||
const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.br';
|
||||
const tarFilename = ['libvips', minimumLibvipsVersionLabelled, platformAndArch].join('-') + '.tar.br';
|
||||
const tarPathCache = path.join(libvips.cachePath(), tarFilename);
|
||||
if (fs.existsSync(tarPathCache)) {
|
||||
libvips.log(`Using cached ${tarPathCache}`);
|
||||
|
@ -150,7 +150,7 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"config": {
|
||||
"libvips": "8.11.3",
|
||||
"libvips": "8.12.0-rc1",
|
||||
"runtime": "napi",
|
||||
"target": 5
|
||||
},
|
||||
|
@ -25,9 +25,9 @@
|
||||
// Verify platform and compiler compatibility
|
||||
|
||||
#if (VIPS_MAJOR_VERSION < 8) || \
|
||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 11) || \
|
||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 11 && VIPS_MICRO_VERSION < 3)
|
||||
#error "libvips version 8.11.3+ is required - please see https://sharp.pixelplumbing.com/install"
|
||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 12) || \
|
||||
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 12 && VIPS_MICRO_VERSION < 0)
|
||||
#error "libvips version 8.12.0+ is required - please see https://sharp.pixelplumbing.com/install"
|
||||
#endif
|
||||
|
||||
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
||||
|
@ -93,7 +93,7 @@ negate( std::vector<double> vector )
|
||||
{
|
||||
std::vector<double> new_vector( vector.size() );
|
||||
|
||||
for( unsigned int i = 0; i < vector.size(); i++ )
|
||||
for( std::vector<double>::size_type i = 0; i < vector.size(); i++ )
|
||||
new_vector[i] = vector[i] * -1;
|
||||
|
||||
return( new_vector );
|
||||
@ -104,7 +104,7 @@ invert( std::vector<double> vector )
|
||||
{
|
||||
std::vector<double> new_vector( vector.size() );
|
||||
|
||||
for( unsigned int i = 0; i < vector.size(); i++ )
|
||||
for( std::vector<double>::size_type i = 0; i < vector.size(); i++ )
|
||||
new_vector[i] = 1.0 / vector[i];
|
||||
|
||||
return( new_vector );
|
||||
@ -210,7 +210,6 @@ VOption::set( const char *name, std::vector<int> value )
|
||||
Pair *pair = new Pair( name );
|
||||
|
||||
int *array;
|
||||
unsigned int i;
|
||||
|
||||
pair->input = true;
|
||||
|
||||
@ -219,7 +218,7 @@ VOption::set( const char *name, std::vector<int> value )
|
||||
static_cast< int >( value.size() ) );
|
||||
array = vips_value_get_array_int( &pair->value, NULL );
|
||||
|
||||
for( i = 0; i < value.size(); i++ )
|
||||
for( std::vector<double>::size_type i = 0; i < value.size(); i++ )
|
||||
array[i] = value[i];
|
||||
|
||||
options.push_back( pair );
|
||||
@ -234,7 +233,6 @@ VOption::set( const char *name, std::vector<double> value )
|
||||
Pair *pair = new Pair( name );
|
||||
|
||||
double *array;
|
||||
unsigned int i;
|
||||
|
||||
pair->input = true;
|
||||
|
||||
@ -243,7 +241,7 @@ VOption::set( const char *name, std::vector<double> value )
|
||||
static_cast< int >( value.size() ) );
|
||||
array = vips_value_get_array_double( &pair->value, NULL );
|
||||
|
||||
for( i = 0; i < value.size(); i++ )
|
||||
for( std::vector<double>::size_type i = 0; i < value.size(); i++ )
|
||||
array[i] = value[i];
|
||||
|
||||
options.push_back( pair );
|
||||
@ -258,7 +256,6 @@ VOption::set( const char *name, std::vector<VImage> value )
|
||||
Pair *pair = new Pair( name );
|
||||
|
||||
VipsImage **array;
|
||||
unsigned int i;
|
||||
|
||||
pair->input = true;
|
||||
|
||||
@ -267,7 +264,7 @@ VOption::set( const char *name, std::vector<VImage> value )
|
||||
static_cast< int >( value.size() ) );
|
||||
array = vips_value_get_array_image( &pair->value, NULL );
|
||||
|
||||
for( i = 0; i < value.size(); i++ ) {
|
||||
for( std::vector<double>::size_type i = 0; i < value.size(); i++ ) {
|
||||
VipsImage *vips_image = value[i].get_image();
|
||||
|
||||
array[i] = vips_image;
|
||||
@ -488,10 +485,9 @@ VOption::get_operation( VipsOperation *operation )
|
||||
double *array =
|
||||
vips_value_get_array_double( value,
|
||||
&length );
|
||||
int j;
|
||||
|
||||
((*i)->vvector)->resize( length );
|
||||
for( j = 0; j < length; j++ )
|
||||
for( int j = 0; j < length; j++ )
|
||||
(*((*i)->vvector))[j] = array[j];
|
||||
}
|
||||
else if( type == VIPS_TYPE_BLOB ) {
|
||||
@ -718,16 +714,37 @@ VImage::write_to_buffer( const char *suffix, void **buf, size_t *size,
|
||||
const char *operation_name;
|
||||
VipsBlob *blob;
|
||||
|
||||
/* Save with the new target API if we can. Fall back to the older
|
||||
* mechanism in case the saver we need has not been converted yet.
|
||||
*
|
||||
* We need to hide any errors from this first phase.
|
||||
*/
|
||||
vips__filename_split8( suffix, filename, option_string );
|
||||
if( !(operation_name = vips_foreign_find_save_buffer( filename )) ) {
|
||||
delete options;
|
||||
throw VError();
|
||||
}
|
||||
|
||||
vips_error_freeze();
|
||||
operation_name = vips_foreign_find_save_target( filename );
|
||||
vips_error_thaw();
|
||||
|
||||
if( operation_name ) {
|
||||
VTarget target = VTarget::new_to_memory();
|
||||
|
||||
call_option_string( operation_name, option_string,
|
||||
(options ? options : VImage::option())->
|
||||
set( "in", *this )->
|
||||
set( "target", target ) );
|
||||
|
||||
g_object_get( target.get_target(), "blob", &blob, NULL );
|
||||
}
|
||||
else if( (operation_name = vips_foreign_find_save_buffer( filename )) ) {
|
||||
call_option_string( operation_name, option_string,
|
||||
(options ? options : VImage::option())->
|
||||
set( "in", *this )->
|
||||
set( "buffer", &blob ) );
|
||||
}
|
||||
else {
|
||||
delete options;
|
||||
throw VError();
|
||||
}
|
||||
|
||||
if( blob ) {
|
||||
if( buf ) {
|
||||
@ -767,6 +784,7 @@ std::vector<VImage>
|
||||
VImage::bandsplit( VOption *options ) const
|
||||
{
|
||||
std::vector<VImage> b;
|
||||
b.reserve(bands());
|
||||
|
||||
for( int i = 0; i < bands(); i++ )
|
||||
b.push_back( extract_band( i ) );
|
||||
|
@ -1,5 +1,5 @@
|
||||
// bodies for vips operations
|
||||
// Wed May 12 11:30:00 AM CEST 2021
|
||||
// Mon Nov 1 03:31:09 PM CET 2021
|
||||
// this file is generated automatically, do not edit!
|
||||
|
||||
VImage VImage::CMC2LCh( VOption *options ) const
|
||||
@ -1262,6 +1262,34 @@ VImage VImage::gifload_source( VSource source, VOption *options )
|
||||
return( out );
|
||||
}
|
||||
|
||||
void VImage::gifsave( const char *filename, VOption *options ) const
|
||||
{
|
||||
call( "gifsave",
|
||||
(options ? options : VImage::option())->
|
||||
set( "in", *this )->
|
||||
set( "filename", filename ) );
|
||||
}
|
||||
|
||||
VipsBlob *VImage::gifsave_buffer( VOption *options ) const
|
||||
{
|
||||
VipsBlob *buffer;
|
||||
|
||||
call( "gifsave_buffer",
|
||||
(options ? options : VImage::option())->
|
||||
set( "in", *this )->
|
||||
set( "buffer", &buffer ) );
|
||||
|
||||
return( buffer );
|
||||
}
|
||||
|
||||
void VImage::gifsave_target( VTarget target, VOption *options ) const
|
||||
{
|
||||
call( "gifsave_target",
|
||||
(options ? options : VImage::option())->
|
||||
set( "in", *this )->
|
||||
set( "target", target ) );
|
||||
}
|
||||
|
||||
VImage VImage::globalbalance( VOption *options ) const
|
||||
{
|
||||
VImage out;
|
||||
|
@ -180,6 +180,8 @@ class MetadataWorker : public Napi::AsyncWorker {
|
||||
}
|
||||
if (baton->pageHeight > 0) {
|
||||
info.Set("pageHeight", baton->pageHeight);
|
||||
} else if (baton->pages > 0) {
|
||||
info.Set("pageHeight", baton->height);
|
||||
}
|
||||
if (baton->loop >= 0) {
|
||||
info.Set("loop", baton->loop);
|
||||
|
BIN
test/fixtures/expected/composite-cutout.png
vendored
BIN
test/fixtures/expected/composite-cutout.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 175 KiB After Width: | Height: | Size: 180 KiB |
BIN
test/fixtures/expected/median_1.jpg
vendored
BIN
test/fixtures/expected/median_1.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
BIN
test/fixtures/expected/median_3.jpg
vendored
BIN
test/fixtures/expected/median_3.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 833 B |
BIN
test/fixtures/expected/median_5.jpg
vendored
BIN
test/fixtures/expected/median_5.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 640 B |
BIN
test/fixtures/expected/median_color.jpg
vendored
BIN
test/fixtures/expected/median_color.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
@ -247,7 +247,7 @@ describe('composite', () => {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(300, 300)
|
||||
.composite([{
|
||||
input: Buffer.from('<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'),
|
||||
input: Buffer.from('<svg width="200" height="200"><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'),
|
||||
density: 96,
|
||||
blend: 'dest-in',
|
||||
cutout: true
|
||||
|
@ -5,68 +5,46 @@ const assert = require('assert');
|
||||
const sharp = require('../../');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('Median filter', function () {
|
||||
it('1x1 window', function (done) {
|
||||
sharp(fixtures.inputJpgThRandom)
|
||||
describe('Median filter', () => {
|
||||
it('1x1 window', async () => {
|
||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
||||
.median(1)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('median_1.jpg'), data, done);
|
||||
});
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.deepStrictEqual({ r: 0, g: 0, b: 0 }, { r, g, b });
|
||||
});
|
||||
|
||||
it('3x3 window', function (done) {
|
||||
sharp(fixtures.inputJpgThRandom)
|
||||
it('3x3 window', async () => {
|
||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
||||
.median(3)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('median_3.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
it('5x5 window', function (done) {
|
||||
sharp(fixtures.inputJpgThRandom)
|
||||
.median(5)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('median_5.jpg'), data, done);
|
||||
});
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.deepStrictEqual({ r: 255, g: 0, b: 127 }, { r, g, b });
|
||||
});
|
||||
|
||||
it('color image', function (done) {
|
||||
sharp(fixtures.inputJpgRandom)
|
||||
.median(5)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('median_color.jpg'), data, done);
|
||||
});
|
||||
it('7x7 window', async () => {
|
||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
||||
.median(7)
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.deepStrictEqual({ r: 255, g: 19, b: 146 }, { r, g, b });
|
||||
});
|
||||
|
||||
it('no windows size', function (done) {
|
||||
sharp(fixtures.inputJpgThRandom)
|
||||
.median()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('median_3.jpg'), data, done);
|
||||
it('default window (3x3)', async () => {
|
||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
||||
.median(3)
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
assert.deepStrictEqual({ r: 255, g: 0, b: 127 }, { r, g, b });
|
||||
});
|
||||
});
|
||||
it('invalid radius', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg).median(0.1);
|
||||
|
||||
it('invalid radius', () => {
|
||||
assert.throws(() => {
|
||||
sharp().median(0.1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user