Skip to content

Commit

Permalink
feat(transforms): Add autoImage transformation (#276)
Browse files Browse the repository at this point in the history
* feat(auto_image): Add autoImage transformation

* feat(transforms): add compress transformations

* style(linter): fix blank line linter error
  • Loading branch information
pcholuj authored Aug 23, 2019
1 parent 3a82f02 commit d371552
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/filelink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ describe('filelink', () => {
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/5aYkEQJSQCmYShsoCnZN');
});

it('should be able to autoImage transformation', () => {
filelink.autoImage();
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/auto_image/5aYkEQJSQCmYShsoCnZN');
});

it('should be able to add flip', () => {
filelink.flip();
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/flip/5aYkEQJSQCmYShsoCnZN');
Expand Down
27 changes: 27 additions & 0 deletions src/lib/filelink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getValidator } from './../schema/validator';
import { resolveHost, b64 } from './utils';
import { FilestackError, FilestackErrorType } from './../filestack_error';
import Debug from 'debug';
import { booleanLiteral } from '@babel/types';

const debug = Debug('fs:filelink');

Expand Down Expand Up @@ -280,6 +281,10 @@ export interface BorderParams {
background?: string;
}

export interface CompressParams {
metadata?: boolean;
}

export interface SharpenParams {
amount: number;
}
Expand Down Expand Up @@ -739,6 +744,17 @@ export class Filelink {
* Transformations part
*/

/**
* Add autoimage transformation
*
* @see https://www.filestack.com/docs/api/processing/#auto-image-conversion
* @returns this
* @memberof Filelink
*/
autoImage() {
return this.addTask('auto_image', true);
}

/**
* Adds flip transformation
*
Expand Down Expand Up @@ -794,6 +810,17 @@ export class Filelink {
return this.addTask('monochrome', true);
}

/**
* Add compress transformation
*
* @see https://www.filestack.com/docs/api/processing/#compress
* @returns this
* @memberof Filelink
*/
compress(params?: CompressParams) {
return this.addTask('compress', params || true);
}

/**
* Adds negative transformation
*
Expand Down
4 changes: 4 additions & 0 deletions src/schema/transforms.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const TransformSchema = {
type: 'boolean',
additionalProperties: false,
},
auto_image: {
type: 'boolean',
additionalProperties: false,
},
no_metadata: {
type: 'boolean',
additionalProperties: false,
Expand Down

0 comments on commit d371552

Please sign in to comment.