Skip to content

Commit

Permalink
Add support for upscale effect
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary committed May 27, 2024
1 parent a88d355 commit de8607c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Transformation/Effect/Generative/GenerativeEffect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ abstract class GenerativeEffect
{
const GENERATIVE_RECOLOR = 'gen_recolor';
const GENERATIVE_REMOVE = 'gen_remove';
const GENERATIVE_REPLACE = 'gen_replace';
const GENERATIVE_RESTORE = 'gen_restore';
const GENERATIVE_REPLACE = 'gen_replace';
const GENERATIVE_RESTORE = 'gen_restore';
const UPSCALE = 'upscale';

use GenerativeEffectTrait;
}
11 changes: 11 additions & 0 deletions src/Transformation/Effect/Generative/GenerativeEffectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,15 @@ public static function generativeReplace($fromPrompt, $toPrompt, $preserveGeomet
{
return new GenerativeReplace($fromPrompt, $toPrompt, $preserveGeometry, $detectMultiple);
}

/**
* Uses AI-based prediction to add fine detail while upscaling small images.
* This 'super-resolution' feature scales each dimension by four, multiplying the total number of pixels by 16.
*
* @return GenerativeEffectAction
*/
public static function upscale()
{
return new GenerativeEffectAction(GenerativeEffect::UPSCALE);
}
}
8 changes: 8 additions & 0 deletions tests/Unit/Transformation/Image/GenerativeEffectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ public function testGenerativeReplace()
(string)Effect::generativeReplace('balloon', 'airplane')->preserveGeometry(false)->detectMultiple()
);
}

public function testGenerativeUpscale()
{
self::assertEquals(
'e_upscale',
(string)Effect::upscale()
);
}
}

0 comments on commit de8607c

Please sign in to comment.