Skip to content

Commit

Permalink
Implementation of Tiff Image Functions
Browse files Browse the repository at this point in the history
Working with TIFF Properties
Merge Tiff Images
Working with TIFF Frames
  • Loading branch information
assadvirgo committed Apr 7, 2015
1 parent 83b7757 commit e42d469
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 1 deletion.
241 changes: 241 additions & 0 deletions lib/aspose-imaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ AsposeImaging.prototype.convertTiffToFax = function (fileName, callback) {

};


AsposeImaging.prototype.appendTiff = function (targetFile, appendFile, callback) {
targetFile = typeof targetFile !== 'undefined' ? targetFile : '';
appendFile = typeof appendFile !== 'undefined' ? appendFile : '';

if(targetFile === '' || appendFile === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/tiff/' + targetFile + '/appendTiff?appendFile=' + appendFile;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('POST', signedURI, '', function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}

});

};

AsposeImaging.prototype.convertLocalFile = function (fileStream, fileName, saveFormat, callback) {
fileStream = typeof fileStream !== 'undefined' ? fileStream : '';
fileName = typeof fileName !== 'undefined' ? fileName : '';
Expand All @@ -78,6 +100,77 @@ AsposeImaging.prototype.convertLocalFile = function (fileStream, fileName, saveF

/* Document Methods */

AsposeImaging.prototype.updateTiffProperties = function (fileName, bitDepth, compression, resolutionUnit, newWidth, newHeight, horizontalResolution, verticalResolution, outputPath, callback) {
fileName = typeof fileName !== 'undefined' ? fileName : '';
bitDepth = typeof bitDepth !== 'undefined' ? bitDepth : '';
outputPath = typeof outputPath !== 'undefined' ? outputPath : '';
compression = typeof compression !== 'undefined' ? compression : '';
resolutionUnit = typeof resolutionUnit !== 'undefined' ? resolutionUnit : '';
newWidth = typeof newWidth !== 'undefined' ? newWidth : '';
newHeight = typeof newHeight !== 'undefined' ? newHeight : '';
horizontalResolution = typeof horizontalResolution !== 'undefined' ? horizontalResolution : '';
verticalResolution = typeof verticalResolution !== 'undefined' ? verticalResolution : '';

if(fileName === '' || outputPath === ''){
throw new Error('missing required parameters.');
}

//First download the tiff file
var strURI = this.baseURI + 'storage/file/' + fileName;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

var appSID = this.appSID;
var appKey = this.appKey;
var baseURI = this.baseURI;

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

var strURI = baseURI + 'imaging/tiff?compression=' + compression +
'&resolutionUnit=' + resolutionUnit + '&newWidth=' + newWidth +
'&newHeight=' + newHeight + '&horizontalResolution=' + horizontalResolution +
'&verticalResolution=' + verticalResolution + '&bitDepth=' + bitDepth + '&output=' + outputPath;
var signedURI = Utils.Sign(strURI,appSID,appKey);


Utils.ProcessCommandStream('POST', signedURI, data, function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}

});

});
};

AsposeImaging.prototype.updateTiffPropertiesLocal = function (fileStream, bitDepth, compression, resolutionUnit, newWidth, newHeight, horizontalResolution, verticalResolution, callback) {
fileStream = typeof fileStream !== 'undefined' ? fileStream : '';
bitDepth = typeof bitDepth !== 'undefined' ? bitDepth : '';
compression = typeof compression !== 'undefined' ? compression : '';
resolutionUnit = typeof resolutionUnit !== 'undefined' ? resolutionUnit : '';
newWidth = typeof newWidth !== 'undefined' ? newWidth : '';
newHeight = typeof newHeight !== 'undefined' ? newHeight : '';
horizontalResolution = typeof horizontalResolution !== 'undefined' ? horizontalResolution : '';
verticalResolution = typeof verticalResolution !== 'undefined' ? verticalResolution : '';

if(fileStream === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/tiff?compression=' + compression +
'&resolutionUnit=' + resolutionUnit + '&newWidth=' + newWidth +
'&newHeight=' + newHeight + '&horizontalResolution=' + horizontalResolution +
'&verticalResolution=' + verticalResolution + '&bitDepth=' + bitDepth;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandStream('POST', signedURI, fileStream, function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}

});
};

AsposeImaging.prototype.updatePSDPropertiesLocal = function (fileStream, channelsCount, compressionMethod, callback) {
fileStream = typeof fileStream !== 'undefined' ? fileStream : '';
Expand Down Expand Up @@ -294,6 +387,28 @@ AsposeImaging.prototype.getProperties = function(fileName,callback){
});
};

