Skip to content

Commit 2aa8525

Browse files
authored
Merge pull request #24 from Fingertips/manfred-23-support-no-autorotate
Don't autorotate PNG and GIF images
2 parents ed2c108 + 1a97176 commit 2aa8525

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

Diff for: shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: greitspitz
2-
version: 0.2.0
2+
version: 0.2.1
33
license: MIT
44
dependencies:
55
awscr-s3:

Diff for: spec/cases/transformer_spec.cr

+8
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,12 @@ describe Greitspitz::Transformer do
162162
image = Vips::Image.new_from_buffer(output)
163163
image.get_fields.includes?("exif-ifd0-Model").should be_false
164164
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
165173
end

Diff for: spec/files/small.png

7.13 KB
Loading

Diff for: spec/spec_helper.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ module Spec
7575
end
7676
end
7777

78-
def self.transform_image(instructions : String)
78+
def self.transform_image(instructions : String, extension = ".jpg")
7979
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|
8181
File.open(temporary_filename, "wb") do |output|
8282
Greitspitz::Transformer.new(input, Greitspitz::Instructions.new(instructions)).write(output)
8383
end

Diff for: src/greitspitz/transformer.cr

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module Greitspitz
2121
end
2222

2323
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
2526
image = image.colourspace(Vips::Enums::Interpretation::Srgb)
2627
@instructions.transformations.each do |name, value|
2728
case name

0 commit comments

Comments
 (0)