Skip to content

Commit 1c9befb

Browse files
committed
perf: replace tempfile round-trip with write_to_buffer
1 parent f93952e commit 1c9befb

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/dynamic_image/image_processor.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ def convert(new_format)
4949

5050
# Returns the image data as a binary string.
5151
def read
52-
tempfile = Tempfile.new(["dynamic_image", target_format.extension],
53-
binmode: true)
54-
tempfile.close
55-
write(tempfile.path)
56-
tempfile.open
57-
tempfile.read
58-
ensure
59-
tempfile.close
52+
image.write_to_buffer(target_format.extension,
53+
**target_format.save_options)
6054
end
6155

6256
# Returns the image size as a Vector2d.

0 commit comments

Comments
 (0)