Index: trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegCommentDescriptor.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
@@ -26,7 +26,7 @@
 
 /**
- * Provides human-readable string representations of tag values stored in a <code>JpegCommentDirectory</code>.
+ * Provides human-readable string representations of tag values stored in a {@link JpegCommentDirectory}.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class JpegCommentDescriptor extends TagDescriptor<JpegCommentDirectory>
@@ -40,5 +40,5 @@
     public String getJpegCommentDescription()
     {
-        return _directory.getString(JpegCommentDirectory.TAG_JPEG_COMMENT);
+        return _directory.getString(JpegCommentDirectory.TAG_COMMENT);
     }
 }
Index: trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegCommentDirectory.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
@@ -29,5 +29,5 @@
  * Describes tags used by a JPEG file comment.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class JpegCommentDirectory extends Directory
@@ -37,5 +37,5 @@
      * consistency with other directory types.
      */
-    public static final int TAG_JPEG_COMMENT = 0;
+    public static final int TAG_COMMENT = 0;
 
     @NotNull
@@ -43,5 +43,5 @@
 
     static {
-        _tagNameMap.put(TAG_JPEG_COMMENT, "Jpeg Comment");
+        _tagNameMap.put(TAG_COMMENT, "JPEG Comment");
     }
 
@@ -51,4 +51,5 @@
     }
 
+    @Override
     @NotNull
     public String getName()
@@ -57,4 +58,5 @@
     }
 
+    @Override
     @NotNull
     protected HashMap<Integer, String> getTagNameMap()
Index: trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegCommentReader.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,36 +16,42 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
 
-import com.drew.lang.BufferBoundsException;
-import com.drew.lang.BufferReader;
+import com.drew.imaging.jpeg.JpegSegmentMetadataReader;
+import com.drew.imaging.jpeg.JpegSegmentType;
 import com.drew.lang.annotations.NotNull;
 import com.drew.metadata.Metadata;
-import com.drew.metadata.MetadataReader;
+
+import java.util.Arrays;
 
 /**
- * Decodes the comment stored within Jpeg files, populating a <code>Metadata</code> object with tag values in a
- * <code>JpegCommentDirectory</code>.
+ * Decodes the comment stored within JPEG files, populating a {@link Metadata} object with tag values in a
+ * {@link JpegCommentDirectory}.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
-public class JpegCommentReader implements MetadataReader
+public class JpegCommentReader implements JpegSegmentMetadataReader
 {
-    /**
-     * Performs the Jpeg data extraction, adding found values to the specified
-     * instance of <code>Metadata</code>.
-     */
-    public void extract(@NotNull final BufferReader reader, @NotNull Metadata metadata)
+    @NotNull
+    public Iterable<JpegSegmentType> getSegmentTypes()
+    {
+        return Arrays.asList(JpegSegmentType.COM);
+    }
+
+    public boolean canProcess(@NotNull byte[] segmentBytes, @NotNull JpegSegmentType segmentType)
+    {
+        // The entire contents of the byte[] is the comment. There's nothing here to discriminate upon.
+        return true;
+    }
+
+    public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
     {
         JpegCommentDirectory directory = metadata.getOrCreateDirectory(JpegCommentDirectory.class);
 
-        try {
-            directory.setString(JpegCommentDirectory.TAG_JPEG_COMMENT, reader.getString(0, (int)reader.getLength()));
-        } catch (BufferBoundsException e) {
-            directory.addError("Exception reading JPEG comment string");
-        }
+        // The entire contents of the directory are the comment
+        directory.setString(JpegCommentDirectory.TAG_COMMENT, new String(segmentBytes));
     }
 }
