Module: Cul::Scv::Hydra::Models::ImageResource
- Included in:
- GenericResource, Resource
- Defined in:
- app/models/concerns/cul/scv/hydra/models/image_resource.rb
Constant Summary collapse
- IMAGE_EXT =
{"image/bmp" => 'bmp', "image/gif" => 'gif', "image/jpeg" => 'jpg', "image/png" => 'png', "image/tiff" => 'tif', "image/x-windows-bmp" => 'bmp', 'image/jp2' => 'jp2'}
- WIDTH =
RDF::URI(ActiveFedora::Predicates.find_graph_predicate(:image_width))
- LENGTH =
RDF::URI(ActiveFedora::Predicates.find_graph_predicate(:image_length))
- WIDTH_PREDICATE =
ActiveFedora::Predicates.short_predicate("http://www.w3.org/2003/12/exif/ns#imageWidth").to_s
- LENGTH_PREDICATE =
ActiveFedora::Predicates.short_predicate("http://www.w3.org/2003/12/exif/ns#imageLength").to_s
- EXTENT_PREDICATE =
ActiveFedora::Predicates.short_predicate("http://purl.org/dc/terms/extent").to_s
- FORMAT_OF_PREDICATE =
ActiveFedora::Predicates.short_predicate("http://purl.org/dc/terms/isFormatOf").to_s
- FORMAT_URI =
RDF::URI("http://purl.org/dc/terms/format")
- DJATOKA_THUMBNAIL_PARMS =
{ "url_ver" => "Z39.88-2004", "svc_id" => "info:lanl-repo/svc/getRegion", "svc_val_fmt" => "info:ofi/fmt:kev:mtx:jpeg2000", "svc.format" => "image/jpeg", "svc.level" => "", "svc.rotate" => "0", "svc.scale" => "200", "svc.clayers" => "" }
- DJATOKA_BASE_URL =
"http://iris.cul.columbia.edu:8888/resolve"
Instance Method Summary collapse
Instance Method Details
#length ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/concerns/cul/scv/hydra/models/image_resource.rb', line 40 def length @length ||= begin ds = datastreams["content"] length = 0 unless ds.nil? or rels_int.relationships(ds,:exif_image_length).blank? length = rels_int.relationships(ds,:exif_image_length).first.object.to_s.to_i end length = relationships(:image_length).first.to_s.to_i if length == 0 length end end |
#long ⇒ Object
24 25 26 |
# File 'app/models/concerns/cul/scv/hydra/models/image_resource.rb', line 24 def long @long_side ||= max(width(), length()) end |
#thumbnail_info ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/models/concerns/cul/scv/hydra/models/image_resource.rb', line 63 def thumbnail_info thumb = rels_int.relationships(datastreams['content'],:foaf_thumbnail).first if thumb t_dsid = thumb.object.to_s.split('/')[-1] t_url = "#{ActiveFedora.fedora_config.credentials[:url]}/objects/#{pid}/datastreams/#{t_dsid}/content" return {:url=>t_url,:mime=>datastreams[t_dsid].mimeType} elsif (zoom = self.zooming?) t_dsid = zoom.split('/')[-1] t_parms = DJATOKA_THUMBNAIL_PARMS.merge({"rft_id" => datastreams[t_dsid].dsLocation}) url = "#{DJATOKA_BASE_URL}?#{.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }" {:url => url, :mime => t_parms["svc.format"]} else return {:asset=>"cul_scv_hydra/crystal/file.png",:mime=>'image/png'} end end |
#width ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/concerns/cul/scv/hydra/models/image_resource.rb', line 28 def width @width ||= begin ds = datastreams["content"] width = 0 unless ds.nil? or rels_int.relationships(ds,:exif_image_width).blank? width = rels_int.relationships(ds,:exif_image_width).first.object.to_s.to_i end width = relationships(:image_width).first.to_s.to_i if width == 0 width end end |
#zooming? ⇒ Boolean
52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/concerns/cul/scv/hydra/models/image_resource.rb', line 52 def zooming? zoom = rels_int.relationships(datastreams['content'],:foaf_zooming).first return zoom.object.to_s if zoom datastreams.each do |k,v| if v.mimeType =~ /image\/jp2$/i zoom = "info:fedora/#{k.dsid}" end end return zoom end |