Class: PDF::Writer::Graphics::ImageInfo
- Inherits:
-
Object
- Object
- PDF::Writer::Graphics::ImageInfo
- Defined in:
- lib/pdf/writer/graphics/imageinfo.rb
Overview
This is based on ImageSize, by Keisuke Minami <[email protected]>. It can be found at www.rubycgi.org/tools/index.en.htm
This has been integrated into PDF::Writer because as yet there has been no response to emails asking for my extensions to be integrated and a RubyGem package to be made available.
Defined Under Namespace
Modules: Formats
Constant Summary collapse
- Type =
Flash
Formats
- JPEG_SOF_BLOCKS =
%W(\xc0 \xc1 \xc2 \xc3 \xc5 \xc6 \xc7 \xc9 \xca \xcb \xcd \xce \xcf)
- JPEG_APP_BLOCKS =
%W(\xe0 \xe1 \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef)
- XBM_DIMENSIONS_RE =
%r{^\#define\s*\S*\s*(\d+)\s*\n\#define\s*\S*\s*(\d+)}mi
- XPM_DIMENSIONS_RE =
%r<"\s*(\d+)\s+(\d+)(\s+\d+\s+\d+){1,2}\s*">m
Instance Attribute Summary collapse
-
#bits ⇒ Object
readonly
Returns the value of attribute bits.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#format ⇒ Object
(also: #get_type)
readonly
Returns the value of attribute format.
-
#height ⇒ Object
(also: #get_height)
readonly
Returns the value of attribute height.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#width ⇒ Object
(also: #get_width)
readonly
Returns the value of attribute width.
Class Method Summary collapse
- .formats ⇒ Object (also: type_list)
Instance Method Summary collapse
-
#initialize(data, format = nil) ⇒ ImageInfo
constructor
Receive image & make size.
Constructor Details
#initialize(data, format = nil) ⇒ ImageInfo
Receive image & make size. argument is image String or IO
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 54 def initialize(data, format = nil) @data = data.dup rescue data @info = {} if @data.kind_of?(IO) @top = @data.read(128) @data.seek(0, 0) # Define Singleton-method definition to IO (byte, offset) def @data.read_o(length = 1, offset = nil) self.seek(offset, 0) if offset ret = self.read(length) raise "cannot read!!" unless ret ret end elsif @data.is_a?(String) @top = @data[0, 128] # Define Singleton-method definition to String (byte, offset) @data.extend(PDF::Writer::OffsetReader) else raise "argument class error!! #{data.type}" end if format.nil? @format = discover_format else match = false Formats.constants.each { |t| match = true if format == t } raise("format is failed. #{format}\n") unless match @format = format end __send__("measure_#@format".intern) unless @format == Formats::OTHER @data = data.dup end |
Instance Attribute Details
#bits ⇒ Object (readonly)
Returns the value of attribute bits.
97 98 99 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 97 def bits @bits end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
98 99 100 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 98 def channels @channels end |
#format ⇒ Object (readonly) Also known as: get_type
Returns the value of attribute format.
90 91 92 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 90 def format @format end |
#height ⇒ Object (readonly) Also known as: get_height
Returns the value of attribute height.
92 93 94 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 92 def height @height end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
100 101 102 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 100 def info @info end |
#width ⇒ Object (readonly) Also known as: get_width
Returns the value of attribute width.
94 95 96 |
# File 'lib/pdf/writer/graphics/imageinfo.rb', line 94 def width @width end |