Exemplo n.º 1
0
    def metadata(self):
        """Returns image metadata associated with this submission"""
        if getattr(self, "_image_meta", None) is None:
            from EXIF import process_file
            from cStringIO import StringIO

            f = StringIO("".join([c for c in self.image.chunks()]))
            self._image_meta = process_file(f)
        return self._image_meta
Exemplo n.º 2
0
def extract_exif(filename):
    """
    Returns EXIF tags found in file at ``filename``
    """
    try:
        with file(filename) as image:
            return process_file(image, details=False)
    except IOError:
        raise BadMediaFail(_('Could not read the image file.'))
Exemplo n.º 3
0
def extract_exif(filename):
    """
    Returns EXIF tags found in file at ``filename``
    """
    try:
        with file(filename) as image:
            return process_file(image, details=False)
    except IOError:
        raise BadMediaFail(_('Could not read the image file.'))
Exemplo n.º 4
0
    def set_exif(self):
        data = process_file(self.image, details = True, debug = False )
        if not data:
            return False

        # See if the date the image was taken is available
        if data.has_key('Image DateTime'):
            datetime = data['Image DateTime']
            self.date_taken = datetime.values.replace(':','-',2)

        # See if GPS data is available and if so convert to decimal for Google Map
        self. longitude, self.latitude = get_GPS(data)
        
        # Check orientation
        if data.has_key( 'Image Orientation' ):
            orient = data['Image Orientation']
            if orient.printable:
                return orient.__str__()
            
        return 0
Exemplo n.º 5
0
    def clean(self):
        """{'image': <InMemoryUploadedFile: Photo 04-08-2011 19 51 15.jpeg
        (image/jpeg)>, 'lon': None, 'taxon': <Taxon: Family: Fallopia>,
        'datetime': u"[u'', u'']", 'lat': None, 'contactable': True,
        'get_coords_from_photo': True, 'get_datetime_from_photo': True,
        'email': u'*****@*****.**'}"""
        c_data = self.cleaned_data
        if c_data.get('contactable', False) and \
            not c_data.get('email', ''):
            msg = "Please add email address if you want to be contacted!"
            self._errors["email"] = self.error_class([msg])
            del c_data['email']

        exif = None
        try:
            f = c_data['image'].file
            f.seek(0)
            exif = process_file(f)
        except Exception, e:
            import logging
            logging.error(e)
            exif = None
Exemplo n.º 6
0
 def __init__(self, path):
     fd = open(path, "rb")
     self.tags = process_file(fd, details=False)
     # print self.tags
     self.path = path