diff --git a/src/lib/filelink.spec.ts b/src/lib/filelink.spec.ts index 7eb394e4..cdf0c444 100644 --- a/src/lib/filelink.spec.ts +++ b/src/lib/filelink.spec.ts @@ -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'); diff --git a/src/lib/filelink.ts b/src/lib/filelink.ts index fe434b32..2c820e96 100644 --- a/src/lib/filelink.ts +++ b/src/lib/filelink.ts @@ -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'); @@ -280,6 +281,10 @@ export interface BorderParams { background?: string; } +export interface CompressParams { + metadata?: boolean; +} + export interface SharpenParams { amount: number; } @@ -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 * @@ -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 * diff --git a/src/schema/transforms.schema.ts b/src/schema/transforms.schema.ts index 5a3b513b..166c44c9 100644 --- a/src/schema/transforms.schema.ts +++ b/src/schema/transforms.schema.ts @@ -25,6 +25,10 @@ export const TransformSchema = { type: 'boolean', additionalProperties: false, }, + auto_image: { + type: 'boolean', + additionalProperties: false, + }, no_metadata: { type: 'boolean', additionalProperties: false,