Author: dmeyer
Date: Sat Feb 11 15:48:37 2006
New Revision: 1166

Added:
   trunk/metadata/src/image/bmpinfo.py
   trunk/metadata/src/image/gifinfo.py
Removed:
   trunk/metadata/src/image/pilinfo.py
Modified:
   trunk/metadata/src/factory.py
   trunk/metadata/src/image/core.py
   trunk/metadata/src/image/jpginfo.py
   trunk/metadata/src/image/pnginfo.py
   trunk/metadata/src/image/tiffinfo.py

Log:
remove PIL and add gif and bmp parser

Modified: trunk/metadata/src/factory.py
==============================================================================
--- trunk/metadata/src/factory.py       (original)
+++ trunk/metadata/src/factory.py       Sat Feb 11 15:48:37 2006
@@ -112,7 +112,8 @@
         import image.jpginfo
         import image.pnginfo
         import image.tiffinfo
-        import image.pilinfo
+        import image.bmpinfo
+        import image.gifinfo
         import video.vcdinfo
         import video.realinfo
         import video.ogminfo

Added: trunk/metadata/src/image/bmpinfo.py
==============================================================================
--- (empty file)
+++ trunk/metadata/src/image/bmpinfo.py Sat Feb 11 15:48:37 2006
@@ -0,0 +1,64 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# bmpinfo.py - bmp file parsing
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa-Metadata - Media Metadata for Python
+# Copyright (C) 2003-2005 Thomas Schueppel, Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file doc/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# python imports
+import struct
+import logging
+
+# kaa imports
+from kaa.metadata import mediainfo
+from kaa.metadata import factory
+
+import core
+
+# get logging object
+log = logging.getLogger('metadata')
+
+# interesting file format info:
+# http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html
+
+class BMPInfo(core.ImageInfo):
+
+    def __init__(self,file):
+        core.ImageInfo.__init__(self)
+        self.mime = 'image/bmp'
+        self.type = 'windows bitmap image'
+
+        (bfType, bfSize, bfZero, bfOffset, biSize, self.width, self.height) = \
+                 struct.unpack('<2sIIIIII', file.read(26))
+        # seek to the end to test length
+        file.seek(0, 2)
+
+        if bfType != 'BM' or bfSize != file.tell():
+            raise mediainfo.KaaMetadataParseError()
+
+
+factory.register( 'image/bmp', ('bmp', ), mediainfo.TYPE_IMAGE, BMPInfo )

Modified: trunk/metadata/src/image/core.py
==============================================================================
--- trunk/metadata/src/image/core.py    (original)
+++ trunk/metadata/src/image/core.py    Sat Feb 11 15:48:37 2006
@@ -43,13 +43,6 @@
 # get logging object
 log = logging.getLogger('metadata')
 
-try:
-    import Image as PIL
-except:
-    log.info('Python Imaging not found')
-    PIL = None
-
-
 # attributes for image files
 ATTRIBUTES = ['description', 'people', 'location', 'event', 'width', 'height',
               'thumbnail','software','hardware', 'dpi']
@@ -101,31 +94,3 @@
                         self.description = c.textof()
             except:
                 pass
-
-
-    def add_imaging_information(self, filename):
-        """
-        Add informations based on imaging (PIL)
-        """
-        if not PIL:
-            return
-        try:
-            i = PIL.open(filename)
-        except:
-            raise mediainfo.KaaMetadataParseError()
-
-        if not self.mime:
-            self.mime = 'image/%s' % i.format.lower()
-
-        self.type = i.format_description
-
-        if i.info.has_key('dpi'):
-            self['dpi'] = '%sx%s' % i.info['dpi']
-
-        for info in i.info:
-            if not info == 'exif':
-                log.debug('%s: %s' % (info, i.info[info]))
-
-        self.mode = i.mode
-        if not self.height:
-            self.width, self.height = i.size

Added: trunk/metadata/src/image/gifinfo.py
==============================================================================
--- (empty file)
+++ trunk/metadata/src/image/gifinfo.py Sat Feb 11 15:48:37 2006
@@ -0,0 +1,62 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# gifinfo.py - gif file parsing
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# kaa-Metadata - Media Metadata for Python
+# Copyright (C) 2003-2005 Thomas Schueppel, Dirk Meyer
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file doc/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# python imports
+import struct
+import logging
+
+# kaa imports
+from kaa.metadata import mediainfo
+from kaa.metadata import factory
+
+import core
+
+# get logging object
+log = logging.getLogger('metadata')
+
+# interesting file format info:
+# http://www.danbbs.dk/~dino/whirlgif/gif87.html
+
+class GIFInfo(core.ImageInfo):
+
+    def __init__(self,file):
+        core.ImageInfo.__init__(self)
+        self.mime = 'image/gif'
+
+        (gifType, self.width, self.height) = struct.unpack('<6sHH', 
file.read(10))
+
+        if not gifType.startswith('GIF'):
+            raise mediainfo.KaaMetadataParseError()
+
+        self.type = gifType.lower()
+
+
+factory.register( 'image/gif', ('gif', ), mediainfo.TYPE_IMAGE, GIFInfo )

Modified: trunk/metadata/src/image/jpginfo.py
==============================================================================
--- trunk/metadata/src/image/jpginfo.py (original)
+++ trunk/metadata/src/image/jpginfo.py Sat Feb 11 15:48:37 2006
@@ -139,11 +139,4 @@
                 if not key in self.keys:
                     self.keys.append(key)
 
-        # core stuff
-        self.add_imaging_information(file.name)
-        if core.PIL:
-            self.parse_external_files(file.name)
-
-
-factory.register( 'image/jpeg', ('jpg','jpeg'), mediainfo.TYPE_IMAGE,
-                       JPGInfo )
+factory.register( 'image/jpeg', ('jpg','jpeg'), mediainfo.TYPE_IMAGE, JPGInfo )

Modified: trunk/metadata/src/image/pnginfo.py
==============================================================================
--- trunk/metadata/src/image/pnginfo.py (original)
+++ trunk/metadata/src/image/pnginfo.py Sat Feb 11 15:48:37 2006
@@ -76,11 +76,6 @@
                 if not key in self.keys:
                     self.keys.append(key)
 
-        # core stuff
-        self.add_imaging_information(file.name)
-        if core.PIL:
-            self.parse_external_files(file.name)
-
 
     def _readChunk(self,file):
         try:

Modified: trunk/metadata/src/image/tiffinfo.py
==============================================================================
--- trunk/metadata/src/image/tiffinfo.py        (original)
+++ trunk/metadata/src/image/tiffinfo.py        Sat Feb 11 15:48:37 2006
@@ -121,12 +121,5 @@
             self.setitem( 'caption', iptc, 632 )
             self.appendtable('IPTC', iptc)
 
-        # core stuff
-        self.add_imaging_information(file.name)
-        if core.PIL:
-            self.parse_external_files(file.name)
-        return
 
-
-factory.register( 'image/tiff', ('tif','tiff'), mediainfo.TYPE_IMAGE,
-                       TIFFInfo )
+factory.register( 'image/tiff', ('tif','tiff'), mediainfo.TYPE_IMAGE, TIFFInfo 
)


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to