You've already forked image_processing
mirror of
https://github.com/usetrmnl/image_processing.git
synced 2026-04-29 13:33:11 -07:00
[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:
@@ -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)
|
||||
|
||||
@@ -264,6 +264,7 @@ ImageProcessing::Vips
|
||||
.crop(0, 0, 300, 300)
|
||||
.invert
|
||||
.set("icc-profile-data", custom_profile)
|
||||
.remove("xmp-data")
|
||||
.gaussblur(2)
|
||||
# ...
|
||||
```
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user