Skip to content

Commit

Permalink
Add Enhance action (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
magdakwiecien authored Feb 21, 2024
1 parent 10d500d commit 1cd3594
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion __TESTS__/unit/actions/Effect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Tests for Transformation Action -- Effect', () => {
.effect(Effect.deshake().shakeStrength(ShakeStrength.pixels16()))
.effect(Effect.generativeRestore())
.effect(Effect.upscale())
.effect(Effect.enhance())
.toString();

const expectedToContain = [
Expand Down Expand Up @@ -90,7 +91,8 @@ describe('Tests for Transformation Action -- Effect', () => {
'e_deshake:10',
'e_deshake:16',
'e_gen_restore',
'e_upscale'
'e_upscale',
'e_enhance'
].join('/');

expect(tx).toBe(`${expectedToContain}`);
Expand Down
6 changes: 4 additions & 2 deletions __TESTS__/unit/fromJson/effect.fromJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ describe('effect.fromJson', () => {
{ actionType: 'generativeRecolor', prompts: ['something'], toColor: 'red', detectMultiple: true },
{ actionType: 'generativeRecolor', prompts: ['something', 'else'], toColor: 'blue', detectMultiple: false },
{ actionType: 'generativeRestore' },
{ actionType: 'upscale' }
{ actionType: 'upscale' },
{ actionType: 'enhance' }
]});

expect(transformation.toString().split('/')).toStrictEqual([
Expand Down Expand Up @@ -95,7 +96,8 @@ describe('effect.fromJson', () => {
'e_gen_recolor:prompt_something;to-color_red;multiple_true',
'e_gen_recolor:prompt_(something;else);to-color_blue',
'e_gen_restore',
'e_upscale'
'e_upscale',
'e_enhance'
]);
});
});
10 changes: 10 additions & 0 deletions __TESTS__/unit/toJson/effect.toJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,14 @@ describe('Effect toJson()', () => {
]
});
});

it('effect.enhance', () => {
const transformation = new Transformation()
.addAction(Effect.enhance());
expect(transformation.toJson()).toStrictEqual({
actions: [
{actionType: 'enhance'}
]
});
});
});
11 changes: 11 additions & 0 deletions src/actions/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,15 @@ function theme(color: SystemColors): ThemeEffect {
return new ThemeEffect(color);
}

/**
*
* @description Uses AI to analyze an image and make adjustments to enhance the appeal of the image.
* @return {Actions.Effect.Enhance}
*/
function enhance(): SimpleEffectAction {
return new SimpleEffectAction("enhance");
}

/**
* @description Defines effects that you can apply to transform your assets.
* @memberOf Actions
Expand Down Expand Up @@ -605,6 +614,7 @@ const Effect = {
generativeRestore,
upscale,
theme,
enhance
};

export declare type EffectActions =
Expand Down Expand Up @@ -671,4 +681,5 @@ export {
generativeRestore,
upscale,
theme,
enhance,
};
1 change: 1 addition & 0 deletions src/internal/fromJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const ActionModelMap: Record<string, IHasFromJson> = {
upscale: SimpleEffectAction,
auto: ResizeAdvancedAction,
backgroundColor: BackgroundColor,
enhance: SimpleEffectAction,
};

/**
Expand Down

0 comments on commit 1cd3594

Please sign in to comment.