Skip to content

Commit

Permalink
Upgrade to libvips v8.12.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Nov 16, 2021
1 parent 1ff84b2 commit 079bd7b
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 77 deletions.
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions install/libvips.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const platform = require('../lib/platform');

const minimumGlibcVersionByArch = {
arm: '2.28',
arm64: '2.29',
arm64: '2.17',
x64: '2.17'
};

Expand Down Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
},
"license": "Apache-2.0",
"config": {
"libvips": "8.11.3",
"libvips": "8.12.0-rc1",
"runtime": "napi",
"target": 5
},
Expand Down
6 changes: 3 additions & 3 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
50 changes: 34 additions & 16 deletions src/libvips/cplusplus/VImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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;

Expand All @@ -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 );
Expand All @@ -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;

Expand All @@ -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 );
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -718,17 +714,38 @@ 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 )) ) {

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();
}

call_option_string( operation_name, option_string,
(options ? options : VImage::option())->
set( "in", *this )->
set( "buffer", &blob ) );

if( blob ) {
if( buf ) {
*buf = VIPS_AREA( blob )->data;
Expand Down Expand Up @@ -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 ) );
Expand Down
30 changes: 29 additions & 1 deletion src/libvips/cplusplus/vips-operators.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file modified test/fixtures/expected/composite-cutout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed test/fixtures/expected/median_1.jpg
Binary file not shown.
Binary file removed test/fixtures/expected/median_3.jpg
Binary file not shown.
Binary file removed test/fixtures/expected/median_5.jpg
Binary file not shown.
Binary file removed test/fixtures/expected/median_color.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion test/unit/composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
84 changes: 31 additions & 53 deletions test/unit/median.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit 079bd7b

Please sign in to comment.