diff -r 058a5d7a4f84 lib/galaxy/datatypes/images.py
--- a/lib/galaxy/datatypes/images.py	Mon Jun 06 09:08:59 2011 -0400
+++ b/lib/galaxy/datatypes/images.py	Mon Jul 25 17:04:55 2011 +0200
@@ -9,7 +9,15 @@
 from galaxy.datatypes.sniff import *
 from urllib import urlencode, quote_plus
 import zipfile
-import os, subprocess, tempfile
+import os, subprocess, tempfile, imghdr
+
+try:
+    import Image as PIL
+except ImportError:
+    try:
+        from PIL import Image as PIL
+    except:
+        PIL = None
 
 log = logging.getLogger(__name__)
 
@@ -22,7 +30,154 @@
         else:
             dataset.peek = 'file does not exist'
             dataset.blurb = 'file purged from disk'
+    def sniff( self, filename ):
+        # First check if we can  use PIL
+        if PIL != None:
+            try:
+                im = PIL.open( filename )
+                im.close()
+            except:
+                return False
+            if im:
+                return True
+            return False
+        else:
+            if imghdr.what(filename) != None:
+                return True
+            else:
+                return False
+    def image_type( self, filename, image=None ):
+        format = ''
+        if PIL != None:
+            if not image or image == None:
+                try:
+                    im = PIL.open( filename )
+                    format = im.format
+                    im.close()
+                except:
+                    return False
+            else:
+                format = image.format
+                image.close()
+        else:
+            format = imghdr.what(filename)
+            if format != None:
+                format = format.upper()
+            else:
+                return False
+        return format
+    
+    def check_image_type( self, filename, types, image=None ):
+        format = self.image_type( filename, image )
+        # First check if we can  use PIL        
+        if format in types:
+            return True
+        return False
+    
+class Jpg( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in jpg format.
+        """
+        return Image.check_image_type( filename, ['JPEG'], image )
 
+class Png( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in png format.
+        """
+        return Image.check_image_type( filename, ['PNG'], image )
+    
+class Tiff( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in tiff format.
+        """
+        return Image.check_image_type( filename, ['TIFF'], image )
+    
+class Bmp( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in bmp format.
+        """
+        return Image.check_image_type( filename, ['BMP'], image )
+
+class Gif( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in gif format.
+        """
+        return Image.check_image_type( filename, ['GIF'], image )
+
+class Im( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in im format.
+        """
+        return Image.check_image_type( filename, ['IM'], image )
+
+class Pcd( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in pcd format.
+        """
+        return Image.check_image_type( filename, ['PCD'], image )        
+
+class Pcx( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in pcx format.
+        """
+        return Image.check_image_type( filename, ['PCX'], image )
+
+class Ppm( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in ppm format.
+        """
+        return Image.check_image_type( filename, ['PPM'], image )        
+
+class Psd( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in psd format.
+        """
+        return Image.check_image_type( filename, ['PSD'], image )        
+
+class Xbm( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in XBM format.
+        """
+        return Image.check_image_type( filename, ['XBM'], image )        
+
+class Xpm( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in XPM format.
+        """
+        return Image.check_image_type( filename, ['XPM'], image )        
+
+class Rgb( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in RGB format.
+        """
+        return Image.check_image_type( filename, ['RGB'], image )
+
+class Pbm( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in PBM format
+        """
+        return Image.check_image_type( filename, ['PBM'], image )
+
+class Pgm( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in PGM format
+        """
+        return Image.check_image_type( filename, ['PGM'], image )
+
+class Eps( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in eps format.
+        """
+        return Image.check_image_type( filename, ['EPS'], image )        
+
+
+class Rast( Image ):
+    def sniff(self, filename, image=None):
+        """Determine if the file is in rast format
+        """
+        return Image.check_image_type( filename, ['RAST'], image )
+
+   
 class Pdf( Image ):
     def sniff(self, filename):
         """Determine if the file is in pdf format.
@@ -36,6 +191,8 @@
         except IndexError:
             return False
 
+
+
 def create_applet_tag_peek( class_name, archive, params ):
     text = """
 <!--[if !IE]>-->
