Skip to content

Commit 7d650cd

Browse files
authored
Image processing updates (#67)
Bumps Node runtime to 20, fixes security vulnerabilities, updates documentation (including POSTINSTALL.md link and param labels), updates extension.yaml/CHANGELOG.md, and applies formatting. * fix(image-processing-api): npm audit and bump runtime to 20 * chore(image-processing-api): fix vulnerabilities * docs(image-processing-api): fix documentation * docs(image-processing-api): fix link to function in POSTINSTALL * chore(image-processing-api): fix extension.yaml version and CHANGELOG * docs(image-processing-api): fix param label * chore(image-processing-api): format * chore(image-processing-api): format and fix docs
1 parent ef90ddf commit 7d650cd

File tree

10 files changed

+19535
-17898
lines changed

10 files changed

+19535
-17898
lines changed

extensions/image-processing-api/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Version 0.2.0
2+
3+
chore - bump node runtime to nodejs20
4+
5+
docs - fix documentation according to functionality of the extension
6+
7+
fix - npm audit and fix other vulnerabilities
8+
19
## Version 0.1.1
210

311
Updated POSTINSTALL parameters.

extensions/image-processing-api/POSTINSTALL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ encodeURIComponent(JSON.stringify(operations));
2929

3030
3. Call the deployed `process` Cloud Function:
3131

32-
[https://${param:LOCATION}-${param:PROJECT_ID}.cloudfunctions.net/ext-image-processing-api-handler/process?operations=%5B%7B%22operation%22%3A%22input%22%2C%22type%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663659552548-25d7771802c9%3Fixlib%3Drb-1.2.1%26ixid%3DMnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8%26auto%3Dformat%26fit%3Dcrop%26w%3D774%26q%3D80%22%7D%2C%7B%22operation%22%3A%22grayscale%22%7D%2C%7B%22operation%22%3A%22output%22%2C%22format%22%3A%22webp%22%7D%5D](https://${param:LOCATION}-${param:PROJECT_ID}.cloudfunctions.net/ext-image-processing-api-handler/process?operations=%5B%7B%22operation%22%3A%22input%22%2C%22type%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663659552548-25d7771802c9%3Fixlib%3Drb-1.2.1%26ixid%3DMnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8%26auto%3Dformat%26fit%3Dcrop%26w%3D774%26q%3D80%22%7D%2C%7B%22operation%22%3A%22grayscale%22%7D%2C%7B%22operation%22%3A%22output%22%2C%22format%22%3A%22webp%22%7D%5D)
32+
[https://${param:LOCATION}-${param:PROJECT_ID}.cloudfunctions.net/ext-${param:EXT_INSTANCE_ID}-handler/process?operations=%5B%7B%22operation%22%3A%22input%22%2C%22type%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663659552548-25d7771802c9%3Fixlib%3Drb-1.2.1%26ixid%3DMnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8%26auto%3Dformat%26fit%3Dcrop%26w%3D774%26q%3D80%22%7D%2C%7B%22operation%22%3A%22grayscale%22%7D%2C%7B%22operation%22%3A%22output%22%2C%22format%22%3A%22webp%22%7D%5D](https://${param:LOCATION}-${param:PROJECT_ID}.cloudfunctions.net/ext-image-processing-api-handler/process?operations=%5B%7B%22operation%22%3A%22input%22%2C%22type%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fimages.unsplash.com%2Fphoto-1663659552548-25d7771802c9%3Fixlib%3Drb-1.2.1%26ixid%3DMnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8%26auto%3Dformat%26fit%3Dcrop%26w%3D774%26q%3D80%22%7D%2C%7B%22operation%22%3A%22grayscale%22%7D%2C%7B%22operation%22%3A%22output%22%2C%22format%22%3A%22webp%22%7D%5D)
3333

3434
The result will be a grayscaled version of the image, in WebP format.
3535

extensions/image-processing-api/PREINSTALL.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
Use this extension to optimize and transform images via a powerful HTTP API with over 30 different image operations to enhance and manipulate your images.
1+
Image Processing Extension
2+
Use this extension to optimize and transform images via a powerful HTTP API with over 30 image operations for enhancing and manipulating your images.
23

3-
This extension creates a Cloud Function named `process`, which can be called via a GET request, specifiying
4-
the operations to perform via the `operations` query parameter, for example:
4+
How It Works
5+
When you install this extension, it deploys a Cloud Function that exposes an HTTP API. All requests must be sent to the /process endpoint of the function. You perform image operations by passing an operations query parameter—a URL-encoded JSON string defining the operations to execute.
6+
7+
Example
8+
Define your operations like so:
59

610
```js
711
const operations = [
@@ -22,6 +26,12 @@ const operations = [
2226
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
2327
```
2428

29+
Then, make your GET request to your Cloud Function using the correct endpoint. For example:
30+
31+
```
32+
https://<your-configured-region>-<your-project-id>.cloudfunctions.net/<extension-instance-id>/process${params}
33+
```
34+
2535
The extension also comes with a JavaScript utility library for simplifying the creation of operations:
2636

2737
```ts

extensions/image-processing-api/README.md

+32-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44

55
**Description**: Use this extension to optimize and transform images via a powerful HTTP API with over 30 different image operations to enhance and manipulate your images.
66

7-
**Details**: Use this extension to optimize and transform images via a powerful HTTP API with over 30 different image operations to enhance and manipulate your images.
7+
**Details**: Image Processing Extension
8+
Use this extension to optimize and transform images via a powerful HTTP API with over 30 image operations for enhancing and manipulating your images.
89

9-
This extension creates a Cloud Function named `process`, which can be called via a GET request, specifiying
10-
the operations to perform via the `operations` query parameter, for example:
10+
How It Works
11+
When you install this extension, it deploys a Cloud Function that exposes an HTTP API. All requests must be sent to the /process endpoint of the function. You perform image operations by passing an operations query parameter—a URL-encoded JSON string defining the operations to execute.
12+
13+
Example
14+
Define your operations like so:
1115

1216
```js
1317
const operations = [
1418
{
1519
operation: 'input',
1620
type: 'url',
17-
url: 'https://images.unsplash.com/photo-1663659552548-25d7771802c9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80',
21+
url: 'https://example.com/image.jpg',
1822
},
1923
{
2024
operation: 'grayscale',
@@ -28,6 +32,29 @@ const operations = [
2832
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
2933
```
3034

35+
Then, make your GET request to your Cloud Function using the correct endpoint. For example:
36+
37+
```
38+
https://<your-configured-region>-<your-project-id>.cloudfunctions.net/<extension-instance-id>/process${params}
39+
```
40+
41+
The extension also comes with a JavaScript utility library for simplifying the creation of operations:
42+
43+
```ts
44+
import { builder } from '@invertase/image-processing-api';
45+
46+
const output = builder()
47+
.input({
48+
url: 'https://example.com/image.jpg',
49+
})
50+
.grayscale()
51+
.output({
52+
format: 'webp',
53+
});
54+
55+
const params = `?operations=${output.toEncodedJSONString()}`;
56+
```
57+
3158
View the [official documentation](https://extensions.invertase.dev/image-processing-api) for full usage examples.
3259

3360
#### Additional setup
@@ -49,7 +76,7 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan
4976

5077
- Cloud Storage bucket for images: The Cloud Storage bucket where images that are to be processed are located. API requests with input urls or paths that are not inside this bucket will be dropped.
5178

52-
- Allowed CORS origins.: A comma delimited value of allowed CORS origins. Use the default of '\*' to allow all origins. This is useful to lockdown your API and only allow your own website to embed the images directly. Note this will not prevent non-browser requests from accessing your API.
79+
- Allowed CORS origins: A comma delimited value of allowed CORS origins. Use the default of '\*' to allow all origins. This is useful to lockdown your API and only allow your own website to embed the images directly. Note this will not prevent non-browser requests from accessing your API.
5380

5481
**Cloud Functions:**
5582

extensions/image-processing-api/extension.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: image-processing-api
2-
version: 0.1.1
2+
version: 0.2.0
33
specVersion: v1beta
44

55
displayName: Image Processing API
@@ -37,7 +37,7 @@ resources:
3737
Serves a API accepting incoming HTTP requests.
3838
properties:
3939
location: ${param:LOCATION}
40-
runtime: nodejs14
40+
runtime: nodejs20
4141
availableMemoryMb: 1024
4242
httpsTrigger: {}
4343

@@ -109,7 +109,7 @@ params:
109109
required: true
110110

111111
- param: CORS_ORIGIN_ALLOW_LIST
112-
label: Allowed CORS origins.
112+
label: Allowed CORS origins
113113
description: >
114114
A comma delimited value of allowed CORS origins. Use the default of '*'
115115
to allow all origins. This is useful to lockdown your API and only allow

0 commit comments

Comments
 (0)