cloudmersive-image-recognition-api-client 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,5 +75,61 @@ module CloudmersiveImageRecognitionApiClient
75
75
  end
76
76
  return data, status_code, headers
77
77
  end
78
+
79
+ # Returns the image metadata, including EXIF and resolution
80
+ # Returns the metadata information on the image, including file type, EXIF (if available), and resolution.
81
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
82
+ # @param [Hash] opts the optional parameters
83
+ # @return [ImageMetadata]
84
+ def info_get_metadata(image_file, opts = {})
85
+ data, _status_code, _headers = info_get_metadata_with_http_info(image_file, opts)
86
+ return data
87
+ end
88
+
89
+ # Returns the image metadata, including EXIF and resolution
90
+ # Returns the metadata information on the image, including file type, EXIF (if available), and resolution.
91
+ # @param image_file Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Array<(ImageMetadata, Fixnum, Hash)>] ImageMetadata data, response status code and response headers
94
+ def info_get_metadata_with_http_info(image_file, opts = {})
95
+ if @api_client.config.debugging
96
+ @api_client.config.logger.debug "Calling API: InfoApi.info_get_metadata ..."
97
+ end
98
+ # verify the required parameter 'image_file' is set
99
+ if @api_client.config.client_side_validation && image_file.nil?
100
+ fail ArgumentError, "Missing the required parameter 'image_file' when calling InfoApi.info_get_metadata"
101
+ end
102
+ # resource path
103
+ local_var_path = "/image/get-info/metadata"
104
+
105
+ # query parameters
106
+ query_params = {}
107
+
108
+ # header parameters
109
+ header_params = {}
110
+ # HTTP header 'Accept' (if needed)
111
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
112
+ # HTTP header 'Content-Type'
113
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
114
+
115
+ # form parameters
116
+ form_params = {}
117
+ form_params["imageFile"] = image_file
118
+
119
+ # http body (model)
120
+ post_body = nil
121
+ auth_names = ['Apikey']
122
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
123
+ :header_params => header_params,
124
+ :query_params => query_params,
125
+ :form_params => form_params,
126
+ :body => post_body,
127
+ :auth_names => auth_names,
128
+ :return_type => 'ImageMetadata')
129
+ if @api_client.config.debugging
130
+ @api_client.config.logger.debug "API called: InfoApi#info_get_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
131
+ end
132
+ return data, status_code, headers
133
+ end
78
134
  end
79
135
  end
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # Metadata from an image
17
+ class ImageMetadata
18
+ # True if the operation was successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # File format of the image
22
+ attr_accessor :file_format
23
+
24
+ # Width of the image in pixels
25
+ attr_accessor :width
26
+
27
+ # Height of the image in pixels
28
+ attr_accessor :height
29
+
30
+ # Bits per pixel
31
+ attr_accessor :bit_depth
32
+
33
+ # Color space of the image
34
+ attr_accessor :color_space
35
+
36
+ # Name of the EXIF profile used
37
+ attr_accessor :exif_profile_name
38
+
39
+ # EXIF tags and values embedded in the image
40
+ attr_accessor :exif_values
41
+
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'successful' => :'Successful',
47
+ :'file_format' => :'FileFormat',
48
+ :'width' => :'Width',
49
+ :'height' => :'Height',
50
+ :'bit_depth' => :'BitDepth',
51
+ :'color_space' => :'ColorSpace',
52
+ :'exif_profile_name' => :'ExifProfileName',
53
+ :'exif_values' => :'ExifValues'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.swagger_types
59
+ {
60
+ :'successful' => :'BOOLEAN',
61
+ :'file_format' => :'String',
62
+ :'width' => :'Integer',
63
+ :'height' => :'Integer',
64
+ :'bit_depth' => :'Integer',
65
+ :'color_space' => :'String',
66
+ :'exif_profile_name' => :'String',
67
+ :'exif_values' => :'Array<ImageMetadataExifValue>'
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
78
+
79
+ if attributes.has_key?(:'Successful')
80
+ self.successful = attributes[:'Successful']
81
+ end
82
+
83
+ if attributes.has_key?(:'FileFormat')
84
+ self.file_format = attributes[:'FileFormat']
85
+ end
86
+
87
+ if attributes.has_key?(:'Width')
88
+ self.width = attributes[:'Width']
89
+ end
90
+
91
+ if attributes.has_key?(:'Height')
92
+ self.height = attributes[:'Height']
93
+ end
94
+
95
+ if attributes.has_key?(:'BitDepth')
96
+ self.bit_depth = attributes[:'BitDepth']
97
+ end
98
+
99
+ if attributes.has_key?(:'ColorSpace')
100
+ self.color_space = attributes[:'ColorSpace']
101
+ end
102
+
103
+ if attributes.has_key?(:'ExifProfileName')
104
+ self.exif_profile_name = attributes[:'ExifProfileName']
105
+ end
106
+
107
+ if attributes.has_key?(:'ExifValues')
108
+ if (value = attributes[:'ExifValues']).is_a?(Array)
109
+ self.exif_values = value
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ return invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+ return true
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ successful == o.successful &&
134
+ file_format == o.file_format &&
135
+ width == o.width &&
136
+ height == o.height &&
137
+ bit_depth == o.bit_depth &&
138
+ color_space == o.color_space &&
139
+ exif_profile_name == o.exif_profile_name &&
140
+ exif_values == o.exif_values
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Fixnum] Hash code
151
+ def hash
152
+ [successful, file_format, width, height, bit_depth, color_space, exif_profile_name, exif_values].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ self.class.swagger_types.each_pair do |key, type|
161
+ if type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :DateTime
182
+ DateTime.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :BOOLEAN
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
213
+ temp_model.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ next if value.nil?
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map{ |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ end
@@ -0,0 +1,209 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # EXIF tag and value
17
+ class ImageMetadataExifValue
18
+ # Tag name for the EXIF value
19
+ attr_accessor :tag
20
+
21
+ # Date type of the EXIF value
22
+ attr_accessor :data_type
23
+
24
+ # Value, formatted as a string of the EXIF value
25
+ attr_accessor :data_value
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'tag' => :'Tag',
32
+ :'data_type' => :'DataType',
33
+ :'data_value' => :'DataValue'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'tag' => :'String',
41
+ :'data_type' => :'String',
42
+ :'data_value' => :'String'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'Tag')
55
+ self.tag = attributes[:'Tag']
56
+ end
57
+
58
+ if attributes.has_key?(:'DataType')
59
+ self.data_type = attributes[:'DataType']
60
+ end
61
+
62
+ if attributes.has_key?(:'DataValue')
63
+ self.data_value = attributes[:'DataValue']
64
+ end
65
+
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ return invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ return true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ tag == o.tag &&
87
+ data_type == o.data_type &&
88
+ data_value == o.data_value
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Fixnum] Hash code
99
+ def hash
100
+ [tag, data_type, data_value].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.swagger_types.each_pair do |key, type|
109
+ if type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ DateTime.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :String
134
+ value.to_s
135
+ when :Integer
136
+ value.to_i
137
+ when :Float
138
+ value.to_f
139
+ when :BOOLEAN
140
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
141
+ true
142
+ else
143
+ false
144
+ end
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ else # model
160
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
161
+ temp_model.build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = self.send(attr)
183
+ next if value.nil?
184
+ hash[param] = _to_hash(value)
185
+ end
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map{ |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to? :to_hash
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+ end