Index: ext/metadata/gstbasemetadata.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/gstbasemetadata.c,v
retrieving revision 1.3
diff -u -p -r1.3 gstbasemetadata.c
--- ext/metadata/gstbasemetadata.c	21 Dec 2007 19:01:00 -0000	1.3
+++ ext/metadata/gstbasemetadata.c	4 Jan 2008 13:48:10 -0000
@@ -128,6 +128,7 @@ static void gst_base_metadata_init_membe
 static void gst_base_metadata_dispose_members (GstBaseMetadata * filter);
 
 static gboolean gst_base_metadata_configure_caps (GstBaseMetadata * filter);
+static gboolean gst_base_metadata_configure_srccaps (GstBaseMetadata * filter);
 
 static int
 gst_base_metadata_parse (GstBaseMetadata * filter, const guint8 * buf,
@@ -1046,6 +1047,8 @@ gst_base_metadata_init_members (GstBaseM
   filter->metadata = NULL;
 
   filter->img_type = IMG_NONE;
+  filter->img_width = -1;
+  filter->img_height = -1;
 
   filter->duration_orig = 0;
   filter->duration = 0;
@@ -1160,6 +1163,49 @@ done:
 
 }
 
+static gboolean
+gst_base_metadata_configure_srccaps (GstBaseMetadata * filter)
+{
+  GstCaps *caps = NULL;
+  gboolean ret = FALSE;
+  gchar *mime = NULL;
+
+  switch (filter->img_type) {
+    case IMG_JPEG:
+      mime = "image/jpeg";
+      break;
+    case IMG_PNG:
+      mime = "image/png";
+      break;
+    default:
+      ret = FALSE;
+      goto done;
+      break;
+  }
+
+  if (filter->img_width > 0 && filter->img_height > 0) {
+    caps = gst_caps_new_simple (mime,
+      "tags-extracted", G_TYPE_BOOLEAN, TRUE,
+      "width", G_TYPE_INT, filter->img_width,
+      "height", G_TYPE_INT, filter->img_height,
+      NULL);
+  } else {
+    caps =
+        gst_caps_new_simple (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, NULL);
+  }
+
+  ret = gst_pad_set_caps (filter->srcpad, caps);
+
+done:
+
+  if (caps) {
+    gst_caps_unref (caps);
+    caps = NULL;
+  }
+
+  return ret;
+}
+
 static const GstQueryType *
 gst_base_metadata_get_query_types (GstPad * pad)
 {
@@ -1262,12 +1308,24 @@ gst_base_metadata_parse (GstBaseMetadata
     filter->img_type = META_DATA_IMG_TYPE (filter->metadata);
     if (!gst_base_metadata_configure_caps (filter)) {
       GST_ELEMENT_ERROR (filter, STREAM, FORMAT, (NULL),
-          ("Couldn't reconfigure caps for %s",
+          ("Couldn't reconfigure sink caps for %s",
               gst_base_metadata_get_type_name (filter->img_type)));
       ret = META_PARSING_ERROR;
       goto done;
     }
   }
+  if (filter->img_width != META_DATA_IMG_WIDTH (filter->metadata) ||
+      filter->img_height != META_DATA_IMG_HEIGHT (filter->metadata)) {
+    filter->img_width = META_DATA_IMG_WIDTH (filter->metadata);
+    filter->img_height = META_DATA_IMG_HEIGHT (filter->metadata);
+    if (!gst_base_metadata_configure_srccaps (filter)) {
+      GST_ELEMENT_ERROR (filter, STREAM, FORMAT, (NULL),
+                         ("Couldn't reconfigure src caps for %s",
+                          gst_base_metadata_get_type_name (filter->img_type)));
+      ret = META_PARSING_ERROR;
+      goto done;
+    }
+  }
 
 done:
 
Index: ext/metadata/gstbasemetadata.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/gstbasemetadata.h,v
retrieving revision 1.3
diff -u -p -r1.3 gstbasemetadata.h
--- ext/metadata/gstbasemetadata.h	21 Dec 2007 19:01:00 -0000	1.3
+++ ext/metadata/gstbasemetadata.h	4 Jan 2008 13:48:10 -0000
@@ -112,6 +112,8 @@ struct _GstBaseMetadata
   MetaData *metadata; /* handle for parsing module */
 
   ImageType img_type;
+  gint img_width;
+  gint img_height;
 
   /*< private >*/
 
Index: ext/metadata/metadata.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadata.h,v
retrieving revision 1.8
diff -u -p -r1.8 metadata.h
--- ext/metadata/metadata.h	21 Dec 2007 19:01:00 -0000	1.8
+++ ext/metadata/metadata.h	4 Jan 2008 13:48:10 -0000
@@ -105,6 +105,8 @@ typedef struct _tag_MetaData
 } MetaData;
 
 #define META_DATA_IMG_TYPE(p) (p)->img_type
+#define META_DATA_IMG_WIDTH(p) ((p)->img_type == IMG_JPEG ? (p)->format_data.jpeg_parse.width : -1)
+#define META_DATA_IMG_HEIGHT(p) ((p)->img_type == IMG_JPEG ? (p)->format_data.jpeg_parse.height : -1)
 
 #define META_DATA_STRIP_CHUNKS(p) (p)->strip_chunks
 #define META_DATA_INJECT_CHUNKS(p) (p)->inject_chunks
Index: ext/metadata/metadataparsejpeg.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataparsejpeg.c,v
retrieving revision 1.12
diff -u -p -r1.12 metadataparsejpeg.c
--- ext/metadata/metadataparsejpeg.c	21 Dec 2007 19:01:00 -0000	1.12
+++ ext/metadata/metadataparsejpeg.c	4 Jan 2008 13:48:10 -0000
@@ -92,6 +92,8 @@ metadataparse_jpeg_init (JpegParseData *
   jpeg_data->xmp_adapter = xmp_adpt;
   jpeg_data->read = 0;
   jpeg_data->jfif_found = FALSE;
+  jpeg_data->width = -1;
+  jpeg_data->height = -1;
 
   jpeg_data->strip_chunks = strip_chunks;
   jpeg_data->inject_chunks = inject_chunks;
@@ -233,8 +235,8 @@ metadataparse_jpeg_reading (JpegParseDat
     chunk_size = READ (*buf, *bufsize) << 8;
     chunk_size += READ (*buf, *bufsize);
 
-    if (mark[1] == 0xE0) {      /* may be JFIF */
-
+    switch (mark[1]) {
+    case 0xE0:                          /* may be JFIF */
       if (chunk_size >= 16) {
         if (*bufsize < 14) {
           *next_size = (*buf - *next_start) + 14;
@@ -246,9 +248,9 @@ metadataparse_jpeg_reading (JpegParseDat
           jpeg_data->jfif_found = TRUE;
         }
       }
+      break;
 
-    } else if (mark[1] == 0xE1) {       /* may be it is Exif or XMP */
-
+    case 0xE1:                          /* may be it is Exif or XMP */
       if (chunk_size >= 8) {    /* size2 'EXIF' 0x00 0x00 */
         guint8 ch;
 
@@ -342,9 +344,32 @@ metadataparse_jpeg_reading (JpegParseDat
           }
         }
       }
-    }
+      break;
+
+    case 0xC0:                          /* SOF_0 */
+    case 0xC1:                          /* SOF_1 */
+    case 0xC2:                          /* SOF_2 */
+    case 0xC3:                          /* SOF_3 */
+    case 0xC5:                          /* SOF_5 */
+    case 0xC6:                          /* SOF_6 */
+    case 0xC7:                          /* SOF_7 */
+    case 0xC8:                          /* SOF_8 */
+    case 0xC9:                          /* SOF_9 */
+    case 0xCA:                          /* SOF_10 */
+    case 0xCB:                          /* SOF_11 */
+    case 0xCD:                          /* SOF_13 */
+    case 0xCE:                          /* SOF_14 */
+    case 0xCF:                          /* SOF_15 */
+      if (chunk_size < 5)
+          break;
+      /* first byte is data precision, we don't need that */
+      /* then width and height in 2-byte chunks */
+        jpeg_data->height = (*buf)[2] + ((*buf)[1] << 8);
+        jpeg_data->width = (*buf)[4] + ((*buf)[3] << 8);
+      break;
+
 #ifdef HAVE_IPTC
-    else if (mark[1] == 0xED) { /* may be it is photoshop and may be there is iptc */
+    case 0xED:                          /* may be it is photoshop and may be there is iptc */
       if (chunk_size >= 16) {   /* size2 "Photoshop 3.0" */
 
         if (*bufsize < 14) {
@@ -379,10 +404,11 @@ metadataparse_jpeg_reading (JpegParseDat
           }
         }
       }
-    }
+      break;
 #endif /* #ifdef HAVE_IPTC */
+    }
 
-    /* just set jump sise  */
+    /* just set jump size  */
     jpeg_data->read = chunk_size - 2;
     jpeg_data->state = JPEG_PARSE_JUMPING;
     ret = META_PARSING_DONE;
Index: ext/metadata/metadataparsejpeg.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataparsejpeg.h,v
retrieving revision 1.7
diff -u -p -r1.7 metadataparsejpeg.h
--- ext/metadata/metadataparsejpeg.h	17 Dec 2007 12:37:35 -0000	1.7
+++ ext/metadata/metadataparsejpeg.h	4 Jan 2008 13:48:10 -0000
@@ -77,6 +77,8 @@ typedef struct _tag_JpegParseData
 
   guint32 read;
   gboolean jfif_found;
+  gint width;
+  gint height;
 } JpegParseData;
 
 
