Skip to content

Commit e982879

Browse files
committed
chore(image-processing-api): update docs and tests
1 parent ddffa66 commit e982879

File tree

28 files changed

+3943
-824
lines changed

28 files changed

+3943
-824
lines changed

extensions/image-processing-api/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Version 0.2.1
2+
3+
feat - support relative URLs
4+
5+
chore - modernize/fix tests
6+
17
## Version 0.2.0
28

39
chore - bump node runtime to nodejs20

extensions/image-processing-api/PREINSTALL.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Image Processing Extension
1+
# Image Processing Extension
22
Use this extension to optimize and transform images via a powerful HTTP API with over 30 image operations for enhancing and manipulating your images.
33

4-
How It Works
4+
## How It Works
55
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.
66

77
Example
@@ -32,6 +32,35 @@ Then, make your GET request to your Cloud Function using the correct endpoint. F
3232
https://<your-configured-region>-<your-project-id>.cloudfunctions.net/<extension-instance-id>/process${params}
3333
```
3434

35+
### Using Relative URLs (type: 'path')
36+
37+
In addition to fetching images via remote URLs, this extension also supports relative paths through the type: 'path' input type. This is useful when you're serving images from your own domain (e.g. through a CDN, proxy, or local server during development).
38+
39+
When you use type: 'path', the extension will prepend the hostname of the incoming request to the path to construct the full image URL.
40+
41+
```ts
42+
const operations = [
43+
{
44+
operation: 'input',
45+
type: 'path',
46+
path: '/images/photo.jpg',
47+
},
48+
{
49+
operation: 'resize',
50+
width: 800,
51+
height: 600,
52+
},
53+
{
54+
operation: 'output',
55+
format: 'jpeg',
56+
},
57+
];
58+
59+
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
60+
```
61+
62+
### Javascript Utility Library
63+
3564
The extension also comes with a JavaScript utility library for simplifying the creation of operations:
3665

3766
```ts

extensions/image-processing-api/README.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
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**: Image Processing Extension
7+
8+
9+
**Details**: # Image Processing Extension
810
Use this extension to optimize and transform images via a powerful HTTP API with over 30 image operations for enhancing and manipulating your images.
911

10-
How It Works
12+
## How It Works
1113
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.
1214

1315
Example
@@ -38,6 +40,35 @@ Then, make your GET request to your Cloud Function using the correct endpoint. F
3840
https://<your-configured-region>-<your-project-id>.cloudfunctions.net/<extension-instance-id>/process${params}
3941
```
4042

43+
### Using Relative URLs (type: 'path')
44+
45+
In addition to fetching images via remote URLs, this extension also supports relative paths through the type: 'path' input type. This is useful when you're serving images from your own domain (e.g. through a CDN, proxy, or local server during development).
46+
47+
When you use type: 'path', the extension will prepend the hostname of the incoming request to the path to construct the full image URL.
48+
49+
```ts
50+
const operations = [
51+
{
52+
operation: 'input',
53+
type: 'path',
54+
path: '/images/photo.jpg',
55+
},
56+
{
57+
operation: 'resize',
58+
width: 800,
59+
height: 600,
60+
},
61+
{
62+
operation: 'output',
63+
format: 'jpeg',
64+
},
65+
];
66+
67+
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
68+
```
69+
70+
### Javascript Utility Library
71+
4172
The extension also comes with a JavaScript utility library for simplifying the creation of operations:
4273

4374
```ts
@@ -70,24 +101,37 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan
70101
- Cloud Storage
71102
- Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))
72103

104+
105+
106+
73107
**Configuration Parameters:**
74108

75-
- Cloud Functions location: Where do you want to deploy the functions created for this extension? You usually want a location close to your Storage bucket. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
109+
* Cloud Functions location: Where do you want to deploy the functions created for this extension? You usually want a location close to your Storage bucket. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
110+
111+
* 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.
112+
113+
114+
* 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.
115+
76116

77-
- 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.
78117

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.
80118

81119
**Cloud Functions:**
82120

83-
- **handler:** Serves a API accepting incoming HTTP requests.
121+
* **handler:** Serves a API accepting incoming HTTP requests.
122+
123+
84124

85125
**APIs Used**:
86126

87-
- storage-component.googleapis.com (Reason: Needed to use Cloud Storage)
127+
* storage-component.googleapis.com (Reason: Needed to use Cloud Storage)
128+
129+
88130

89131
**Access Required**:
90132

133+
134+
91135
This extension will operate with the following project IAM roles:
92136

93-
- storage.admin (Reason: Allows the extension to read images in Cloud Storage)
137+
* storage.admin (Reason: Allows the extension to read images in Cloud Storage)

extensions/image-processing-api/extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: image-processing-api
2-
version: 0.2.0
2+
version: 0.2.1
33
specVersion: v1beta
44

55
displayName: Image Processing API

extensions/image-processing-api/functions/__tests__/data/firebase-export-metadata.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

extensions/image-processing-api/functions/__tests__/data/storage_export/buckets.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

extensions/image-processing-api/functions/__tests__/data/storage_export/metadata/extensions-testing.appspot.com/invertase.jpeg.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)