Index: trunk/src/com/drew/metadata/jpeg/JpegComponent.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegComponent.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegComponent.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
@@ -26,8 +26,8 @@
 
 /**
- * Stores information about a Jpeg image component such as the component id, horiz/vert sampling factor and
+ * Stores information about a JPEG image component such as the component id, horiz/vert sampling factor and
  * quantization table number.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class JpegComponent implements Serializable
Index: trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegDescriptor.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
@@ -29,5 +29,5 @@
  * Thanks to Darrell Silver (www.darrellsilver.com) for the initial version of this class.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class JpegDescriptor extends TagDescriptor<JpegDirectory>
@@ -38,4 +38,5 @@
     }
 
+    @Override
     @Nullable
     public String getDescription(int tagType)
@@ -43,19 +44,19 @@
         switch (tagType)
         {
-            case JpegDirectory.TAG_JPEG_COMPRESSION_TYPE:
+            case JpegDirectory.TAG_COMPRESSION_TYPE:
                 return getImageCompressionTypeDescription();
-            case JpegDirectory.TAG_JPEG_COMPONENT_DATA_1:
+            case JpegDirectory.TAG_COMPONENT_DATA_1:
                 return getComponentDataDescription(0);
-            case JpegDirectory.TAG_JPEG_COMPONENT_DATA_2:
+            case JpegDirectory.TAG_COMPONENT_DATA_2:
                 return getComponentDataDescription(1);
-            case JpegDirectory.TAG_JPEG_COMPONENT_DATA_3:
+            case JpegDirectory.TAG_COMPONENT_DATA_3:
                 return getComponentDataDescription(2);
-            case JpegDirectory.TAG_JPEG_COMPONENT_DATA_4:
+            case JpegDirectory.TAG_COMPONENT_DATA_4:
                 return getComponentDataDescription(3);
-            case JpegDirectory.TAG_JPEG_DATA_PRECISION:
+            case JpegDirectory.TAG_DATA_PRECISION:
                 return getDataPrecisionDescription();
-            case JpegDirectory.TAG_JPEG_IMAGE_HEIGHT:
+            case JpegDirectory.TAG_IMAGE_HEIGHT:
                 return getImageHeightDescription();
-            case JpegDirectory.TAG_JPEG_IMAGE_WIDTH:
+            case JpegDirectory.TAG_IMAGE_WIDTH:
                 return getImageWidthDescription();
             default:
@@ -67,5 +68,5 @@
     public String getImageCompressionTypeDescription()
     {
-        Integer value = _directory.getInteger(JpegDirectory.TAG_JPEG_COMPRESSION_TYPE);
+        Integer value = _directory.getInteger(JpegDirectory.TAG_COMPRESSION_TYPE);
         if (value==null)
             return null;
@@ -93,5 +94,5 @@
     public String getImageWidthDescription()
     {
-        final String value = _directory.getString(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
+        final String value = _directory.getString(JpegDirectory.TAG_IMAGE_WIDTH);
         if (value==null)
             return null;
@@ -102,5 +103,5 @@
     public String getImageHeightDescription()
     {
-        final String value = _directory.getString(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
+        final String value = _directory.getString(JpegDirectory.TAG_IMAGE_HEIGHT);
         if (value==null)
             return null;
@@ -111,5 +112,5 @@
     public String getDataPrecisionDescription()
     {
-        final String value = _directory.getString(JpegDirectory.TAG_JPEG_DATA_PRECISION);
+        final String value = _directory.getString(JpegDirectory.TAG_DATA_PRECISION);
         if (value==null)
             return null;
@@ -125,14 +126,7 @@
             return null;
 
-        StringBuilder sb = new StringBuilder();
-        sb.append(value.getComponentName());
-        sb.append(" component: Quantization table ");
-        sb.append(value.getQuantizationTableNumber());
-        sb.append(", Sampling factors ");
-        sb.append(value.getHorizontalSamplingFactor());
-        sb.append(" horiz/");
-        sb.append(value.getVerticalSamplingFactor());
-        sb.append(" vert");
-        return sb.toString();
+        return value.getComponentName() + " component: Quantization table " + value.getQuantizationTableNumber()
+            + ", Sampling factors " + value.getHorizontalSamplingFactor()
+            + " horiz/" + value.getVerticalSamplingFactor() + " vert";
     }
 }
Index: trunk/src/com/drew/metadata/jpeg/JpegDirectory.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegDirectory.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegDirectory.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
@@ -29,17 +29,17 @@
 
 /**
- * Directory of tags and values for the SOF0 Jpeg segment.  This segment holds basic metadata about the image.
+ * Directory of tags and values for the SOF0 JPEG segment.  This segment holds basic metadata about the image.
  *
- * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes http://drewnoakes.com
+ * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes https://drewnoakes.com
  */
 public class JpegDirectory extends Directory
 {
-    public static final int TAG_JPEG_COMPRESSION_TYPE = -3;
+    public static final int TAG_COMPRESSION_TYPE = -3;
     /** This is in bits/sample, usually 8 (12 and 16 not supported by most software). */
-    public static final int TAG_JPEG_DATA_PRECISION = 0;
+    public static final int TAG_DATA_PRECISION = 0;
     /** The image's height.  Necessary for decoding the image, so it should always be there. */
-    public static final int TAG_JPEG_IMAGE_HEIGHT = 1;
+    public static final int TAG_IMAGE_HEIGHT = 1;
     /** The image's width.  Necessary for decoding the image, so it should always be there. */
-    public static final int TAG_JPEG_IMAGE_WIDTH = 3;
+    public static final int TAG_IMAGE_WIDTH = 3;
     /**
      * Usually 1 = grey scaled, 3 = color YcbCr or YIQ, 4 = color CMYK
@@ -48,19 +48,19 @@
      * sampling factors (1byte) (bit 0-3 vertical., 4-7 horizontal.),
      * quantization table number (1 byte).
-     * <p/>
+     * <p>
      * This info is from http://www.funducode.com/freec/Fileformats/format3/format3b.htm
      */
-    public static final int TAG_JPEG_NUMBER_OF_COMPONENTS = 5;
+    public static final int TAG_NUMBER_OF_COMPONENTS = 5;
 
     // NOTE!  Component tag type int values must increment in steps of 1
 
-    /** the first of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
-    public static final int TAG_JPEG_COMPONENT_DATA_1 = 6;
-    /** the second of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
-    public static final int TAG_JPEG_COMPONENT_DATA_2 = 7;
-    /** the third of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
-    public static final int TAG_JPEG_COMPONENT_DATA_3 = 8;
-    /** the fourth of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
-    public static final int TAG_JPEG_COMPONENT_DATA_4 = 9;
+    /** the first of a possible 4 color components.  Number of components specified in TAG_NUMBER_OF_COMPONENTS. */
+    public static final int TAG_COMPONENT_DATA_1 = 6;
+    /** the second of a possible 4 color components.  Number of components specified in TAG_NUMBER_OF_COMPONENTS. */
+    public static final int TAG_COMPONENT_DATA_2 = 7;
+    /** the third of a possible 4 color components.  Number of components specified in TAG_NUMBER_OF_COMPONENTS. */
+    public static final int TAG_COMPONENT_DATA_3 = 8;
+    /** the fourth of a possible 4 color components.  Number of components specified in TAG_NUMBER_OF_COMPONENTS. */
+    public static final int TAG_COMPONENT_DATA_4 = 9;
 
     @NotNull
@@ -68,13 +68,13 @@
 
     static {
-        _tagNameMap.put(TAG_JPEG_COMPRESSION_TYPE, "Compression Type");
-        _tagNameMap.put(TAG_JPEG_DATA_PRECISION, "Data Precision");
-        _tagNameMap.put(TAG_JPEG_IMAGE_WIDTH, "Image Width");
-        _tagNameMap.put(TAG_JPEG_IMAGE_HEIGHT, "Image Height");
-        _tagNameMap.put(TAG_JPEG_NUMBER_OF_COMPONENTS, "Number of Components");
-        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_1, "Component 1");
-        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_2, "Component 2");
-        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_3, "Component 3");
-        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_4, "Component 4");
+        _tagNameMap.put(TAG_COMPRESSION_TYPE, "Compression Type");
+        _tagNameMap.put(TAG_DATA_PRECISION, "Data Precision");
+        _tagNameMap.put(TAG_IMAGE_WIDTH, "Image Width");
+        _tagNameMap.put(TAG_IMAGE_HEIGHT, "Image Height");
+        _tagNameMap.put(TAG_NUMBER_OF_COMPONENTS, "Number of Components");
+        _tagNameMap.put(TAG_COMPONENT_DATA_1, "Component 1");
+        _tagNameMap.put(TAG_COMPONENT_DATA_2, "Component 2");
+        _tagNameMap.put(TAG_COMPONENT_DATA_3, "Component 3");
+        _tagNameMap.put(TAG_COMPONENT_DATA_4, "Component 4");
     }
 
