Skip to content

Commit d371552

Browse files
authored
feat(transforms): Add autoImage transformation (#276)
* feat(auto_image): Add autoImage transformation * feat(transforms): add compress transformations * style(linter): fix blank line linter error
1 parent 3a82f02 commit d371552

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/lib/filelink.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ describe('filelink', () => {
198198
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/5aYkEQJSQCmYShsoCnZN');
199199
});
200200

201+
it('should be able to autoImage transformation', () => {
202+
filelink.autoImage();
203+
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/auto_image/5aYkEQJSQCmYShsoCnZN');
204+
});
205+
201206
it('should be able to add flip', () => {
202207
filelink.flip();
203208
expect(filelink.toString()).toBe('https://customDomain.com/DEFAULT_API_KEY/flip/5aYkEQJSQCmYShsoCnZN');

src/lib/filelink.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { getValidator } from './../schema/validator';
2121
import { resolveHost, b64 } from './utils';
2222
import { FilestackError, FilestackErrorType } from './../filestack_error';
2323
import Debug from 'debug';
24+
import { booleanLiteral } from '@babel/types';
2425

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

@@ -280,6 +281,10 @@ export interface BorderParams {
280281
background?: string;
281282
}
282283

284+
export interface CompressParams {
285+
metadata?: boolean;
286+
}
287+
283288
export interface SharpenParams {
284289
amount: number;
285290
}
@@ -739,6 +744,17 @@ export class Filelink {
739744
* Transformations part
740745
*/
741746

747+
/**
748+
* Add autoimage transformation
749+
*
750+
* @see https://www.filestack.com/docs/api/processing/#auto-image-conversion
751+
* @returns this
752+
* @memberof Filelink
753+
*/
754+
autoImage() {
755+
return this.addTask('auto_image', true);
756+
}
757+
742758
/**
743759
* Adds flip transformation
744760
*
@@ -794,6 +810,17 @@ export class Filelink {
794810
return this.addTask('monochrome', true);
795811
}
796812

813+
/**
814+
* Add compress transformation
815+
*
816+
* @see https://www.filestack.com/docs/api/processing/#compress
817+
* @returns this
818+
* @memberof Filelink
819+
*/
820+
compress(params?: CompressParams) {
821+
return this.addTask('compress', params || true);
822+
}
823+
797824
/**
798825
* Adds negative transformation
799826
*

src/schema/transforms.schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export const TransformSchema = {
2525
type: 'boolean',
2626
additionalProperties: false,
2727
},
28+
auto_image: {
29+
type: 'boolean',
30+
additionalProperties: false,
31+
},
2832
no_metadata: {
2933
type: 'boolean',
3034
additionalProperties: false,

0 commit comments

Comments
 (0)