File tree 5 files changed +13
-4
lines changed
5 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
name : greitspitz
2
- version : 0.2.0
2
+ version : 0.2.1
3
3
license : MIT
4
4
dependencies :
5
5
awscr-s3 :
Original file line number Diff line number Diff line change @@ -162,4 +162,12 @@ describe Greitspitz::Transformer do
162
162
image = Vips ::Image .new_from_buffer(output)
163
163
image.get_fields.includes?(" exif-ifd0-Model" ).should be_false
164
164
end
165
+
166
+ it " transforms a PNG" do
167
+ image = Spec .transform_image(" fit:40x40" , extension: " .png" )
168
+ image.width.should eq(40 )
169
+ image.height.should eq(40 )
170
+ content_type = ` file --mime-type #{ image.filename } ` .split(" :" ).last.strip
171
+ content_type.should eq(" image/jpeg" )
172
+ end
165
173
end
Original file line number Diff line number Diff line change @@ -75,9 +75,9 @@ module Spec
75
75
end
76
76
end
77
77
78
- def self.transform_image (instructions : String )
78
+ def self.transform_image (instructions : String , extension = " .jpg " )
79
79
temporary_filename = Spec .generate_tmp_filename
80
- File .open(Spec .root.join(" spec/files/small.jpg " ), " rb" ) do |input |
80
+ File .open(Spec .root.join(" spec/files/small#{ extension } " ), " rb" ) do |input |
81
81
File .open(temporary_filename, " wb" ) do |output |
82
82
Greitspitz ::Transformer .new(input, Greitspitz ::Instructions .new(instructions)).write(output)
83
83
end
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ module Greitspitz
21
21
end
22
22
23
23
def write (output : IO )
24
- image = Vips ::Image .new_from_buffer(@input , autorotate: true )
24
+ image = Vips ::Image .new_from_buffer(@input )
25
+ image, _angle, _flip = image.autorot
25
26
image = image.colourspace(Vips ::Enums ::Interpretation ::Srgb )
26
27
@instructions .transformations.each do |name , value |
27
28
case name
You can’t perform that action at this time.
0 commit comments