Skip to content

Commit 2eb11a6

Browse files
committed
docs(image-processing-api): fix link to function in POSTINSTALL
1 parent 0096644 commit 2eb11a6

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

extensions/image-processing-api/POSTINSTALL.md

Lines changed: 1 addition & 1 deletion
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/README.md

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
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.
87

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:
8+
9+
**Details**: Image Processing Extension
10+
Use this extension to optimize and transform images via a powerful HTTP API with over 30 image operations for enhancing and manipulating your images.
11+
12+
How It Works
13+
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.
14+
15+
Example
16+
Define your operations like so:
1117

1218
```js
1319
const operations = [
1420
{
1521
operation: 'input',
1622
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',
23+
url: 'https://example.com/image.jpg',
1824
},
1925
{
2026
operation: 'grayscale',
@@ -27,6 +33,28 @@ const operations = [
2733

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

3159
View the [official documentation](https://extensions.invertase.dev/image-processing-api) for full usage examples.
3260

@@ -43,24 +71,37 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan
4371
- Cloud Storage
4472
- Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))
4573

74+
75+
76+
4677
**Configuration Parameters:**
4778

48-
- 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).
79+
* 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).
80+
81+
* 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.
82+
83+
84+
* 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.
85+
4986

50-
- 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.
5187

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

5489
**Cloud Functions:**
5590

56-
- **handler:** Serves a API accepting incoming HTTP requests.
91+
* **handler:** Serves a API accepting incoming HTTP requests.
92+
93+
5794

5895
**APIs Used**:
5996

60-
- storage-component.googleapis.com (Reason: Needed to use Cloud Storage)
97+
* storage-component.googleapis.com (Reason: Needed to use Cloud Storage)
98+
99+
61100

62101
**Access Required**:
63102

103+
104+
64105
This extension will operate with the following project IAM roles:
65106

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

0 commit comments

Comments
 (0)