Skip to content

Instantly share code, notes, and snippets.

@aspose-imaging
Last active April 7, 2017 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-imaging/9f7c8fb7229ef911df9df46bd1c1d639 to your computer and use it in GitHub Desktop.
Save aspose-imaging/9f7c8fb7229ef911df9df46bd1c1d639 to your computer and use it in GitHub Desktop.
Aspose.Imaging-for-Cloud-for-Ruby
The GIST contains Ruby code snippets for examples of Aspose.Imaging for Cloud.
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class BMPProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def get_image_bmp
file_name = "sample.bmp"
upload_file(file_name)
bits_per_pixel = 24
horizontal_resolution = 300
vertical_resolution = 300
response = @imaging_api.get_image_bmp(file_name, bits_per_pixel, horizontal_resolution, vertical_resolution)
end
end
bmpProperties = BMPProperties.new()
puts bmpProperties.get_image_bmp
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class BMPProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
# Update parameters of bmp image.
def update_bmp_image_parameters
bits_per_pixel = 24
horizontal_resolution = 300
vertical_resolution = 300
file_name = "sample.bmp"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
response = @imaging_api.post_image_bmp(bits_per_pixel, horizontal_resolution, vertical_resolution, file)
end
end
bmpProperties = BMPProperties.new()
puts bmpProperties.update_bmp_image_parameters
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ImageProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Get properties of an image.
def get_image_properties
file_name = "demo.tif"
upload_file(file_name)
response = @imaging_api.get_image_properties(file_name)
end
end
imageProperties = ImageProperties.new()
puts imageProperties.get_image_properties
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class GIFProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def get_image_gif
file_name = "sample.gif"
upload_file(file_name)
response = @imaging_api.get_image_gif(file_name)
end
end
gifProperties = GIFProperties.new()
puts gifProperties.get_image_gif
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class GIFProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def update_gif_image_parameters
file_name = "sample.gif"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
opts = {background_color_index: "255", color_resolution: "7"}
response = @imaging_api.post_image_gif(file, opts)
end
end
gifProperties = GIFProperties.new()
puts gifProperties.update_gif_image_parameters
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class JPGProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def get_image_jpg
file_name = "aspose.jpg"
upload_file(file_name)
opts = {quality: 100, compression_type: "progressive"}
response = @imaging_api.get_image_jpg(file_name, opts)
end
end
jpgProperties = JPGProperties.new()
puts jpgProperties.get_image_jpg
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class JPGProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def update_jpg_image_parameters
file_name = "aspose.jpg"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
opts = {quality: 100, compression_type: "progressive"}
response = @imaging_api.post_image_jpg(file, opts)
end
end
jpgProperties = JPGProperties.new()
puts jpgProperties.update_jpg_image_parameters
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class PNGProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def get_image_png
file_name = "aspose_imaging_for_cloud.png"
upload_file(file_name)
opts = {from_scratch: true}
response = @imaging_api.get_image_png(file_name, opts)
end
end
pngProperties = PNGProperties.new()
puts pngProperties.get_image_png
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class PNGProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def update_png_image_parameters
file_name = "aspose_imaging_for_cloud.png"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
opts = {from_scratch: true}
response = @imaging_api.post_image_png(file, opts)
end
end
pngProperties = PNGProperties.new()
puts pngProperties.update_png_image_parameters
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class PSDProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def get_image_psd
file_name = "sample.psd"
upload_file(file_name)
opts = {channels_count: 3, compression_method: "rle"}
response = @imaging_api.get_image_psd(file_name, opts)
end
end
psdProperties = PSDProperties.new()
puts psdProperties.get_image_psd
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class PSDProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def update_psd_image_parameters
file_name = "sample.psd"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
opts = {channels_count: 3, compression_method: "rle"}
response = @imaging_api.post_image_psd(file, opts)
end
end
psdProperties = PSDProperties.new()
puts psdProperties.update_psd_image_parameters
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFProperties
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../../data/" << file_name,"r") { |io| io.read } )
end
def update_tiff_image
file_name = "demo.tif"
file = File.open("../../../../data/" << file_name,"r") { |io| io.read }
opts = {compression: "ccittfax3", resolution_unit: "inch", bit_depth: 1}
response = @imaging_api.post_process_tiff(file, opts)
end
end
tiffProperties = TIFFProperties.new()
puts tiffProperties.update_tiff_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Append tiff image.
def append_tiff_image
file_name = "sample.tif"
upload_file(file_name)
append_file = "TestDemo.tif"
upload_file(append_file)
opts = {append_file: append_file}
response = @imaging_api.post_tiff_append(file_name, opts)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.append_tiff_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Change scale of an image from body
def change_image_scale
format = "jpg"
new_width = 200
new_height = 200
file_name = "aspose_imaging_for_cloud.png"
file = File.open("../../../data/" << file_name,"r") { |io| io.read }
response = @imaging_api.post_change_image_scale(format, new_width, new_height, file)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.change_image_scale
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Crop existing image
def crop_image
file_name = "aspose.jpg"
upload_file(file_name)
format = "png"
x = 30
y = 40
width = 100
height = 100
response = @imaging_api.get_crop_image(file_name, format, x, y, width, height)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.crop_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Export existing image to another format. Image is passed as request body.
def export_image_to_another_format
format = "png"
file_name = "aspose.jpg"
file = File.open("../../../data/" << file_name,"r") { |io| io.read }
response = @imaging_api.post_image_save_as(format, file)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.export_image_to_another_format
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Get tiff image for fax.
def get_tiff_image_for_fax
file_name = "TestDemo.tif"
upload_file(file_name)
response = @imaging_api.get_tiff_to_fax(file_name)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.get_tiff_image_for_fax
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class ManipulateImage
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Rotate and flip existing image
def rotate_and_flip_image
file_name = "aspose.jpg"
upload_file(file_name)
format = "png"
method = "Rotate180FlipX"
response = @imaging_api.get_image_rotate_flip(file_name, format, method)
end
end
manipulateImage = ManipulateImage.new()
puts manipulateImage.rotate_and_flip_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Crop image from body
def crop_image
format = "png"
x = 30
y = 40
width = 100
height = 100
file_name = "aspose.jpg"
file = File.open("../../../data/" << file_name,"r") { |io| io.read }
response = @imaging_api.post_crop_image(format, x, y, width, height, file)
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.crop_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Get separate frame of tiff image
def get_frame_of_tiff_image
file_name = "sample-multi.tif"
upload_file(file_name)
frame_id = 1
response = @imaging_api.get_image_frame(file_name, frame_id)
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.get_frame_of_tiff_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Get properties of a tiff frame.
def get_properties_of_tiff_frame
file_name = "TestDemo.tif"
upload_file(file_name)
frame_id = 0
response = @imaging_api.get_image_frame_properties(file_name, frame_id)
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.get_properties_of_tiff_frame
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
def get_frame_of_tiff_image
file_name = "sample-multi.tif"
upload_file(file_name)
frame_id = 1
response = @imaging_api.get_image_frame(file_name, frame_id, {new_width: 0, new_height: 0, x: 0, y: 0,
rect_width: 0, rect_height: 0, rotate_flip_method: "rotate90flipnone",
save_other_frames: false})
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.get_frame_of_tiff_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
# Get separate frame of tiff image
def get_frame_of_tiff_image
file_name = "sample-multi.tif"
upload_file(file_name)
frame_id = 1
response = @imaging_api.get_image_frame(file_name, frame_id, {new_width: 300, new_height: 300, x: 100, y: 100,
rect_width: 200, rect_height: 200, save_other_frames: false})
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.get_frame_of_tiff_image
# For complete examples and data files, please go to https://github.com/aspose-imaging/Aspose.Imaging-for-Cloud
require 'aspose_imaging_cloud'
class TIFFFrames
include AsposeImagingCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("", "")
@imaging_api = ImagingApi.new
end
def upload_file(file_name)
@storage_api = StorageApi.new
response = @storage_api.put_create(file_name, File.open("../../../data/" << file_name,"r") { |io| io.read } )
end
def get_frame_of_tiff_image
file_name = "TestDemo.tif"
upload_file(file_name)
frame_id = 0
response = @imaging_api.get_image_frame(file_name, frame_id, {new_width: 0, new_height: 0, x: 0, y: 0,
rect_width: 0, rect_height: 0, rotate_flip_method: "rotate90flipnone",
save_other_frames: false})
end
end
tiffFrames = TIFFFrames.new()
puts tiffFrames.get_frame_of_tiff_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment