@photos-sh/photos 1.0.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to this library are written down here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the library
5
5
  follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## Unreleased
8
+
9
+ - `removeBackground` takes `studio`, for studio shots (a product on a plain,
10
+ light backdrop): it also keeps what clearly stands out from the backdrop and
11
+ touches the product, such as the gift box, case or lid shown with a bottle.
12
+ It is sent only when given.
13
+ - `subjectFound` docs: since engine 0.1.9 the API returns the photo as it was,
14
+ with `X-Subject-Found: false`, whenever no subject is found (under 3% of the
15
+ photo), not only for an empty canvas.
16
+
7
17
  ## 1.0.0 (unreleased)
8
18
 
9
19
  First version.
package/README.md CHANGED
@@ -116,8 +116,17 @@ const cutout = await photos.removeBackground("shoe.jpg", {
116
116
 
117
117
  // The greyscale alpha mask instead of the cutout:
118
118
  const mask = await photos.removeBackground("shoe.jpg", { mask: true });
119
+
120
+ // A studio shot (a product on a plain, light backdrop, as in a light tent):
121
+ // also keep the gift box, case or lid shown with the bottle.
122
+ const boxed = await photos.removeBackground("bottle.jpg", { studio: true });
119
123
  ```
120
124
 
125
+ `studio` also keeps what clearly stands out from the backdrop and touches the
126
+ product, such as a pale box the model left half transparent. Shadows and the
127
+ floor below the product are left out. A photo without a plain light backdrop
128
+ is cut out as without it.
129
+
121
130
  The same call can stage the cutout: on a canvas, with a shadow or a reflection
122
131
  under it, and with a colour, an image or the photo's own blurred background
123
132
  behind it.
@@ -132,7 +141,7 @@ const staged = await photos.removeBackground("shoe.jpg", {
132
141
  reflection: true, // needs room below the subject: a fill under 1
133
142
  backgroundImage: "studio.jpg", // an image behind the subject, scaled to cover
134
143
  });
135
- staged.subjectFound; // false: the photo has no subject and the canvas is empty
144
+ staged.subjectFound; // false: no subject was found and the photo comes back as it was
136
145
 
137
146
  // The photo's own background, blurred (1 to 100):
138
147
  const soft = await photos.removeBackground("portrait.jpg", { blur: 40 });
package/dist/results.d.ts CHANGED
@@ -22,8 +22,8 @@ export declare class ImageResult {
22
22
  /** The result of `removeBackground`. */
23
23
  export declare class RemoveBackgroundResult extends ImageResult {
24
24
  /**
25
- * `false` when a canvas was asked for and the photo has no subject: the
26
- * canvas is then empty. `undefined` when the API does not say (no
25
+ * `false` when no subject was found (under 3% of the photo): the photo is
26
+ * then returned as it was. `undefined` when the API does not say (no
27
27
  * `X-Subject-Found` header), which is not the same as `false`.
28
28
  */
29
29
  readonly subjectFound: boolean | undefined;
package/dist/results.js CHANGED
@@ -63,8 +63,8 @@ export class ImageResult {
63
63
  /** The result of `removeBackground`. */
64
64
  export class RemoveBackgroundResult extends ImageResult {
65
65
  /**
66
- * `false` when a canvas was asked for and the photo has no subject: the
67
- * canvas is then empty. `undefined` when the API does not say (no
66
+ * `false` when no subject was found (under 3% of the photo): the photo is
67
+ * then returned as it was. `undefined` when the API does not say (no
68
68
  * `X-Subject-Found` header), which is not the same as `false`.
69
69
  */
70
70
  subjectFound;
package/dist/types.d.ts CHANGED
@@ -32,6 +32,15 @@ export interface RemoveBackgroundOptions extends OutputOptions, RequestOptions {
32
32
  crop?: boolean | undefined;
33
33
  /** Margin around the subject when cropping, in pixels. */
34
34
  padding?: number | undefined;
35
+ /**
36
+ * For studio shots (a product on a plain, light backdrop, as in a light
37
+ * tent): also keep what clearly stands out from the backdrop and touches the
38
+ * product, such as the gift box, case or lid shown with a bottle, or a pale
39
+ * box the model left half transparent. Shadows and the floor below the
40
+ * product are left out. A photo without a plain light backdrop is cut out as
41
+ * without it.
42
+ */
43
+ studio?: boolean | undefined;
35
44
  /** Return the greyscale alpha mask instead of the cutout. Takes no staging options. */
36
45
  mask?: boolean | undefined;
37
46
  /** Place the subject on a canvas this wide, in pixels. Needs `height`. */
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The version of this library (kept equal to `package.json`). */
2
- export declare const VERSION = "1.0.0";
2
+ export declare const VERSION = "1.1.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The version of this library (kept equal to `package.json`). */
2
- export const VERSION = "1.0.0";
2
+ export const VERSION = "1.1.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photos-sh/photos",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Client library for the Photos.sh image API: background removal, resizing, upscaling, object and text removal, marketplace checks and fixes, barcode and label reading.",
5
5
  "license": "MIT",
6
6
  "author": "Vallic",