Class: Aspose::Cloud::Imaging::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/imaging/document.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Document

Returns a new instance of Document.



5
6
7
8
9
# File 'lib/imaging/document.rb', line 5

def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/#{@filename}"
end

Instance Method Details

#get_properties(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Get Document’s properties



14
15
16
17
18
19
# File 'lib/imaging/document.rb', line 14

def get_properties(folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/properties"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))
end

#update_bmp_properties(bits_per_px, h_resolution, v_resolution, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update BMP Image Properties

@param number bits_per_px Color depth.
@param number h_resolution New horizontal resolution.
@param number v_resolution New vertical resolution.
@param string output_path Path to updated file.


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/imaging/document.rb', line 28

def update_bmp_properties(bits_per_px, h_resolution, v_resolution, output_path,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/bmp"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:bitsPerPixel=> bits_per_px,
                                                             :horizontalResolution=> h_resolution,
                                                             :verticalResolution=> v_resolution,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.get(signed_str_uri, {:content_type=>'application/json',
                                                    :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_updated.bmp"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_bmp_properties_local(input_file_path, bits_per_px, h_resolution, v_resolution, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update BMP Image Properties without Storage

@param number input_file_path Path of the input file.
@param number bits_per_px Color depth.
@param number h_resolution New horizontal resolution.
@param string v_resolution New vertical resolution.


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/imaging/document.rb', line 56

def update_bmp_properties_local(input_file_path, bits_per_px, h_resolution, v_resolution,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/bmp"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:bitsPerPixel=> bits_per_px,
                                                             :horizontalResolution=> h_resolution,
                                                             :verticalResolution=> v_resolution})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, File.new(input_file_path, 'rb'),
                                    {:content_type=>'application/json', :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(input_file_path)}_updated.bmp"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_gif_properties(bg_color_index, px_aspect_ratio, interlaced, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update GIF Image Properties

@param number bg_color_index Index of the background color.
@param number px_aspect_ratio Pixel aspect ratio. 
@param boolean interlaced Specifies if image is interlaced.
@param string output_path Path to updated file.


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/imaging/document.rb', line 83

def update_gif_properties(bg_color_index, px_aspect_ratio, interlaced, output_path,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/gif"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:backgroundColorIndex=> bg_color_index,
                                                             :pixelAspectRatio=> px_aspect_ratio,
                                                             :interlaced=> interlaced,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.get(signed_str_uri, {:content_type=>'application/json',
                                                    :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_updated.gif"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_gif_properties_local(input_file_path, bg_color_index, px_aspect_ratio, interlaced, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update GIF Image Properties without Storage

@param string input_file_path Path of the input file.
@param number bg_color_index Index of the background color.
@param number px_aspect_ratio Pixel aspect ratio. 
@param boolean interlaced Specifies if image is interlaced.


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/imaging/document.rb', line 111

def update_gif_properties_local(input_file_path, bg_color_index, px_aspect_ratio, interlaced,
                                folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/gif"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:backgroundColorIndex=> bg_color_index,
                                                             :pixelAspectRatio=> px_aspect_ratio,
                                                             :interlaced=> interlaced})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, File.new(input_file_path, 'rb'),
                                    {:content_type=>'application/json', :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(input_file_path)}_updated.gif"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_jpg_properties(quality, compression_type, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update JPG Image Properties

@param number quality Quality of image. From 0 to 100
@param string compression_type Compression type. 
@param string output_path Path to updated file.


137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/imaging/document.rb', line 137

def update_jpg_properties(quality, compression_type, output_path,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/jpg"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:quality=> quality,
                                                             :compressionType=> compression_type,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.get(signed_str_uri, {:content_type=>'application/json',
                                                    :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_updated.jpg"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_jpg_properties_local(input_file_path, quality, compression_type, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update JPG Image Properties without Storage

@param string input_file_path Path of the file.
@param number quality Quality of image. From 0 to 100
@param string compression_type Compression type.


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/imaging/document.rb', line 163

def update_jpg_properties_local(input_file_path, quality, compression_type,
                                folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/jpg"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:quality=> quality,
                                                             :compressionType=> compression_type})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, File.new(input_file_path, 'rb'),
                                    {:content_type=>'application/json', :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(input_file_path)}_updated.jpg"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_psd_properties(channels_count, compression_method, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update PSD Image Properties

@param number channels_count Count of channels.
@param string compression_method Compression method.
@param string output_path Path to updated file.


254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/imaging/document.rb', line 254

def update_psd_properties(channels_count, compression_method, output_path,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/psd"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:channelsCount=> channels_count,
                                                             :compressionMethod=> compression_method,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
puts signed_str_uri
  response_stream = RestClient.get(signed_str_uri, {:content_type=>'application/json',
                                                    :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_updated.psd"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_psd_properties_local(input_file_path, channels_count, compression_method, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update PSD Image Properties without Storage

@param string input_file_path Path of the input file.
@param number channels_count Count of channels.
@param string compression_method Compression method.


280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/imaging/document.rb', line 280

def update_psd_properties_local(input_file_path, channels_count, compression_method,
                                folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/psd"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:channelsCount=> channels_count,
                                                             :compressionMethod=> compression_method})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, File.new(input_file_path, 'rb'),
                                    {:content_type=>'application/json', :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(input_file_path)}_updated.psd"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_tiff_properties(compression, resolution_unit, new_width, new_height, horizontal_resolution, vertical_resolution, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update TIFF Image Properties

@param string compression Type of the compression.
@param string resolution_unit Resolution unit: none, inch, centimeter.
@param number new_width New image width.
@param number new_height New image height.
@param number horizontal_resolution Horizontal resolution.
@param number vertical_resolution Vertical resolution.
@param string output_path Path to updated file.


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/imaging/document.rb', line 192

def update_tiff_properties(compression, resolution_unit, new_width, new_height, horizontal_resolution, vertical_resolution, output_path,
                          folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/tiff"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:resolutionUnit=> resolution_unit,
                                                             :compression=> compression,
                                                             :newWidth=> new_width,
                                                             :newHeight=> new_height,
                                                             :horizontalResolution=> horizontal_resolution,
                                                             :verticalResolution=> vertical_resolution,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, '', {:content_type=>'application/json',
                                                    :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(@filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#update_tiff_properties_local(input_file_path, resolution_unit, new_width, new_height, horizontal_resolution, vertical_resolution, output_path, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Update TIFF Image Properties without Storage

@param string input_file_path Path of the input file.
@param string resolution_unit Resolution unit: none, inch, centimeter.
@param number new_width New image width.
@param number new_height New image height.
@param number horizontal_resolution Horizontal resolution.
@param number vertical_resolution Vertical resolution.


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/imaging/document.rb', line 225

def update_tiff_properties_local(input_file_path, resolution_unit, new_width, new_height, horizontal_resolution, vertical_resolution, output_path,
                                 folder_name = '', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/tiff"
  str_uri = Aspose::Cloud::Common::Utils.build_uri(str_uri, {:resolutionUnit=> resolution_unit,
                                                             :newWidth=> new_width,
                                                             :newHeight=> new_height,
                                                             :horizontalResolution=> horizontal_resolution,
                                                             :verticalResolution=> vertical_resolution,
                                                             :outPath=> output_path})
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri, folder_name, storage_name, storage_type)
  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)

  response_stream = RestClient.post(signed_str_uri, File.new(input_file_path, 'rb'),
                                    {:content_type=>'application/json', :accept=>'application/json'})
  valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(input_file_path)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end