$: << "../../libmetadata-jpeg-ruby/lib"
$: << "../../rdf/lib"

require 'metadata-jpeg'
require 'metadata.com-jpeg'

require 'rdfpic'

module Zoy
    module Rdf
        # this is a JPEG File that might contains RDF data inside
        class RichImage
            include Zoy::Jpeg
            include Zoy::Rdf
           
            attr_reader :rdf_data
            attr_reader :normal_comments
            attr_reader :jpeg_image
            def initialize(name)
                @filename = name
                @jpeg_image = nil
                @rdf_data = Array.new
                @normal_comments = Array.new
            end
            def load
                @jpeg_image = Image.new()
                @jpeg_image.load_from_file(@filename)
                
                if @jpeg_image.comment != nil
                    @jpeg_image.comment.each do |comment|
                        rdf_comment = ReadableImageString.new(comment.to_s)
                        if rdf_comment.valid?
                            @rdf_data << rdf_comment
                        else
                            @normal_comments << comment.to_s
                        end
                    end
                end
            end
            def valid?
                return true if @rdf_data.length > 0
                return false
            end

        end
    end
end

