Class: Aspose::Cloud::Imaging::Converter
- Inherits:
-
Object
- Object
- Aspose::Cloud::Imaging::Converter
- Defined in:
- lib/imaging/converter.rb
Instance Method Summary collapse
-
#convert_local_file(input_file_path, output_filename, save_format) ⇒ Object
convert an image file to a different format @param string input_file_path Path of the input file.
-
#convert_tiff_to_fax(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
convert an image file to a fax.
-
#initialize(filename) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(filename) ⇒ Converter
Returns a new instance of Converter.
5 6 7 8 9 |
# File 'lib/imaging/converter.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
#convert_local_file(input_file_path, output_filename, save_format) ⇒ Object
convert an image file to a different format
@param string input_file_path Path of the input file.
@param string output_filename Name of the output file.
@param string save_format Output file format.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/imaging/converter.rb', line 17 def convert_local_file(input_file_path, output_filename, save_format) raise 'input_file_path not specified.' if input_file_path.empty? raise 'output_filename not specified.' if output_filename.empty? raise 'save_format not specified.' if save_format.empty? str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/#{@filename}/saveAs?format=#{save_format}" signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json', :payload=>File.new(input_file_path, 'rb')}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output.empty? save_format = 'zip' if save_format.eql?('html') output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{Aspose::Cloud::Common::Utils.get_filename(output_filename)}.#{save_format}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |
#convert_tiff_to_fax(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object
convert an image file to a fax
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/imaging/converter.rb', line 39 def convert_tiff_to_fax(folder_name = '', storage_type = 'Aspose', storage_name = '') str_uri = "#{Aspose::Cloud::Common::Product.product_uri}/imaging/tiff/#{@filename}/toFax" 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}#{@filename}" Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) end valid_output end |