Sha256: 48b4590e2620a0a029c8a75d7760b7379e22f741bb4fe8d78680df5ed4246f0d

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

# GenericImage
#
# Default content datastreams: content, original (optional), max, thumbnail, screen
#
# Sample Usages:
#  From file:
#   my_image = File.new("#{Rails.root}/spec/fixtures/image.tiff")
#   gi = GenericImage.new
#   gi.content=my_image
#   gi.save
#
#  From url:
#   my_image = "http://example.com/path/to/some/image.jpeg"
#   gi = HydraImage.new
#   gi.content=my_image
#
#  From binary string:
#    my_image = File.open("#{Rails.root}/spec/fixtures/image.tiff")
#    my_blob = my_image.read
#    gi = HydraImage.new
#    gi.content={ :blob=> my_blob, :extension => ".tiff" }
#
#  To create the derived images:
#    gi.derive_all # creates max, screen and thumbnail from content datastream
#    gi.derive_max
#    gi.derive_screen
#    gi.derive_thumbnail
#
#  To get the content of a default datastream:
#    max = gi.max
#    screen = gi.screen
#    thumbnail = gi.thumbnail
#
#  To determine if a particular datastream exists for an image:
#    gi.has_content?
#    gi.has_original?
#    gi.has_max?
#    gi.has_screen?
#    gi.has_thumbnail?
require 'hydra'

class GenericImage < ActiveFedora::Base
  include Hydra::GenericImage
  include Hydra::ModelMethods
  
  # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
  has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata 

  has_metadata :name => "descMetadata", :type => Hydra::ModsImage
  
  # A place to put extra metadata values
  has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
    m.field 'collection', :string
    m.field 'depositor', :string
    m.field 'title', :string
  end
  
  def initialize( attrs={} )
    super
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-head-3.0.0pre3 app/models/generic_image.rb
hydra-head-3.0.0pre2 app/models/generic_image.rb
hydra-head-3.0.0pre1 app/models/generic_image.rb