[vips] Make #remove chainable

Vips::Image#remove removes metadata from a Vips::Image, which can be
useful for reducing filesize of an image or stripping potentially
sensitive data.

Like Vips::Image#set, it isn't chainable by default because the method
doesn't return a Vips::Image instance. Like #set, this commit makes
`#remove` chainable as well.
This commit is contained in:
Janko Marohnić
2018-09-27 01:01:01 +02:00
parent 46e91a1284
commit fcdc623791
4 changed files with 13 additions and 2 deletions
+4
View File
@@ -1,3 +1,7 @@
## HEAD
* [vips] Make `#remove` that's used for removing image metadata chainable (@janko-m)
## 1.7.0 (2018-09-20)
* [vips] `#rotate` now always calls `vips_similarity()` and forwards all options to it (@janko-m)
+1
View File
@@ -264,6 +264,7 @@ ImageProcessing::Vips
.crop(0, 0, 300, 300)
.invert
.set("icc-profile-data", custom_profile)
.remove("xmp-data")
.gaussblur(2)
# ...
```
+2 -1
View File
@@ -112,10 +112,11 @@ module ImageProcessing
image.composite(overlay, mode, **options)
end
# make Vips::Image#set, #set_type, and #set_value chainable
# make Vips::Image#set, #set_type, #set_value, and #move chainable
def set(*args) image.tap { |img| img.set(*args) } end
def set_type(*args) image.tap { |img| img.set_type(*args) } end
def set_value(*args) image.tap { |img| img.set_value(*args) } end
def remove(*args) image.tap { |img| img.remove(*args) } end
private
+6 -1
View File
@@ -30,13 +30,18 @@ describe "ImageProcessing::Vips" do
assert_similar expected, actual
end
it "applies setting metadata" do
it "allows changing metadata" do
image = ImageProcessing::Vips
.copy
.set("icc-profile-data", "foobar")
.set_type(Vips::BLOB_TYPE, "foo", "bar")
.remove("exif-data")
.call(@portrait, save: false)
assert_equal "foobar", image.get("icc-profile-data")
assert_equal "bar", image.get("foo")
assert_raises(Vips::Error) { image.get("exif-data") }
end
it "applies format" do