Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(images-processing-api): update README & POSTINSTALL #46

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions extensions/image-processing-api/PREINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ const operations = [
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
```

Input types are:

1. `url` - A public URL to an image.

```js
{
operation: 'input',
type: 'url',
url: 'https://example.com/image.jpg',
}
```

2. `gcs` - A Google Cloud Storage public link to an image.

```js
{
operation: 'input',
type: 'gcs',
source: 'image.jpg',
}
```

3. `create` - Create a new image by specifying options such as width, height, background color, etc.

```js
{
operation: 'input',
type: 'create',
width: 100,
height: 100,
background: '#000000',
}
```

The extension also comes with a JavaScript utility library for simplifying the creation of operations:

```ts
Expand All @@ -33,7 +67,7 @@ const output = builder()
})
.grayscale()
.output({
format: 'webp',
webp: true,
});

const params = `?operations=${output.toEncodedJSONString()}`;
Expand All @@ -51,5 +85,5 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan

- You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).
- This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s no-cost tier:
- Cloud Storage
- Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))
- Cloud Storage
57 changes: 54 additions & 3 deletions extensions/image-processing-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,57 @@ const operations = [
const params = `?operations=${encodeURIComponent(JSON.stringify(operations))}`;
```

Input types are:

1. `url` - A public URL to an image.

```js
{
operation: 'input',
type: 'url',
url: 'https://example.com/image.jpg',
}
```

2. `gcs` - A Google Cloud Storage public link to an image.

```js
{
operation: 'input',
type: 'gcs',
source: 'image.jpg',
}
```

3. `create` - Create a new image by specifying options such as width, height, background color, etc.

```js
{
operation: 'input',
type: 'create',
width: 100,
height: 100,
background: '#000000',
}
```

The extension also comes with a JavaScript utility library for simplifying the creation of operations:

```ts
import { builder } from '@invertase/image-processing-api';

const output = builder()
.input({
url: 'https://example.com/image.jpg',
})
.grayscale()
.output({
webp: true,
});

const params = `?operations=${output.toEncodedJSONString()}`;
```

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

#### Additional setup
Expand All @@ -40,14 +91,14 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan

- You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).
- This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s no-cost tier:
- Cloud Storage
- Cloud Functions (Node.js 10+ runtime. [See FAQs](https://firebase.google.com/support/faq#extensions-pricing))

- Cloud Storage

**Configuration Parameters:**

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

- 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.
- Cloud Storage bucket for images: The Cloud Storage bucket for images from a `gcs` input type.

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

Expand Down
4 changes: 1 addition & 3 deletions extensions/image-processing-api/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ params:
- param: CLOUD_STORAGE_BUCKET
label: Cloud Storage bucket for images
description: >
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.
The Cloud Storage bucket for images from a `gcs` input type.
type: string
example: my-project-12345.appspot.com
validationRegex: ^([0-9a-z_.-]*)$
Expand Down