File tree Expand file tree Collapse file tree 2 files changed +62
-2
lines changed
docs/storage-image-processing-api
extensions/storage-image-processing-api/lib Expand file tree Collapse file tree 2 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -129,3 +129,40 @@ const operations = [
129
129
const encodedOperations = encodeURIComponent (JSON .stringify (operations));
130
130
const url = ` https://{LOCATION}-{PROJECT_ID}.cloudfunctions.net/ext-storage-image-processing-api-handler/process?operations=${ encodedOperations} ` ;
131
131
```
132
+
133
+ ### JavaScript utility library
134
+
135
+ Additionally, a utility library exists to provide a fully typed interface for constructing options.
136
+
137
+ Firstly, install the [ library] ( https://www.npmjs.com/package/@invertase/storage-image-processing-api ) via npm:
138
+
139
+ ``` bash
140
+ npm i --save @invertase/storage-image-processing-api
141
+ ```
142
+
143
+ Use the ` builder ` function to return a ` StorageImageProcessingApi ` instance which can be used to build an array of operations:
144
+
145
+ ``` ts
146
+ import { builder } from ' @invertase/storage-image-processing-api' ;
147
+
148
+ const output = builder ()
149
+ // Input required
150
+ .input ({
151
+ source: ' https://example.com/image.jpg' ,
152
+ })
153
+ .flip ()
154
+ .grayscale ()
155
+ .rotate ({ angle: 90 })
156
+ // Output required
157
+ .output ({
158
+ format: ' png' ,
159
+ });
160
+ ```
161
+
162
+ Once created, the api provides the means to return the operations as JSON, a JSON string or an encoded JSON string suitable for GET requests in your browser.
163
+
164
+ ``` ts
165
+ const json = output .toJSON ();
166
+ const jsonString = output .toJSONString ();
167
+ const encodedJsonString = output .toEncodedJSONString ();
168
+ ```
Original file line number Diff line number Diff line change 1
1
# Storage Image Processing API Utilities
2
2
3
- This package contains utilities for interacting with the [ Firebase Storage Image Processing API Extension] ( #todo ) .
3
+ This package contains utilities for interacting with the Firebase Storage Image Processing API Extension.
4
4
5
5
## Installation
6
6
@@ -14,4 +14,27 @@ npm i --save @invertase/storage-image-processing-api
14
14
15
15
Returns a ` StorageImageProcessingApi ` instance which can be used to build an array of operations to be applied to an image via the extension.
16
16
17
- Once built,
17
+ ``` ts
18
+ import { builder } from ' @invertase/storage-image-processing-api' ;
19
+
20
+ const output = builder ()
21
+ // Input required
22
+ .input ({
23
+ source: ' https://example.com/image.jpg' ,
24
+ })
25
+ .flip ()
26
+ .grayscale ()
27
+ .rotate ({ angle: 90 })
28
+ // Output required
29
+ .output ({
30
+ format: ' png' ,
31
+ });
32
+ ```
33
+
34
+ Once created, the api provides the means to return the operations as JSON, a JSON string or an encoded JSON string suitable for GET requests in your browser.
35
+
36
+ ``` ts
37
+ const json = output .toJSON ();
38
+ const jsonString = output .toJSONString ();
39
+ const encodedJsonString = output .toEncodedJSONString ();
40
+ ```
You can’t perform that action at this time.
0 commit comments