Skip to content

Commit

Permalink
Merge pull request #12 from prezly/feature/smart-cropping
Browse files Browse the repository at this point in the history
[CARE-5657] Feature - Smart cropping
  • Loading branch information
e1himself authored Sep 10, 2024
2 parents 75f3937 + eb39596 commit 961cb6f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib/UploadcareImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ export class UploadcareImage {
return this.withEffect(`/scale_crop/${width}x${height}/`);
};

/**
* @see https://uploadcare.com/docs/transformations/image/resize-crop/#operation-smart-crop
*/
public smartCrop = (
width: number,
height: number,
type:
| 'smart'
| 'smart_faces_objects'
| 'smart_faces_points'
| 'smart_objects_faces_points'
| 'smart_objects_faces'
| 'smart_objects_points'
| 'smart_points'
| 'smart_objects'
| 'smart_faces' = 'smart',
alignment?: 'center' | 'top' | 'right' | 'bottom' | 'left' | `${number}p,${number}p`,
): UploadcareImage => {
if (alignment) {
return this.withEffect(`/scale_crop/${width}x${height}/${type}/${alignment}/`);
}
return this.withEffect(`/scale_crop/${width}x${height}/${type}/`);
};

public toGifVideo = (): UploadcareGifVideo => {
// The `gif2video` transformation is supported only for gifs,
// otherwise the server responds with "400 Bad Request".
Expand Down

0 comments on commit 961cb6f

Please sign in to comment.