Class: CloudmersiveImageRecognitionApiClient::ResizeApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudmersive-image-recognition-api-client/api/resize_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ResizeApi

Returns a new instance of ResizeApi.



19
20
21
# File 'lib/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#resize_post(max_width, max_height, image_file, opts = {}) ⇒ String

Resize an image while preserving aspect ratio Resize an image to a maximum width and maximum height, while preserving the image’s original aspect ratio. Resize is EXIF-aware.

Parameters:

  • max_width

    Maximum width of the output image - final image will be as large as possible while less than or equial to this width

  • max_height

    Maximum height of the output image - final image will be as large as possible while less than or equial to this height

  • image_file

    Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


29
30
31
32
# File 'lib/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 29

def resize_post(max_width, max_height, image_file, opts = {})
  data, _status_code, _headers = resize_post_with_http_info(max_width, max_height, image_file, opts)
  data
end

#resize_post_with_http_info(max_width, max_height, image_file, opts = {}) ⇒ Array<(String, Fixnum, Hash)>

Resize an image while preserving aspect ratio Resize an image to a maximum width and maximum height, while preserving the image&#39;s original aspect ratio. Resize is EXIF-aware.

Parameters:

  • max_width

    Maximum width of the output image - final image will be as large as possible while less than or equial to this width

  • max_height

    Maximum height of the output image - final image will be as large as possible while less than or equial to this height

  • image_file

    Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Fixnum, Hash)>)

    String data, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
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/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 41

def resize_post_with_http_info(max_width, max_height, image_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResizeApi.resize_post ...'
  end
  # verify the required parameter 'max_width' is set
  if @api_client.config.client_side_validation && max_width.nil?
    fail ArgumentError, "Missing the required parameter 'max_width' when calling ResizeApi.resize_post"
  end
  # verify the required parameter 'max_height' is set
  if @api_client.config.client_side_validation && max_height.nil?
    fail ArgumentError, "Missing the required parameter 'max_height' when calling ResizeApi.resize_post"
  end
  # verify the required parameter 'image_file' is set
  if @api_client.config.client_side_validation && image_file.nil?
    fail ArgumentError, "Missing the required parameter 'image_file' when calling ResizeApi.resize_post"
  end
  # resource path
  local_var_path = '/image/resize/preserveAspectRatio/{maxWidth}/{maxHeight}'.sub('{' + 'maxWidth' + '}', max_width.to_s).sub('{' + 'maxHeight' + '}', max_height.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])

  # form parameters
  form_params = {}
  form_params['imageFile'] = image_file

  # http body (model)
  post_body = nil
  auth_names = ['Apikey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'String')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ResizeApi#resize_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#resize_resize_simple(width, height, image_file, opts = {}) ⇒ String

Resize an image Resize an image to a specific width and specific height. Resize is EXIF-aware.

Parameters:

  • width

    Width of the output image - final image will be exactly this width

  • height

    Height of the output image - final image will be exactly this height

  • image_file

    Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


96
97
98
99
# File 'lib/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 96

def resize_resize_simple(width, height, image_file, opts = {})
  data, _status_code, _headers = resize_resize_simple_with_http_info(width, height, image_file, opts)
  data
end

#resize_resize_simple_with_http_info(width, height, image_file, opts = {}) ⇒ Array<(String, Fixnum, Hash)>

Resize an image Resize an image to a specific width and specific height. Resize is EXIF-aware.

Parameters:

  • width

    Width of the output image - final image will be exactly this width

  • height

    Height of the output image - final image will be exactly this height

  • image_file

    Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Fixnum, Hash)>)

    String data, response status code and response headers



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/cloudmersive-image-recognition-api-client/api/resize_api.rb', line 108

def resize_resize_simple_with_http_info(width, height, image_file, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResizeApi.resize_resize_simple ...'
  end
  # verify the required parameter 'width' is set
  if @api_client.config.client_side_validation && width.nil?
    fail ArgumentError, "Missing the required parameter 'width' when calling ResizeApi.resize_resize_simple"
  end
  # verify the required parameter 'height' is set
  if @api_client.config.client_side_validation && height.nil?
    fail ArgumentError, "Missing the required parameter 'height' when calling ResizeApi.resize_resize_simple"
  end
  # verify the required parameter 'image_file' is set
  if @api_client.config.client_side_validation && image_file.nil?
    fail ArgumentError, "Missing the required parameter 'image_file' when calling ResizeApi.resize_resize_simple"
  end
  # resource path
  local_var_path = '/image/resize/target/{width}/{height}'.sub('{' + 'width' + '}', width.to_s).sub('{' + 'height' + '}', height.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])

  # form parameters
  form_params = {}
  form_params['imageFile'] = image_file

  # http body (model)
  post_body = nil
  auth_names = ['Apikey']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'String')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ResizeApi#resize_resize_simple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end