lib/prawn/images/jpg.rb in prawn-2.0.1 vs lib/prawn/images/jpg.rb in prawn-2.0.2
- old
+ new
@@ -8,11 +8,10 @@
require 'stringio'
module Prawn
module Images
-
# A convenience class that wraps the logic for extracting the parts
# of a JPG image that we need to embed them in a PDF
#
class JPG < Image
# @group Extension API
@@ -37,11 +36,11 @@
c_marker = 0xff # Section marker.
d.seek(2) # Skip the first two bytes of JPEG identifier.
loop do
marker, code, length = d.read(4).unpack('CCn')
- raise "JPEG marker not found!" if marker != c_marker
+ fail "JPEG marker not found!" if marker != c_marker
if JPEG_SOF_BLOCKS.include?(code)
@bits, @height, @width, @channels = d.read(6).unpack("CnnC")
break
end
@@ -53,19 +52,19 @@
# Build a PDF object representing this image in +document+, and return
# a Reference to it.
#
def build_pdf_object(document)
color_space = case channels
- when 1
- :DeviceGray
- when 3
- :DeviceRGB
- when 4
- :DeviceCMYK
- else
- raise ArgumentError, 'JPG uses an unsupported number of channels'
- end
+ when 1
+ :DeviceGray
+ when 3
+ :DeviceRGB
+ when 4
+ :DeviceCMYK
+ else
+ fail ArgumentError, 'JPG uses an unsupported number of channels'
+ end
obj = document.ref!(
:Type => :XObject,
:Subtype => :Image,
:ColorSpace => color_space,
@@ -83,9 +82,8 @@
obj.stream << @data
obj.stream.filters << :DCTDecode
obj
end
-
end
end
end