fix unclosed files
windows doesn't like them
This commit is contained in:
@@ -52,9 +52,11 @@ class Advertisement < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
File.chmod(0644, image_path)
|
File.chmod(0644, image_path)
|
||||||
image_size = ImageSize.new(File.open(image_path, "rb"))
|
File.open(image_path, "rb") do |file|
|
||||||
self.width = image_size.get_width
|
image_size = ImageSize.new(file.read)
|
||||||
self.height = image_size.get_height
|
self.width = image_size.get_width
|
||||||
|
self.height = image_size.get_height
|
||||||
|
end
|
||||||
|
|
||||||
if width > height
|
if width > height
|
||||||
self.ad_type = "horizontal"
|
self.ad_type = "horizontal"
|
||||||
|
|||||||
@@ -172,9 +172,11 @@ class Upload < ActiveRecord::Base
|
|||||||
module DimensionMethods
|
module DimensionMethods
|
||||||
# Figures out the dimensions of the image.
|
# Figures out the dimensions of the image.
|
||||||
def calculate_dimensions(file_path)
|
def calculate_dimensions(file_path)
|
||||||
image_size = ImageSize.new(File.open(file_path, "rb"))
|
File.open(file_path, "rb") do |file|
|
||||||
self.image_width = image_size.get_width
|
image_size = ImageSize.new(file.read)
|
||||||
self.image_height = image_size.get_height
|
self.image_width = image_size.get_width
|
||||||
|
self.image_height = image_size.get_height
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_dimension_tags!
|
def add_dimension_tags!
|
||||||
|
|||||||
Reference in New Issue
Block a user