@agent-media/image 0.4.1 → 0.5.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/dist/actions/crop.d.ts +26 -0
- package/dist/actions/crop.d.ts.map +1 -0
- package/dist/actions/crop.js +29 -0
- package/dist/actions/crop.js.map +1 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +1 -0
- package/dist/actions/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MediaResult } from '@agent-media/core';
|
|
2
|
+
export interface CropInput {
|
|
3
|
+
/** Input file path or URL */
|
|
4
|
+
input: string;
|
|
5
|
+
/** Width of crop area in pixels */
|
|
6
|
+
width: number;
|
|
7
|
+
/** Height of crop area in pixels */
|
|
8
|
+
height: number;
|
|
9
|
+
/** Focal point X position as percentage (0-100, default: 50) */
|
|
10
|
+
focusX?: number;
|
|
11
|
+
/** Focal point Y position as percentage (0-100, default: 50) */
|
|
12
|
+
focusY?: number;
|
|
13
|
+
/** DPI/density for output image (default: 300) */
|
|
14
|
+
dpi?: number;
|
|
15
|
+
/** Output directory (overrides default) */
|
|
16
|
+
out?: string;
|
|
17
|
+
/** Output filename (extension auto-added if missing) */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Provider to use (overrides auto-detection) */
|
|
20
|
+
provider?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Crop an image to specified dimensions centered on a focal point
|
|
24
|
+
*/
|
|
25
|
+
export declare function crop(options: CropInput): Promise<MediaResult>;
|
|
26
|
+
//# sourceMappingURL=crop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.d.ts","sourceRoot":"","sources":["../../src/actions/crop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,mBAAmB,CAAC;AAGhF,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CA8BnE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { executeAction, globalRegistry } from '@agent-media/core';
|
|
2
|
+
/**
|
|
3
|
+
* Crop an image to specified dimensions centered on a focal point
|
|
4
|
+
*/
|
|
5
|
+
export async function crop(options) {
|
|
6
|
+
const isUrl = options.input.startsWith('http://') || options.input.startsWith('https://');
|
|
7
|
+
const input = {
|
|
8
|
+
source: options.input,
|
|
9
|
+
isUrl,
|
|
10
|
+
};
|
|
11
|
+
const context = {
|
|
12
|
+
outputDir: options.out ?? process.cwd() + '/.agent-media',
|
|
13
|
+
provider: options.provider,
|
|
14
|
+
outputName: options.name,
|
|
15
|
+
inputSource: options.input,
|
|
16
|
+
};
|
|
17
|
+
return executeAction(globalRegistry, {
|
|
18
|
+
action: 'crop',
|
|
19
|
+
options: {
|
|
20
|
+
input,
|
|
21
|
+
width: options.width,
|
|
22
|
+
height: options.height,
|
|
23
|
+
focusX: options.focusX,
|
|
24
|
+
focusY: options.focusY,
|
|
25
|
+
dpi: options.dpi,
|
|
26
|
+
},
|
|
27
|
+
}, context);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=crop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.js","sourceRoot":"","sources":["../../src/actions/crop.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAuBlE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAkB;IAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAE1F,MAAM,KAAK,GAAe;QACxB,MAAM,EAAE,OAAO,CAAC,KAAK;QACrB,KAAK;KACN,CAAC;IAEF,MAAM,OAAO,GAAkB;QAC7B,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,eAAe;QACzD,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,IAAI;QACxB,WAAW,EAAE,OAAO,CAAC,KAAK;KAC3B,CAAC;IAEF,OAAO,aAAa,CAClB,cAAc,EACd;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,KAAK;YACL,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB;KACF,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export { extend } from './extend.js';
|
|
|
10
10
|
export type { ExtendInput } from './extend.js';
|
|
11
11
|
export { edit } from './edit.js';
|
|
12
12
|
export type { EditInput } from './edit.js';
|
|
13
|
+
export { crop } from './crop.js';
|
|
14
|
+
export type { CropInput } from './crop.js';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/actions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { resize, convert, removeBackground, generate, extend, edit, } from './actions/index.js';
|
|
2
|
-
export type { ResizeInput, ConvertInput, RemoveBackgroundInput, GenerateInput, ExtendInput, EditInput, } from './actions/index.js';
|
|
1
|
+
export { resize, convert, removeBackground, generate, extend, edit, crop, } from './actions/index.js';
|
|
2
|
+
export type { ResizeInput, ConvertInput, RemoveBackgroundInput, GenerateInput, ExtendInput, EditInput, CropInput, } from './actions/index.js';
|
|
3
3
|
export type { MediaResult, MediaSuccessResult, MediaErrorResult, ImageFormat, } from '@agent-media/core';
|
|
4
4
|
export { isSuccess, isError, printResult } from '@agent-media/core';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,IAAI,GACL,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,GACL,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,SAAS,EACT,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Export all actions
|
|
2
|
-
export { resize, convert, removeBackground, generate, extend, edit, } from './actions/index.js';
|
|
2
|
+
export { resize, convert, removeBackground, generate, extend, edit, crop, } from './actions/index.js';
|
|
3
3
|
export { isSuccess, isError, printResult } from '@agent-media/core';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,IAAI,GACL,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EACL,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,GACL,MAAM,oBAAoB,CAAC;AAqB5B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-media/image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Image actions for agent-media toolkit",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agent-media/core": "0.
|
|
29
|
-
"@agent-media/providers": "0.
|
|
28
|
+
"@agent-media/core": "0.8.0",
|
|
29
|
+
"@agent-media/providers": "0.8.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|