Skip to content

Commit

Permalink
Merge pull request #64 from imagekit-developer/SDK-94
Browse files Browse the repository at this point in the history
added effectShadow and effectGradient prameters
  • Loading branch information
imagekitio authored Feb 9, 2024
2 parents 6bf6085 + 13520f1 commit 000e702
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 713 deletions.
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ImageKit is complete media storage, optimization, and transformation solution th
- [Key Features](#key-features)
- [Requirements](#requirements)
- [Version Support](#version-support)
- [Breaking changes](#breaking-changes)
- [Installation](#installation)
- [Usage](#usage)
- [Getting Started](#getting-started)
Expand Down Expand Up @@ -44,10 +45,20 @@ ImageKit is complete media storage, optimization, and transformation solution th
## Version Support
| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.x |
|-------------|---------|---------|---------|---------|---------|
| 4.x ||| ✔️ | ✔️ |✔️ |
| 3.x ||| ✔️ | ✔️ |✔️ |
| 2.x ||| ✔️ | ✔️ |✔️ |
| 1.x || ✔️ | ✔️ | ✔️ |✔️ |

## Breaking changes

### Upgrading from 3.x to 4.x version

1. Overlay syntax update

* In version 4.0.0, we've removed the old overlay syntax parameters for transformations, such as `oi`, `ot`, `obg`, and [more](https://docs.imagekit.io/features/image-transformations/overlay). These parameters are deprecated and will start returning errors when used in URLs. Please migrate to the new layers syntax that supports overlay nesting, provides better positional control, and allows more transformations at the layer level. You can start with [examples](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#examples) to learn quickly.
* You can migrate to the new layers syntax using the `raw` transformation parameter.

## Installation

You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
Expand Down Expand Up @@ -441,7 +452,32 @@ $imageURL = $imageKit->url(array(
https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end/img/sample-video.mp4
```

### 6. Signed URL
### 6. Arithmetic expressions in transformations

ImageKit allows use of [arithmetic expressions](https://docs.imagekit.io/features/arithmetic-expressions-in-transformations) in certain dimension and position-related parameters, making media transformations more flexible and dynamic.

For example:

```php
$imageURL = $imageKit->url(array(
'path' => '/default-image.jpg',
'urlEndpoint' => 'https://ik.imagekit.io/your_imagekit_id'
'transformation' => [
[
"height": "ih_div_2",
"width": "iw_div_4",
"border": "cw_mul_0.05_yellow"
]
]
));
```

#### Sample Result URL
```
https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-iw_div_4,h-ih_div_2,b-cw_mul_0.05_yellow
``
### 7. Signed URL
For example, the signed URL expires in 300 seconds with the default URL endpoint and other query parameters.
For a detailed explanation of the signed URL, refer to this [documentation](https://docs.imagekit.io/features/security/signed-urls).
Expand Down Expand Up @@ -508,6 +544,8 @@ If you want to generate transformations in your application and add them to the
| effectUSM | e-usm |
| effectContrast | e-contrast |
| effectGray | e-grayscale |
| effectShadow | e-shadow |
| effectGradient | e-gradient |
| original | orig |
| raw | `replaced by the parameter value` |

Expand Down Expand Up @@ -610,6 +648,15 @@ $uploadFile = $imageKit->uploadFile([
"overwriteAITags" => true, // set to false in order to preserve overwriteAITags
"overwriteTags" => true,
"overwriteCustomMetadata" => true,
'transformation' => [
'pre' => 'l-text,i-Imagekit,fs-50,l-end',
'post' => [
[
'type' => 'transformation',
'value' => 'h-100'
]
]
],
// "customMetadata" => [
// "SKU" => "VS882HJ2JD",
// "price" => 599.99,
Expand Down
33 changes: 30 additions & 3 deletions sample/upload_api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@
'folder' => 'sample-folder',
'tags' => implode(['abd', 'def']),
'useUniqueFileName' => false,
'customCoordinates' => implode(',', ['10', '10', '100', '100'])
'customCoordinates' => implode(',', ['10', '10', '100', '100']),
'transformation' => [
'pre' => 'l-text,i-Imagekit,fs-50,l-end',
'post' => [
[
'type' => 'transformation',
'value' => 'h-100'
]
]
],
]);

echo "\n\n";
Expand All @@ -34,7 +43,16 @@
'folder' => 'sample-folder',
'tags' => implode(['abd', 'def']),
'useUniqueFileName' => true,
'customCoordinates' => implode(',', ['10', '10', '100', '100'])
'customCoordinates' => implode(',', ['10', '10', '100', '100']),
'transformation' => [
'pre' => 'l-text,i-Imagekit,fs-50,l-end',
'post' => [
[
'type' => 'transformation',
'value' => 'h-100'
]
]
],
]);

echo "\n\n";
Expand All @@ -51,7 +69,16 @@
'folder' => 'sample-folder',
'tags' => implode(['abd', 'def']),
'useUniqueFileName' => true,
'customCoordinates' => implode(',', ['10', '10', '100', '100'])
'customCoordinates' => implode(',', ['10', '10', '100', '100']),
'transformation' => [
'pre' => 'l-text,i-Imagekit,fs-50,l-end',
'post' => [
[
'type' => 'transformation',
'value' => 'h-100'
]
]
],
]);

echo "\n\n";
Expand Down
40 changes: 40 additions & 0 deletions sample/url_generation/image_enhancement_and_color_manipulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,43 @@
echo "3. Unsharp mask Image URL: \n";
echo "\033[01;32m$imageURL\033[0m";
echo "\n";

// Shadow (e-shadow)
// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#shadow-e-shadow

$imageURL = $imageKit->url(
[
'src' => 'https://ik.imagekit.io/demo/sample_image.jpg',
'transformation' => [
[
'height' => '300',
'effectShadow' => 'bl-15_st-40_x-10_y-N5'
]
],
]
);

echo "\n\n";
echo "4. Shadow image URL: \n";
echo "\033[01;32m$imageURL\033[0m";
echo "\n";

// Gradient (e-gradient)
// https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation#gradient-e-gradient

$imageURL = $imageKit->url(
[
'src' => 'https://ik.imagekit.io/demo/sample_image.jpg',
'transformation' => [
[
'height' => '300',
'effectGradient' => 'from-red_to-white',
]
],
]
);

echo "\n\n";
echo "5. Gradient image URL: \n";
echo "\033[01;32m$imageURL\033[0m";
echo "\n";
1 change: 0 additions & 1 deletion sample/url_generation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
echo "\n";

include_once('resize_crop_other_common_transformations.php');
include_once('overlay.php');
include_once('image_enhancement_and_color_manipulation.php');
include_once('chained_transformations.php');
include_once('signed_url.php');
Loading

0 comments on commit 000e702

Please sign in to comment.