Class: DynamicPDFApi::ImageResource
Overview
Represents an image resource used to create an ImageInput object to create PDF from images.
Instance Attribute Summary
Attributes inherited from Resource
#_file_path, #_mime_type, #data, #resource_name
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
_get_file_data
Constructor Details
#initialize(file, resource_name = nil) ⇒ ImageResource
Initializes a new instance of the ImageResource class.
16
17
18
19
20
|
# File 'lib/ruby_client/ImageResource.rb', line 16
def initialize(file, resource_name = nil)
@_type = ResourceType::IMAGE
@_mime_type = nil
super(file, resource_name)
end
|
Class Method Details
.is_gif_image(header) ⇒ Object
66
67
68
69
|
# File 'lib/ruby_client/ImageResource.rb', line 66
def self.is_gif_image()
[0] == 0x47 && [1] == 0x49 && [2] == 0x46 && [3] == 0x38 && ([4] == 0x37 ||
[4] == 0x39) && [5] == 0x61
end
|
.is_jpeg2000_image(header) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/ruby_client/ImageResource.rb', line 49
def self.is_jpeg2000_image()
([0] == 0x00 && [1] == 0x00 && [2] == 0x00 && [3] == 0x0C && [4] == 0x6A &&
[5] == 0x50 && ([6] == 0x1A || [6] == 0x20) && ([7] == 0x1A || [7] == 0x20) &&
[8] == 0x0D && [9] == 0x0A && [10] == 0x87 && [11] == 0x0A) ||
([0] == 0xFF && [1] == 0x4F && [2] == 0xFF && [3] == 0x51 && [6] == 0x00 && [7] == 0x00)
end
|
.is_jpeg_image(header) ⇒ Object
71
72
73
|
# File 'lib/ruby_client/ImageResource.rb', line 71
def self.is_jpeg_image()
[0] == 0xFF && [1] == 0xD8 && [2] == 0xFF
end
|
.is_png_image(header) ⇒ Object
56
57
58
59
|
# File 'lib/ruby_client/ImageResource.rb', line 56
def self.is_png_image()
[0] == 0x89 && [1] == 0x50 && [2] == 0x4E && [3] == 0x47 &&
[4] == 0x0D && [5] == 0x0A && [6] == 0x1A && [7] == 0x0A
end
|
.is_tiff_image(header) ⇒ Object
61
62
63
64
|
# File 'lib/ruby_client/ImageResource.rb', line 61
def self.is_tiff_image()
([0] == 0x49 && [1] == 0x49 && [2] == 0x2A && [3] == 0x00) ||
([0] == 0x4D && [1] == 0x4D && [2] == 0x00 && [3] == 0x2A)
end
|
.is_valid_bitmap_image(header) ⇒ Object
75
76
77
|
# File 'lib/ruby_client/ImageResource.rb', line 75
def self.is_valid_bitmap_image()
[0] == 0x42 && [1] == 0x4D
end
|
Instance Method Details
#_file_extension ⇒ Object
#to_json(_options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/ruby_client/ImageResource.rb', line 79
def to_json(_options = {})
json_array = {}
json_array["type"] = "image"
json_array["align"] = 1
json_array["vAlign"] = 1
json_array["resourceName"] = @resource_name
JSON.pretty_generate(json_array)
end
|