AsposeImaging.prototype.getTiffFrameProperties = function(fileName,frameID,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
frameID = typeof frameID !== 'undefined' ? frameID : '';

if(fileName === '' || frameID === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + fileName + '/frames/' + frameID + '/properties';
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('GET',signedURI,'',function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

/* Image Methods */

AsposeImaging.prototype.rotateImage = function(fileName, method, outputPath, saveFormat, callback){
Expand All @@ -320,6 +435,30 @@ AsposeImaging.prototype.rotateImage = function(fileName, method, outputPath, sav

};

AsposeImaging.prototype.rotateFrame = function(fileName, frameID, method, outPath, callback){

fileName = typeof fileName !== 'undefined' ? fileName : '';
method = typeof method !== 'undefined' ? method : '';
frameID = typeof frameID !== 'undefined' ? frameID : '';
outPath = typeof outPath !== 'undefined' ? outPath : '';

if(fileName === '' || method === '' || frameID === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + fileName + '/frames?saveOtherFrames=false&rotateFlipMethod=' + method + '&outPath=' + outPath;

var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}
});

};

AsposeImaging.prototype.cropImage = function(fileName, x, y, width, height, outputPath, saveFormat, callback){

fileName = typeof fileName !== 'undefined' ? fileName : '';
Expand Down Expand Up @@ -348,6 +487,34 @@ AsposeImaging.prototype.cropImage = function(fileName, x, y, width, height, outp

};

AsposeImaging.prototype.cropFrame = function(fileName, frameID, x, y, width, height, outPath, callback){

fileName = typeof fileName !== 'undefined' ? fileName : '';
frameID = typeof frameID !== 'undefined' ? frameID : '';
x = typeof x !== 'undefined' ? x : '';
y = typeof y !== 'undefined' ? y : '';
width = typeof width !== 'undefined' ? width : '';
height = typeof height !== 'undefined' ? height : '';
outPath = typeof outPath !== 'undefined' ? outPath : '';

if(fileName === '' || x === '' || y === '' || width === '' || height === '' || frameID === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + fileName + '/frames?saveOtherFrames=false&width=' + width + '&height=' + height +
'&x=' + x + '&y=' + y + '&outPath=' + outPath;

var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}
});

};

AsposeImaging.prototype.resizeImage = function(fileStream, newWidth, newHeight, saveFormat, callback){

fileStream = typeof fileStream !== 'undefined' ? fileStream : '';
Expand All @@ -371,6 +538,80 @@ AsposeImaging.prototype.resizeImage = function(fileStream, newWidth, newHeight,

};

AsposeImaging.prototype.resizeFrame = function(filename, frameID, newWidth, newHeight, outPath, callback){

filename = typeof filename !== 'undefined' ? filename : '';
newWidth = typeof newWidth !== 'undefined' ? newWidth : '';
newHeight = typeof newHeight !== 'undefined' ? newHeight : '';
outPath = typeof outPath !== 'undefined' ? outPath : '';

if(filename === '' || newWidth === '' || newHeight === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + filename + '/frames/' + frameID + '?saveOtherFrames=true&newWidth=' + newWidth + '&newHeight=' + newHeight + '&outPath=' + outPath;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}
});

};

AsposeImaging.prototype.extractFrame = function(filename, frameID, outPath, callback){

filename = typeof filename !== 'undefined' ? filename : '';
outPath = typeof outPath !== 'undefined' ? outPath : '';

if(filename === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + filename + '/frames/' + frameID + '?saveOtherFrames=false&outPath=' + outPath;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}
});

};

AsposeImaging.prototype.manipulateFrame = function(fileName, frameID, rotateMethod, width, height, x, y, rectWidth, rectHeight, outPath, callback){

fileName = typeof fileName !== 'undefined' ? fileName : '';
frameID = typeof frameID !== 'undefined' ? frameID : '';
x = typeof x !== 'undefined' ? x : '';
y = typeof y !== 'undefined' ? y : '';
width = typeof width !== 'undefined' ? width : '';
height = typeof height !== 'undefined' ? height : '';
rectWidth = typeof rectWidth !== 'undefined' ? rectWidth : '';
rectHeight = typeof rectHeight !== 'undefined' ? rectHeight : '';
outPath = typeof outPath !== 'undefined' ? outPath : '';

if(rectHeight === '' || rectWidth === '' || fileName === '' || x === '' || y === '' || width === '' || height === '' || frameID === ''){
throw new Error('missing required parameters.');
}

var strURI = this.baseURI + 'imaging/' + fileName + '/frames?saveOtherFrames=true&rotateFlipMethod=' + rotateMethod + '&newWidth=' + width + '&newHeight=' + height +
'&x=' + x + '&y=' + y + '&rectWidth=' + rectWidth + '&rectHeight=' + rectHeight + '&outPath=' + outPath;

var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('GET',signedURI,'',function(data){

if(typeof callback === 'function'){
callback.call(null,data);
}
});

};

/**
*
* @type {AsposeImaging}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asposecloud",
"version": "1.1.0",
"version": "1.2.0",
"description": "Aspose Cloud SDK for NodeJS",
"main": "lib/aspose-cloud.js",
"scripts": {
Expand Down

0 comments on commit e42d469

Please sign in to comment.