Class: Aspose::Cloud::Imaging::Extractor

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Extractor

Returns a new instance of Extractor.



5
6
7
8
9
# File 'lib/imaging/extractor.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

#crop_frame(frame_id, x_position, y_position, rect_width, rect_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Crop a TIFF Frame

@param number frame_id ID of the frame.
@param number x_position X position of start point for cropping rectangle.
@param number y_position Y position of start point for cropping rectangle.
@param number rect_width New width of the scaled image.
@param number rect_height New height of the scaled image.
@param string output_filename Name of the output file.


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/imaging/extractor.rb', line 79

def crop_frame(frame_id, x_position, y_position, rect_width, rect_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?
  raise 'x_position not specified.' if x_position.nil?
  raise 'y_position not specified.' if y_position.nil?
  raise 'rect_width not specified.' if rect_width.nil?
  raise 'rect_height not specified.' if rect_height.nil?
  raise 'output_filename not specified.' if output_filename.empty?

  str_uri = "#{@base_uri}/frames/#{frame_id}?saveOtherFrames=false&x=#{x_position}&y=#{y_position}&rectWidth=#{rect_width}&rectHeight=#{rect_height}&outPath=#{output_filename}"
  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, {: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(output_filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#extract_frame(frame_id, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/imaging/extractor.rb', line 25

def extract_frame(frame_id, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?
  raise 'output_filename not specified.' if output_filename.empty?

  str_uri = "#{@base_uri}/frames/#{frame_id}?saveOtherFrames=false&outPath=#{output_filename}"
  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, {: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(output_filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

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

Get TIFF Frame Properties

@param number frame_id ID of the frame.


15
16
17
18
19
20
21
22
23
# File 'lib/imaging/extractor.rb', line 15

def get_tiff_frame_properties(frame_id, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?

  str_uri = "#{@base_uri}/frames/#{frame_id}/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)

  response = JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))
end

#manipulate_frame(frame_id, rotate_flip_method, new_width, new_height, x_position, y_position, rect_width, rect_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Manipulate a Frame and Save the Modified Frame Along with Unmodified Frames

@param number frame_id ID of the frame.
@param string rotate_flip_method RotateFlip method.
@param number rect_width New width of the scaled image.
@param number rect_height New height of the scaled image.
@param number x_position X position of start point for cropping rectangle.
@param number y_position Y position of start point for cropping rectangle.
@param number rect_width Width of cropping rectangle.
@param number rect_height Height of cropping rectangle.
@param string output_filename Name of the output file.


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/imaging/extractor.rb', line 138

def manipulate_frame(frame_id, rotate_flip_method, new_width, new_height, x_position, y_position, rect_width, rect_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?
  raise 'rotate_flip_method not specified.' if rotate_flip_method.empty?
  raise 'new_width not specified.' if new_width.nil?
  raise 'new_height not specified.' if new_height.nil?
  raise 'x_position not specified.' if x_position.nil?
  raise 'y_position not specified.' if y_position.nil?
  raise 'rect_width not specified.' if rect_width.nil?
  raise 'rect_height not specified.' if rect_height.nil?
  raise 'output_filename not specified.' if output_filename.empty?

  str_uri = "#{@base_uri}/frames/#{frame_id}?saveOtherFrames=true&rotateFlipMethod=#{rotate_flip_method}&newWidth=#{new_width}&newHeight=#{new_height}&x=#{x_position}&y=#{x_position}&rectWidth=#{rect_width}&rectHeight=#{rect_height}&outPath=#{output_filename}"
  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, {: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(output_filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#resize_frame(frame_id, new_width, new_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Resize a TIFF Frame

@param number frame_id ID of the frame.
@param number new_width New width of the frame.
@param number new_height New height of the frame.
@param string output_filename Name of the output file.


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/imaging/extractor.rb', line 50

def resize_frame(frame_id, new_width, new_height, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?
  raise 'new_width not specified.' if new_width.nil?
  raise 'new_height not specified.' if new_height.nil?
  raise 'output_filename not specified.' if output_filename.empty?

  str_uri = "#{@base_uri}/frames/#{frame_id}?saveOtherFrames=false&newWidth=#{new_width}&newHeight=#{new_height}&outPath=#{output_filename}"
  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, {: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(output_filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#rotate_frame(frame_id, rotate_flip_method, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

RotateFlip a TIFF Frame

@param number frame_id ID of the frame.
@param string rotate_flip_method RotateFlip method.
@param string output_filename Name of the output file.


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/imaging/extractor.rb', line 107

def rotate_frame(frame_id, rotate_flip_method, output_filename, folder_name = '', storage_type = 'Aspose', storage_name = '')
  raise 'frame_id not specified.' if frame_id.nil?
  raise 'rotate_flip_method not specified.' if rotate_flip_method.empty?
  raise 'output_filename not specified.' if output_filename.empty?

  str_uri = "#{@base_uri}/frames/#{frame_id}?saveOtherFrames=false&rotateFlipMethod=#{rotate_flip_method}&outPath=#{output_filename}"
  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, {: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(output_filename)}_updated.tiff"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end