Beispiel #1
0
 def add_imageuri(self, uri, image):
     
     """ 
         Adds an Imageuri object to a Image Object
     """ 
 
     global ns_ma
     try:
         imageuri = Imageuri.get(uri=uri)
         if imageuri.image == image:
             return False       
     except Imageuri.DoesNotExist:
         imageuri = Imageuri.create(
             image=image,
             uri=uri,
         )
         imageuri.save()
         try: 
             imagefrag = ImageFragment.get(x=0, y=0, image=image)
             urimeta = self.add_metadata(imagefrag, ns_ma)
             self.add_annotation(urimeta, "relation", uri)
             return True
         except ImageFragment.DoesNotExist:
             return False
         return True
Beispiel #2
0
 def add_fragment(self, image, coordinates):
 
     """ Add a fragment to an image instance requiring
         coordinates with first value as x and second value as y
     """ 
     
     try:
         imgfrag = ImageFragment.get(image=image, x=coordinates[0], y=coordinates[1], visible=True)
         return imgfrag
     except ImageFragment.DoesNotExist:
         imgfrag = ImageFragment.create(
                                 image = image,
                                 x = coordinates[0],
                                 y = coordinates[1],
                                 w = defaultfragsize,
                                 h = defaultfragsize,)
         imgfrag.save()
         return imgfrag
Beispiel #3
0
def image_detail(imageid):

    """
        function that is when a specific image is requested
        the metadata of the requested image is loaded (if there is one)
        and given to the template
    """

    try: 
        image = Image.get(id=imageid)
        imgfrag = ImageFragment.get(image=image, x=0, y=0, visible=True)
        imgmeta = Metadata.get(imgfrag=imgfrag, namespace="http://www.w3.org/ns/ma-ont#")
        annos = Annotation.get(imgmeta=imgmeta)
        return render_template('image_detail.html', img=image,imgmeta=imgmeta)
    except Imageuri.DoesNotExist:
        flash('Die Bildnummer wurde nicht gefunden. Bitte waehle ein anderes Bild.', 'error')
        return render_template('images.html')
    except ImageFragment.DoesNotExist:
        return render_template('image_detail.html', img=image)