    # File lib/prawn/images/jpg.rb, line 27
          def initialize(data)
            data = StringIO.new(data.dup)

            c_marker = "\xff" # Section marker.
            data.read(2)   # Skip the first two bytes of JPEG identifier.
            loop do
              marker, code, length = data.read(4).unpack('aan')
              raise "JPEG marker not found!" if marker != c_marker

              if JPEG_SOF_BLOCKS.include?(code)
                @bits, @height, @width, @channels = data.read(6).unpack("CnnC")
                break
              end

              buffer = data.read(length - 2)
            end
          end