lib/prawn/images/jpg.rb in prawn-1.0.0.rc1 vs lib/prawn/images/jpg.rb in prawn-1.0.0.rc2
- old
+ new
@@ -23,12 +23,13 @@
# Process a new JPG image
#
# <tt>:data</tt>:: A binary string of JPEG data
#
def initialize(data)
- @data = data
- data = StringIO.new(data.dup)
+ @data = data.dup
+ ruby_19 { data.force_encoding("binary") }
+ data = StringIO.new(data)
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')
@@ -63,11 +64,10 @@
:Subtype => :Image,
:Filter => :DCTDecode,
:ColorSpace => color_space,
:BitsPerComponent => bits,
:Width => width,
- :Height => height,
- :Length => @data.size
+ :Height => height
)
# add extra decode params for CMYK images. By swapping the
# min and max values from the default, we invert the colours. See
# section 4.8.4 of the spec.