next-cloudinary 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,19 +12,28 @@
12
12
 
13
13
  ######
14
14
 
15
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
16
- [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
17
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
15
+ <a href="https://github.com/colbyfayock/next-cloudinary/actions/workflows/test_and_release.yml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/colbyfayock/next-cloudinary/Test%20&%20Release?label=Test%20%26%20Release&style=flat-square"></a> <a href="https://www.npmjs.com/package/next-cloudinary"><img alt="npm" src="https://img.shields.io/npm/v/next-cloudinary?style=flat-square"></a> <a href="https://github.com/colbyfayock/next-cloudinary/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/colbyfayock/next-cloudinary?label=License&style=flat-square"></a>
18
16
 
19
- # Cloudinary Next.js Component
17
+ # Next Cloudinary
20
18
 
21
- Get the best of Cloudinary in Next.js with the CldImage component!
19
+ High-performance image delivery and uploading at scale in Next.js powered by Cloudinary.
22
20
 
23
- > 🚨 EXPERIMENTAL: while this should be working pretty well, it's consider experimental, so use at your own risk!
21
+ <a href="#-features">Features</a> • <a href="#-getting-started">Getting Started</a> • <a href="#%EF%B8%8F-community--support">Community & Support</a> • <a href="#-contributing">Contributing</a>
24
22
 
25
- **This plugin is not officially supported by Cloudinary.**
23
+ ## ✨ Features
26
24
 
27
- ## ⚡️ Getting Started
25
+ * Automatically optimize images and deliver in modern formats
26
+ * Remove backgrounds from images
27
+ * Dynamically add image and text overlays to images
28
+ * AI-based cropping and resizing
29
+ * Transform images using color and effects
30
+ * Generate Open Graph Social Media cards on the fly
31
+ * Drop-in Upload Widget
32
+ * ...all at scale with Cloudinary
33
+
34
+ **This plugin is a community library and not officially supported by Cloudinary.**
35
+
36
+ ## 🚀 Getting Started
28
37
 
29
38
  ### Installation
30
39
 
@@ -40,240 +49,115 @@ npm install next-cloudinary
40
49
  NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="<Your Cloud Name>"
41
50
  ```
42
51
 
43
- * Import the CldImage component:
52
+ ### Adding an Image
53
+
44
54
  ```
45
55
  import { CldImage } from 'next-cloudinary';
56
+
57
+ <CldImage width="600" height="600" src="<Public ID or Cloudinary URL>" />
46
58
  ```
47
59
 
48
- ### Usage
60
+ [Learn more about CldImage on the Next Cloudinary Docs](https://next-cloudinary.spacejelly.dev/components/cldimage/basic-usage)
49
61
 
50
- The basic required props include `width`, `height`, and `src`:
62
+ ### Generating an Social Media Card (Open Graph)
51
63
 
52
64
  ```
53
- <CldImage
54
- width="600"
55
- height="600"
56
- src="<Public ID>"
57
- />
65
+ <CldOgImage src="<Public ID or Cloudinary URL>" text="Next Cloudinary" />
58
66
  ```
59
67
 
60
- You can further take advantage of Cloudinary features like background removal and overlays by adding additional props:
68
+ > Note: The width and height is not required (or recommended) to comply with standardized social media card sizing of a 2:1 aspect ratio.
61
69
 
62
- ```
63
- <CldImage
64
- width="600"
65
- height="600"
66
- src="<Public ID>"
67
- crop="thumb"
68
- gravity="faces"
69
- removeBackground
70
- tint="100:blue:green:red"
71
- underlays={[{
72
- publicId: '<Public ID>',
73
- width: 600,
74
- height: 600,
75
- crop: 'fill'
76
- }]}
77
- />
78
- ```
70
+ [Learn more about CldOgImage on the Next Cloudinary Docs](https://next-cloudinary.spacejelly.dev/components/cldogimage/basic-usage)
71
+
72
+ ### Other Use Cases
73
+
74
+ * [Background Removal](https://next-cloudinary.spacejelly.dev/use-cases/background-removal)
75
+ * [Image Overlays](https://next-cloudinary.spacejelly.dev/use-cases/image-underlays)
76
+ * [Image Underlays](https://next-cloudinary.spacejelly.dev/use-cases/image-overlays)
77
+ * [Social Media Card](https://next-cloudinary.spacejelly.dev/use-cases/social-media-card)
78
+ * [Text Overlays](https://next-cloudinary.spacejelly.dev/use-cases/text-overlays)
79
+
80
+ ## ❤️ Community & Support
81
+
82
+ * [GitHub: Create an Issue](https://github.com/colbyfayock/next-cloudinary/issues)
83
+ * [Twitter: @colbyfayock](https://twitter.com/colbyfayock)
84
+
85
+ ## 🛠 Contributing
79
86
 
80
- As CldImage is a wrapper around the Next.js Image component, all built-in Image component features will work out-of-the-box including the `layout` prop.
81
-
82
- ## 🛠 Configuration
83
-
84
- ### General Props
85
-
86
- | Prop Name | Type | Example |
87
- |--------------------|--------------------|------------------------------|
88
- | crop | string | `"thumb"` |
89
- | gravity | string | `"faces"` |
90
- | overlays | array | See Below |
91
- | rawTransformations | array | `['e_blur:2000']` |
92
- | removeBackground | bool/string | `true` |
93
- | underlays | array | See Below |
94
- | zoompan | bool/string/object | See Below |
95
-
96
- ### Effect Props
97
-
98
- | Prop Name | Type | Example |
99
- |------------------ |-------------|------------------------------|
100
- | art | string | `"al_dente"` |
101
- | autoBrightness | bool/string | `true`, `"80"` |
102
- | autoColor | bool/string | `true`, `"80"` |
103
- | autoContrast | bool/string | `true`, `"80"` |
104
- | assistColorblind | bool/string | `true`, `"20"`, `"xray"` |
105
- | blackwhite | bool/string | `true`, `"40"` |
106
- | blur | bool/string | `true`, `"800"` |
107
- | blurFaces | bool/string | `true`, `"800"` |
108
- | blurRegion | bool/string | `true`, `"1000,h_425,w_550,x_600,y_400"` |
109
- | brightness | bool/string | `true`, `"100"` |
110
- | brightnessHSB | bool/string | `true`, `"100"` |
111
- | cartoonify | bool/string | `true`, `"70:80"` |
112
- | colorize | string | `"35,co_darkviolet"` |
113
- | contrast | bool/string | `true`, `"100"`, `"level_-70"` |
114
- | distort | string | `"150:340:1500:10:1500:1550:50:1000"`, `"arc:180.0"` |
115
- | fillLight | bool/string | `true`, `"70:20"` |
116
- | gamma | bool/string | `true`, `"100"` |
117
- | gradientFade | bool/string | `true`, `"symmetric:10,x_0.2,y_0.4"` |
118
- | grayscale | bool | `true` |
119
- | improve | bool/string | `true`, `"50"`, `"indoor"` |
120
- | negate | bool | `true` |
121
- | oilPaint | bool/string | `true`, `"40"` |
122
- | outline | bool/string | `true`, `"40"`, `"outer:15:200"` |
123
- | pixelate | bool/string | `true`, `"20"` |
124
- | pixelateFaces | bool/string | `true`, `"20"` |
125
- | pixelateRegion | bool/string | `true`, `"35,h_425,w_550,x_600,y_400"` |
126
- | redeye | bool/string | `true` |
127
- | replaceColor | string | `"saddlebrown"`, `"2F4F4F:20"`, `"silver:55:89b8ed"` |
128
- | saturation | bool/string | `true`, `"70"` |
129
- | sepia | bool/string | `true`, `"50"` |
130
- | shadow | bool/string | `true`, `"50,x_-15,y_15"` |
131
- | sharpen | bool/string | `true`, `"100"` |
132
- | shear | string | `"20.0:0.0"` |
133
- | simulateColorblind | bool/string | `"deuteranopia"` |
134
- | tint | bool/string | `true`, `"100:red:blue:yellow"` |
135
- | unsharpMask | bool/string | `true`, `"500"` |
136
- | vectorize | bool/string | `true`, `"3:0.5"` |
137
- | vibrance | bool/string | `true`, `"70"` |
138
- | vignette | bool/string | `true`, `"30"` |
139
-
140
- [View the Cloudinary docs](https://cloudinary.com/documentation/transformation_reference#e_effect) to see learn more about using effects.
141
-
142
- ### Background Removal
143
-
144
- Removing backgrounds require enabling the [Cloudinary AI Background Removal Add-On](https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon) which includes a free tier for getting started.
145
-
146
- Once enabled, you can simply apply the `removeBackground` prop.
147
-
148
- **Example:**
87
+ Please read [CONTRIBUTING.md](https://github.com/colbyfayock/next-cloudinary/blob/main/CONTRIBUTING.md) prior to contributing.
88
+
89
+ ### Working Locally
90
+
91
+ #### Installation
92
+
93
+ This project is currently using [yarn](https://yarnpkg.com/) as a way to manage dependencies and workspaces.
94
+
95
+ With the project cloned, install the dependencies from the root of the project with:
149
96
 
150
97
  ```
151
- <CldImage
152
- ...
153
- removeBackground
154
- />
98
+ yarn install
155
99
  ```
156
100
 
157
- ### Overlays
101
+ #### Configuration
158
102
 
159
- The `overlays` prop is an array of objects with the following configuration options:
103
+ To work on the project, you need to have an active Cloudinary account. With the account, configure a `.env.local` file inside of `docs` with:
160
104
 
161
- | Property Name | Type | Example |
162
- |------------------|-------------|--------------------------------------|
163
- | effects | array | See Below |
164
- | position | object | See Below |
165
- | publicId | string | `"thumb"` |
166
- | text | object | See Below |
105
+ ```
106
+ NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="<Your Cloudinary Cloud Name>"
107
+ NEXT_PUBLIC_CLOUDINARY_API_KEY="<Your Cloudinary API Key>"
108
+ CLOUDINARY_API_SECRET="<Your Cloudinary API Secret>"
109
+ NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET="<Your Cloudinary Upload Preset>"
110
+ ```
167
111
 
168
- The position property can include:
112
+ > Note: The Cloudinary account can be free, but some features may not work beyond free tier like Background Removal
169
113
 
170
- | Property Name | Type | Example |
171
- |------------------|-------------|--------------------------------------|
172
- | angle | number | `45` |
173
- | gravity | string | '"north_west"' |
174
- | x | number | `10` |
175
- | y | number | `10` |
114
+ The Cloud Name is required for all usage, where the API Key and Secret currently is only used for Upload Widget usage. The Upload Preset is additionally used for the Upload Widgets.
176
115
 
177
- Objects in the effects array can include:
116
+ #### Uploading Example Images
178
117
 
179
- | Property Name | Type | Example |
180
- |------------------|-------------|--------------------------------------|
181
- | aspectRatio | string | `"3.0"` |
182
- | crop | string | `10` |
183
- | gravity | string | '"north_west"' |
184
- | height | number | '600' |
185
- | width | number | '600' |
118
+ In order to run the Docs project, you need to have the images referenced available inside of your Cloudinary account.
186
119
 
187
- The text property can include:
120
+ To do this, navigate to the `scripts` directory and first create a new `.env` file with:
188
121
 
189
- | Property Name | Type | Example |
190
- |------------------|-------------|--------------------------------------|
191
- | color | string | `"blueviolet"` |
192
- | fontFamily | string | `"Open Sans"` |
193
- | fontSize | number | `48` |
194
- | fontWeight | string | `"bold"` |
195
- | letterSpacing | number | `"14"` |
196
- | textDecoration | string | `"underline"` |
122
+ ```
123
+ CLOUDINARY_CLOUD_NAME="<Your Cloudinary Cloud Name>"
124
+ CLOUDINARY_API_KEY="<Your API Key>"
125
+ CLOUDINARY_API_SECRET="<Your API Secret>"
126
+ ```
197
127
 
198
- #### Adding Images
128
+ Then run the upload script with:
199
129
 
200
- You can add images on top of other images by using image-based overlays.
130
+ ```
131
+ yarn upload
132
+ ```
201
133
 
202
- **Example:**
134
+ By default, the images inside of `scripts/images.json` will be uploaded to the "images" directory inside of your Cloudinary account. To change the location, add the `CLOUDINARY_EXAMPLES_DIRECTORY` environment variable with your preferred directory:
203
135
 
204
136
  ```
205
- <CldImage
206
- ...
207
- overlays={[{
208
- publicId: '<Public ID>',
209
- position: {
210
- x: 10,
211
- y: 10,
212
- gravity: 'north_west',
213
- },
214
- effects: [
215
- {
216
- crop: 'fill',
217
- gravity: 'auto',
218
- width: 500,
219
- height: 500
220
- }
221
- ]
222
- }]}
223
- />
137
+ CLOUDINARY_EXAMPLES_DIRECTORY="<Your Directory>"
224
138
  ```
225
139
 
226
- #### Adding Text
227
-
228
- You can add text on top of your image with text-based overlays.
140
+ #### Running the Project
229
141
 
230
- **Example:**
142
+ Once installed and configured, open two terminal tabs, navigating one to `next-cloudinary` and one to `docs`, running the following command in each:
231
143
 
232
144
  ```
233
- <CldImage
234
- ...
235
- overlays={[{
236
- width: 2670 - 20,
237
- crop: 'fit',
238
- position: {
239
- x: 10,
240
- y: 10,
241
- gravity: 'north_west',
242
- },
243
- text: {
244
- color: 'blueviolet',
245
- fontFamily: 'Source Sans Pro',
246
- fontSize: 120,
247
- fontWeight: 'bold',
248
- textDecoration: 'underline',
249
- letterSpacing: 14,
250
- text: 'Text'
251
- }
252
- }]}
253
- />
145
+ yarn dev
254
146
  ```
255
147
 
256
- ### Underlays
148
+ The project will now be available at <https://localhost:3000> or the configured local port.
257
149
 
258
- Underlays function very similar to overlays in terms of options, however they **do not support text**.
150
+ ### Running Tests
259
151
 
260
- See the examples above under Overlays to learn more about the available configurations.
152
+ All tests are located inside of `next-cloudinary/tests` with a directory structure that should reflect `next-cloudinary/src`.
261
153
 
262
- **Example:**
154
+ While inside `next-cloudinary`, run tests with:
263
155
 
264
156
  ```
265
- <CldImage
266
- ...
267
- underlays={[{
268
- publicId: '<Public ID>',
269
- width: 1920,
270
- height: 1200,
271
- crop: 'fill'
272
- }]}
273
- />
157
+ yarn test
274
158
  ```
275
159
 
276
- ## Contributors
160
+ ### Contributors
277
161
 
278
162
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
279
163
  <!-- prettier-ignore-start -->