From b3ad0d665ff829c6549f931ce333f21eb6268859 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 27 Oct 2021 14:44:26 +0100 Subject: [PATCH 1/2] add support for format_string and a version bump see https://github.com/libvips/libvips/pull/2499 --- CHANGELOG.md | 5 +++++ VERSION | 2 +- lib/vips/image.rb | 14 ++++++++++++-- lib/vips/version.rb | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fdacec..95f0d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## master +## Version 2.1.4 (2021-10-27) + +* add support for `format_string`, so buffer and target savers are better at + writing the correct format [jcupitt] + ## Version 2.1.3 (2021-8-23) * fix a gtype size error on win64 [danini-the-panini] diff --git a/VERSION b/VERSION index ac2cdeb..7d2ed7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.3 +2.1.4 diff --git a/lib/vips/image.rb b/lib/vips/image.rb index 1b800d1..9cf8484 100644 --- a/lib/vips/image.rb +++ b/lib/vips/image.rb @@ -626,7 +626,12 @@ def write_to_buffer format_string, **opts saver = Vips.vips_foreign_find_save_buffer filename raise Vips::Error if saver.nil? - buffer = Vips::Operation.call saver, [self], opts, option_string + # note the format_string for savers + image = self.mutate do |x| + x.set_type! Vips::REFSTR_TYPE, "format_string", format_string + end + + buffer = Vips::Operation.call saver, [image], opts, option_string raise Vips::Error if buffer.nil? write_gc @@ -667,7 +672,12 @@ def write_to_target target, format_string, **opts saver = Vips.vips_foreign_find_save_target filename raise Vips::Error if saver.nil? - Vips::Operation.call saver, [self, target], opts, option_string + # note the format_string for savers + image = self.mutate do |x| + x.set_type! Vips::REFSTR_TYPE, "format_string", format_string + end + + Vips::Operation.call saver, [image, target], opts, option_string write_gc end diff --git a/lib/vips/version.rb b/lib/vips/version.rb index efc5ffb..d1f9890 100644 --- a/lib/vips/version.rb +++ b/lib/vips/version.rb @@ -1,3 +1,3 @@ module Vips - VERSION = "2.1.3" + VERSION = "2.1.4" end From 1a43ca0be4419b08ee442ed4076819fa77532114 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 27 Oct 2021 15:40:53 +0100 Subject: [PATCH 2/2] switch to format-string --- lib/vips/image.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vips/image.rb b/lib/vips/image.rb index 9cf8484..6bc948b 100644 --- a/lib/vips/image.rb +++ b/lib/vips/image.rb @@ -628,7 +628,7 @@ def write_to_buffer format_string, **opts # note the format_string for savers image = self.mutate do |x| - x.set_type! Vips::REFSTR_TYPE, "format_string", format_string + x.set_type! Vips::REFSTR_TYPE, "format-string", format_string end buffer = Vips::Operation.call saver, [image], opts, option_string @@ -674,7 +674,7 @@ def write_to_target target, format_string, **opts # note the format_string for savers image = self.mutate do |x| - x.set_type! Vips::REFSTR_TYPE, "format_string", format_string + x.set_type! Vips::REFSTR_TYPE, "format-string", format_string end Vips::Operation.call saver, [image, target], opts, option_string