Module: Cul::Image::Properties
- Defined in:
- lib/cul_image_props.rb,
lib/cul_image_props/image/properties.rb,
lib/cul_image_props/image/properties/exif.rb,
lib/cul_image_props/image/properties/types.rb,
lib/cul_image_props/image/properties/version.rb,
lib/cul_image_props/image/properties/exif/types.rb,
lib/cul_image_props/image/properties/exif/constants.rb
Defined Under Namespace
Modules: BigEndian, Exif, LittleEndian Classes: Base, Bmp, Gif, Jpeg, Namespace, Png, Tiff
Constant Summary collapse
- ASSESS =
Namespace.new("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/ASSESSMENT/","si-assess")
- BASIC =
Namespace.new("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/","si-basic")
- DCMI =
Namespace.new("http://purl.org/dc/terms/","dcmi")
- VERSION =
"0.2.3"
Class Method Summary collapse
Class Method Details
.identify(src) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cul_image_props/image/properties.rb', line 9 def self.identify(src) if src.is_a? String src = open(src) end filesize = src.stat.size result = nil magic_bytes = '' buf = '' src.read(2,buf) magic_bytes << buf case magic_bytes.unpack('C*') when Cul::Image::Magic::BMP result = Cul::Image::Properties::Bmp.new(src) when Cul::Image::Magic::JPEG result = Cul::Image::Properties::Jpeg.new(src) end if result.nil? src.read(2,buf) magic_bytes << buf case magic_bytes.unpack('C*') when Cul::Image::Magic::TIFF_MOTOROLA_BE result = Cul::Image::Properties::Tiff.new(src) when Cul::Image::Magic::TIFF_INTEL_LE result = Cul::Image::Properties::Tiff.new(src) when Cul::Image::Magic::GIF result = Cul::Image::Properties::Gif.new(src) end end if result.nil? src.read(4,buf) magic_bytes << buf if magic_bytes.unpack('C*') == Cul::Image::Magic::PNG result = Cul::Image::Properties::Png.new(src) else puts "Unknown magic bytes: " + magic_bytes.unpack('H2H2H2H2H2H2H2H2').inspect end end return result end |
.version ⇒ Object
6 7 8 |
# File 'lib/cul_image_props.rb', line 6 def self.version Cul::Image::Properties::VERSION end |