Skip to content

Commit

Permalink
Applied patch from Christoph Lupprich to correct file handling in cor…
Browse files Browse the repository at this point in the history
  • Loading branch information
crafterm committed May 22, 2008
1 parent 61ad36f commit 834553a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -44,6 +44,9 @@ def resize_image(img, size)
processor.render do |result|
self.width = result.extent.size.width if respond_to?(:width)
self.height = result.extent.size.height if respond_to?(:height)

# Get a new temp_path for the image before saving
self.temp_path = Tempfile.new(random_tempfile_filename, Technoweenie::AttachmentFu.tempfile_path).path
result.save self.temp_path, OSX::NSJPEGFileType
self.size = File.size(self.temp_path)
end
Expand Down
6 changes: 6 additions & 0 deletions test/processors/core_image_test.rb
Expand Up @@ -22,6 +22,12 @@ def test_should_resize_image
# test geometry string
assert_equal 31, geo.width
assert_equal 41, geo.height

# This makes sure that we didn't overwrite the original file
# and will end up with a thumbnail instead of the original
assert_equal 42, attachment.width
assert_equal 55, attachment.height

end
else
def test_flunk
Expand Down

0 comments on commit 834553a

Please sign in to comment.