lib/dynamic_image/model.rb in dynamic_image-2.0.0 vs lib/dynamic_image/model.rb in dynamic_image-2.0.1
- old
+ new
@@ -68,21 +68,21 @@
before_validation :read_image_metadata, if: :data_changed?
end
# Returns true if the image is in the CMYK colorspace
def cmyk?
- colorspace == "cmyk"
+ colorspace == 'cmyk'
end
# Returns true if the image is in the grayscale colorspace
def gray?
- colorspace == "gray"
+ colorspace == 'gray'
end
# Returns true if the image is in the RGB colorspace
def rgb?
- colorspace == "rgb"
+ colorspace == 'rgb'
end
# Finds a web safe content type. GIF, JPEG and PNG images are allowed,
# any other formats should be converted to JPEG.
def safe_content_type
@@ -100,31 +100,30 @@
end
private
def read_image_metadata
- metadata = DynamicImage::Metadata.new(self.data)
+ metadata = DynamicImage::Metadata.new(data)
+ @valid_image = false
if metadata.valid?
self.colorspace = metadata.colorspace
self.real_width = metadata.width
self.real_height = metadata.height
self.content_type = metadata.content_type
@valid_image = true
- else
- @valid_image = false
end
true
end
def valid_image?
@valid_image ? true : false
end
def safe_content_types
- %w{
+ %w(
image/png
image/gif
image/jpeg
- }
+ )
end
end
-end
\ No newline at end of file
+end