@@ -84,10 +84,12 @@
     }
 
+    @Override
     @NotNull
     public String getName()
     {
-        return "Jpeg";
+        return "JPEG";
     }
 
+    @Override
     @NotNull
     protected HashMap<Integer, String> getTagNameMap()
@@ -104,5 +106,5 @@
     public JpegComponent getComponent(int componentNumber)
     {
-        int tagType = JpegDirectory.TAG_JPEG_COMPONENT_DATA_1 + componentNumber;
+        int tagType = JpegDirectory.TAG_COMPONENT_DATA_1 + componentNumber;
         return (JpegComponent)getObject(tagType);
     }
@@ -110,15 +112,15 @@
     public int getImageWidth() throws MetadataException
     {
-        return getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
+        return getInt(JpegDirectory.TAG_IMAGE_WIDTH);
     }
 
     public int getImageHeight() throws MetadataException
     {
-        return getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
+        return getInt(JpegDirectory.TAG_IMAGE_HEIGHT);
     }
 
     public int getNumberOfComponents() throws MetadataException
     {
-        return getInt(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS);
+        return getInt(JpegDirectory.TAG_NUMBER_OF_COMPONENTS);
     }
 }
Index: trunk/src/com/drew/metadata/jpeg/JpegReader.java
===================================================================
--- trunk/src/com/drew/metadata/jpeg/JpegReader.java	(revision 6127)
+++ trunk/src/com/drew/metadata/jpeg/JpegReader.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,46 +16,77 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.metadata.jpeg;
 
