Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transforms): Add autoImage transformation #276

Merged
merged 3 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -277,6 +278,10 @@ export interface BorderParams {
background?: string;
}

export interface CompressParams {
metadata?: boolean;
}

export interface SharpenParams {
amount: number;
}
Expand Down Expand Up @@ -721,6 +726,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 @@ -776,6 +792,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