-import com.drew.lang.BufferBoundsException;
-import com.drew.lang.BufferReader;
+import com.drew.imaging.jpeg.JpegSegmentMetadataReader;
+import com.drew.imaging.jpeg.JpegSegmentType;
+import com.drew.lang.SequentialByteArrayReader;
+import com.drew.lang.SequentialReader;
 import com.drew.lang.annotations.NotNull;
 import com.drew.metadata.Metadata;
-import com.drew.metadata.MetadataReader;
+
+import java.io.IOException;
+import java.util.Arrays;
 
 /**
- * Decodes Jpeg SOF0 data, populating a <code>Metadata</code> object with tag values in a <code>JpegDirectory</code>.
+ * Decodes JPEG SOFn data, populating a {@link Metadata} object with tag values in a {@link JpegDirectory}.
  *
- * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
+ * @author Darrell Silver http://www.darrellsilver.com
  */
-public class JpegReader implements MetadataReader
+public class JpegReader implements JpegSegmentMetadataReader
 {
-    /**
-     * Performs the Jpeg data extraction, adding found values to the specified
-     * instance of <code>Metadata</code>.
-     */
-    public void extract(@NotNull final BufferReader reader, @NotNull Metadata metadata)
+    @NotNull
+    public Iterable<JpegSegmentType> getSegmentTypes()
     {
+        // NOTE that some SOFn values do not exist
+        return Arrays.asList(
+            JpegSegmentType.SOF0,
+            JpegSegmentType.SOF1,
+            JpegSegmentType.SOF2,
+            JpegSegmentType.SOF3,
+//            JpegSegmentType.SOF4,
+            JpegSegmentType.SOF5,
+            JpegSegmentType.SOF6,
+            JpegSegmentType.SOF7,
+            JpegSegmentType.SOF8,
+            JpegSegmentType.SOF9,
+            JpegSegmentType.SOF10,
+            JpegSegmentType.SOF11,
+//            JpegSegmentType.SOF12,
+            JpegSegmentType.SOF13,
+            JpegSegmentType.SOF14,
+            JpegSegmentType.SOF15
+        );
+    }
+
+    public boolean canProcess(@NotNull byte[] segmentBytes, @NotNull JpegSegmentType segmentType)
+    {
+        return true;
+    }
+
+    public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
+    {
+        if (metadata.containsDirectory(JpegDirectory.class)) {
+            // If this directory is already present, discontinue this operation.
+            // We only store metadata for the *first* matching SOFn segment.
+            return;
+        }
+
         JpegDirectory directory = metadata.getOrCreateDirectory(JpegDirectory.class);
 
+        // The value of TAG_COMPRESSION_TYPE is determined by the segment type found
+        directory.setInt(JpegDirectory.TAG_COMPRESSION_TYPE, segmentType.byteValue - JpegSegmentType.SOF0.byteValue);
+
+        SequentialReader reader = new SequentialByteArrayReader(segmentBytes);
+
         try {
-            // data precision
-            int dataPrecision = reader.getUInt8(JpegDirectory.TAG_JPEG_DATA_PRECISION);
-            directory.setInt(JpegDirectory.TAG_JPEG_DATA_PRECISION, dataPrecision);
-
-            // process height
-            int height = reader.getUInt16(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
-            directory.setInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT, height);
-
-            // process width
-            int width = reader.getUInt16(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
-            directory.setInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH, width);
-
-            // number of components
-            int numberOfComponents = reader.getUInt8(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS);
-            directory.setInt(JpegDirectory.TAG_JPEG_NUMBER_OF_COMPONENTS, numberOfComponents);
+            directory.setInt(JpegDirectory.TAG_DATA_PRECISION, reader.getUInt8());
+            directory.setInt(JpegDirectory.TAG_IMAGE_HEIGHT, reader.getUInt16());
+            directory.setInt(JpegDirectory.TAG_IMAGE_WIDTH, reader.getUInt16());
+            short componentCount = reader.getUInt8();
+            directory.setInt(JpegDirectory.TAG_NUMBER_OF_COMPONENTS, componentCount);
 
             // for each component, there are three bytes of data:
@@ -63,14 +94,13 @@
             // 2 - Sampling factors: bit 0-3 vertical, 4-7 horizontal
             // 3 - Quantization table number
-            int offset = 6;
-            for (int i = 0; i < numberOfComponents; i++) {
-                int componentId = reader.getUInt8(offset++);
-                int samplingFactorByte = reader.getUInt8(offset++);
-                int quantizationTableNumber = reader.getUInt8(offset++);
-                JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber);
-                directory.setObject(JpegDirectory.TAG_JPEG_COMPONENT_DATA_1 + i, component);
+            for (int i = 0; i < (int)componentCount; i++) {
+                final int componentId = reader.getUInt8();
+                final int samplingFactorByte = reader.getUInt8();
+                final int quantizationTableNumber = reader.getUInt8();
+                final JpegComponent component = new JpegComponent(componentId, samplingFactorByte, quantizationTableNumber);
+                directory.setObject(JpegDirectory.TAG_COMPONENT_DATA_1 + i, component);
             }
 
-        } catch (BufferBoundsException ex) {
+        } catch (IOException ex) {
             directory.addError(ex.getMessage());
         }
Index: trunk/src/com/drew/metadata/jpeg/package.html
===================================================================
--- trunk/src/com/drew/metadata/jpeg/package.html	(revision 8132)
+++ trunk/src/com/drew/metadata/jpeg/package.html	(revision 8132)
@@ -0,0 +1,33 @@
+<!--
+  ~ Copyright 2002-2015 Drew Noakes
+  ~
+  ~    Licensed under the Apache License, Version 2.0 (the "License");
+  ~    you may not use this file except in compliance with the License.
+  ~    You may obtain a copy of the License at
+  ~
+  ~        http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing, software
+  ~    distributed under the License is distributed on an "AS IS" BASIS,
+  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~    See the License for the specific language governing permissions and
+  ~    limitations under the License.
+  ~
+  ~ More information about this project is available at:
+  ~
+  ~    https://drewnoakes.com/code/exif/
+  ~    https://github.com/drewnoakes/metadata-extractor
+  -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+Contains classes for the extraction and modelling of JPEG file format metadata.
+
+<!-- Put @see and @since tags down here. -->
+
+</body>
+</html>
