illustrator-mcp-server 1.0.0 → 1.1.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.ja.md +23 -19
- package/README.md +26 -20
- package/dist/executor/file-transport.d.ts.map +1 -1
- package/dist/executor/file-transport.js +20 -3
- package/dist/executor/file-transport.js.map +1 -1
- package/dist/executor/jsx-runner.d.ts +6 -0
- package/dist/executor/jsx-runner.d.ts.map +1 -1
- package/dist/executor/jsx-runner.js +29 -2
- package/dist/executor/jsx-runner.js.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/export/export-pdf.d.ts.map +1 -1
- package/dist/tools/export/export-pdf.js +2 -7
- package/dist/tools/export/export-pdf.js.map +1 -1
- package/dist/tools/export/export.d.ts.map +1 -1
- package/dist/tools/export/export.js +2 -14
- package/dist/tools/export/export.js.map +1 -1
- package/dist/tools/modify/apply-color-profile.d.ts.map +1 -1
- package/dist/tools/modify/apply-color-profile.js +2 -7
- package/dist/tools/modify/apply-color-profile.js.map +1 -1
- package/dist/tools/modify/convert-to-outlines.d.ts.map +1 -1
- package/dist/tools/modify/convert-to-outlines.js +2 -7
- package/dist/tools/modify/convert-to-outlines.js.map +1 -1
- package/dist/tools/modify/create-ellipse.d.ts.map +1 -1
- package/dist/tools/modify/create-ellipse.js +7 -55
- package/dist/tools/modify/create-ellipse.js.map +1 -1
- package/dist/tools/modify/create-line.d.ts.map +1 -1
- package/dist/tools/modify/create-line.js +6 -42
- package/dist/tools/modify/create-line.js.map +1 -1
- package/dist/tools/modify/create-path.d.ts.map +1 -1
- package/dist/tools/modify/create-path.js +7 -57
- package/dist/tools/modify/create-path.js.map +1 -1
- package/dist/tools/modify/create-rectangle.d.ts.map +1 -1
- package/dist/tools/modify/create-rectangle.js +7 -55
- package/dist/tools/modify/create-rectangle.js.map +1 -1
- package/dist/tools/modify/create-text-frame.d.ts.map +1 -1
- package/dist/tools/modify/create-text-frame.js +5 -35
- package/dist/tools/modify/create-text-frame.js.map +1 -1
- package/dist/tools/modify/modify-object.d.ts.map +1 -1
- package/dist/tools/modify/modify-object.js +10 -56
- package/dist/tools/modify/modify-object.js.map +1 -1
- package/dist/tools/modify/shared.d.ts +34 -0
- package/dist/tools/modify/shared.d.ts.map +1 -0
- package/dist/tools/modify/shared.js +76 -0
- package/dist/tools/modify/shared.js.map +1 -0
- package/dist/tools/read/get-effects.d.ts.map +1 -1
- package/dist/tools/read/get-effects.js +1 -3
- package/dist/tools/read/get-effects.js.map +1 -1
- package/dist/tools/read/get-images.d.ts.map +1 -1
- package/dist/tools/read/get-images.js +45 -5
- package/dist/tools/read/get-images.js.map +1 -1
- package/dist/tools/read/list-text-frames.js +3 -3
- package/dist/tools/utility/preflight-check.d.ts.map +1 -1
- package/dist/tools/utility/preflight-check.js +102 -33
- package/dist/tools/utility/preflight-check.js.map +1 -1
- package/dist/utils/image-header.d.ts +11 -0
- package/dist/utils/image-header.d.ts.map +1 -0
- package/dist/utils/image-header.js +174 -0
- package/dist/utils/image-header.js.map +1 -0
- package/package.json +4 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { colorSchema, strokeSchema, COLOR_HELPERS_JSX } from './shared.js';
|
|
3
4
|
const jsxCode = `
|
|
4
5
|
var preflight = preflightChecks();
|
|
5
6
|
if (preflight) {
|
|
@@ -9,29 +10,7 @@ if (preflight) {
|
|
|
9
10
|
var params = readParamsFile(PARAMS_PATH);
|
|
10
11
|
var doc = app.activeDocument;
|
|
11
12
|
var coordSystem = params.coordinate_system || "artboard-web";
|
|
12
|
-
|
|
13
|
-
function createColor(colorObj) {
|
|
14
|
-
if (!colorObj || colorObj.type === "none") return new NoColor();
|
|
15
|
-
if (colorObj.type === "cmyk") {
|
|
16
|
-
var c = new CMYKColor();
|
|
17
|
-
c.cyan = (typeof colorObj.c === "number") ? colorObj.c : 0;
|
|
18
|
-
c.magenta = (typeof colorObj.m === "number") ? colorObj.m : 0;
|
|
19
|
-
c.yellow = (typeof colorObj.y === "number") ? colorObj.y : 0;
|
|
20
|
-
c.black = (typeof colorObj.k === "number") ? colorObj.k : 0;
|
|
21
|
-
return c;
|
|
22
|
-
}
|
|
23
|
-
if (colorObj.type === "rgb") {
|
|
24
|
-
if (typeof colorObj.r !== "number" && typeof colorObj.g !== "number" && typeof colorObj.b !== "number") {
|
|
25
|
-
return new NoColor(); // チャンネル未指定は NoColor 扱い
|
|
26
|
-
}
|
|
27
|
-
var c = new RGBColor();
|
|
28
|
-
c.red = (typeof colorObj.r === "number") ? colorObj.r : 0;
|
|
29
|
-
c.green = (typeof colorObj.g === "number") ? colorObj.g : 0;
|
|
30
|
-
c.blue = (typeof colorObj.b === "number") ? colorObj.b : 0;
|
|
31
|
-
return c;
|
|
32
|
-
}
|
|
33
|
-
return new NoColor();
|
|
34
|
-
}
|
|
13
|
+
${COLOR_HELPERS_JSX}
|
|
35
14
|
|
|
36
15
|
function findItemByUUID(uuid) {
|
|
37
16
|
var doc = app.activeDocument;
|
|
@@ -87,22 +66,15 @@ if (preflight) {
|
|
|
87
66
|
} catch(e) { errors.push("size: " + e.message); }
|
|
88
67
|
}
|
|
89
68
|
|
|
90
|
-
if (props.fill) {
|
|
69
|
+
if (typeof props.fill !== "undefined") {
|
|
91
70
|
try {
|
|
92
|
-
item
|
|
93
|
-
item.filled = true;
|
|
71
|
+
applyOptionalFill(item, props.fill);
|
|
94
72
|
} catch(e) { errors.push("fill: " + e.message); }
|
|
95
73
|
}
|
|
96
74
|
|
|
97
75
|
if (props.stroke) {
|
|
98
76
|
try {
|
|
99
|
-
|
|
100
|
-
item.strokeColor = createColor(props.stroke.color);
|
|
101
|
-
}
|
|
102
|
-
if (typeof props.stroke.width === "number") {
|
|
103
|
-
item.strokeWidth = props.stroke.width;
|
|
104
|
-
}
|
|
105
|
-
item.stroked = true;
|
|
77
|
+
applyStroke(item, props.stroke, item.stroked);
|
|
106
78
|
} catch(e) { errors.push("stroke: " + e.message); }
|
|
107
79
|
}
|
|
108
80
|
|
|
@@ -154,22 +126,10 @@ if (preflight) {
|
|
|
154
126
|
}
|
|
155
127
|
}
|
|
156
128
|
`;
|
|
157
|
-
const colorSchema = z
|
|
158
|
-
.object({
|
|
159
|
-
type: z.enum(['cmyk', 'rgb', 'none']).describe('Color type'),
|
|
160
|
-
c: z.number().optional(),
|
|
161
|
-
m: z.number().optional(),
|
|
162
|
-
y: z.number().optional(),
|
|
163
|
-
k: z.number().optional(),
|
|
164
|
-
r: z.number().optional(),
|
|
165
|
-
g: z.number().optional(),
|
|
166
|
-
b: z.number().optional(),
|
|
167
|
-
})
|
|
168
|
-
.optional();
|
|
169
129
|
export function register(server) {
|
|
170
130
|
server.registerTool('modify_object', {
|
|
171
131
|
title: 'Modify Object',
|
|
172
|
-
description: 'Modify properties of an existing object',
|
|
132
|
+
description: 'Modify properties of an existing object. Note: Illustrator will be activated (brought to foreground) during execution.',
|
|
173
133
|
inputSchema: {
|
|
174
134
|
uuid: z.string().describe('UUID of the target object'),
|
|
175
135
|
properties: z
|
|
@@ -183,19 +143,13 @@ export function register(server) {
|
|
|
183
143
|
.describe('Position'),
|
|
184
144
|
size: z
|
|
185
145
|
.object({
|
|
186
|
-
width: z.number().describe('Width'),
|
|
187
|
-
height: z.number().describe('Height'),
|
|
146
|
+
width: z.number().optional().describe('Width'),
|
|
147
|
+
height: z.number().optional().describe('Height'),
|
|
188
148
|
})
|
|
189
149
|
.optional()
|
|
190
150
|
.describe('Size'),
|
|
191
151
|
fill: colorSchema.describe('Fill color'),
|
|
192
|
-
stroke:
|
|
193
|
-
.object({
|
|
194
|
-
color: colorSchema.describe('Stroke color'),
|
|
195
|
-
width: z.number().describe('Stroke width'),
|
|
196
|
-
})
|
|
197
|
-
.optional()
|
|
198
|
-
.describe('Stroke settings'),
|
|
152
|
+
stroke: strokeSchema.describe('Stroke settings'),
|
|
199
153
|
opacity: z.number().optional().describe('Opacity (0-100)'),
|
|
200
154
|
rotation: z.number().optional().describe('Rotation angle (degrees), relative to current angle'),
|
|
201
155
|
name: z.string().optional().describe('Object name'),
|
|
@@ -217,7 +171,7 @@ export function register(server) {
|
|
|
217
171
|
openWorldHint: false,
|
|
218
172
|
},
|
|
219
173
|
}, async (params) => {
|
|
220
|
-
const result = await executeJsx(jsxCode, params);
|
|
174
|
+
const result = await executeJsx(jsxCode, params, { activate: true });
|
|
221
175
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
222
176
|
});
|
|
223
177
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-object.js","sourceRoot":"","sources":["../../../src/tools/modify/modify-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"modify-object.js","sourceRoot":"","sources":["../../../src/tools/modify/modify-object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE3E,MAAM,OAAO,GAAG;;;;;;;;;MASV,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmHtB,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,wHAAwH;QACrI,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,Q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S,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;aACzE,CAAC;iBACD,QAAQ,CAAC,sBAAsB,CAAC;YACnC,iBAAiB,EAAE,CAAC;iBACjB,IAAI,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;iBAClC,QAAQ,EAAE;iBACV,OAAO,CAAC,cAAc,CAAC;iBACvB,QAAQ,CAAC,sGAAsG,CAAC;SACpH;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,KAAK;SACrB;KACF,EACD,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const colorSchema: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"cmyk">;
|
|
4
|
+
c: z.ZodNumber;
|
|
5
|
+
m: z.ZodNumber;
|
|
6
|
+
y: z.ZodNumber;
|
|
7
|
+
k: z.ZodNumber;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"rgb">;
|
|
10
|
+
r: z.ZodNumber;
|
|
11
|
+
g: z.ZodNumber;
|
|
12
|
+
b: z.ZodNumber;
|
|
13
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"none">;
|
|
15
|
+
}, z.core.$strip>], "type">>;
|
|
16
|
+
export declare const strokeSchema: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
color: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"cmyk">;
|
|
19
|
+
c: z.ZodNumber;
|
|
20
|
+
m: z.ZodNumber;
|
|
21
|
+
y: z.ZodNumber;
|
|
22
|
+
k: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"rgb">;
|
|
25
|
+
r: z.ZodNumber;
|
|
26
|
+
g: z.ZodNumber;
|
|
27
|
+
b: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"none">;
|
|
30
|
+
}, z.core.$strip>], "type">>;
|
|
31
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
export declare const COLOR_HELPERS_JSX = "\nfunction createColor(colorObj) {\n if (!colorObj || colorObj.type === \"none\") return new NoColor();\n if (colorObj.type === \"cmyk\") {\n var c = new CMYKColor();\n c.cyan = colorObj.c;\n c.magenta = colorObj.m;\n c.yellow = colorObj.y;\n c.black = colorObj.k;\n return c;\n }\n if (colorObj.type === \"rgb\") {\n var c = new RGBColor();\n c.red = colorObj.r;\n c.green = colorObj.g;\n c.blue = colorObj.b;\n return c;\n }\n return new NoColor();\n}\n\nfunction applyOptionalFill(item, colorObj) {\n if (typeof colorObj === \"undefined\") return;\n if (!colorObj || colorObj.type === \"none\") {\n item.filled = false;\n return;\n }\n item.fillColor = createColor(colorObj);\n item.filled = true;\n}\n\nfunction applyStroke(item, strokeObj, defaultStroked) {\n if (!strokeObj) {\n item.stroked = defaultStroked;\n return;\n }\n if (typeof strokeObj.width === \"number\") {\n item.strokeWidth = strokeObj.width;\n }\n if (strokeObj.color && strokeObj.color.type === \"none\") {\n item.stroked = false;\n return;\n }\n if (strokeObj.color) {\n item.strokeColor = createColor(strokeObj.color);\n }\n item.stroked = true;\n}\n";
|
|
34
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/tools/modify/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;4BAEX,CAAC;AAEd,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;kBAKZ,CAAC;AAEd,eAAO,MAAM,iBAAiB,wrCAgD7B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const cmykColorSchema = z.object({
|
|
3
|
+
type: z.literal('cmyk').describe('Color type'),
|
|
4
|
+
c: z.number().describe('Cyan'),
|
|
5
|
+
m: z.number().describe('Magenta'),
|
|
6
|
+
y: z.number().describe('Yellow'),
|
|
7
|
+
k: z.number().describe('Black'),
|
|
8
|
+
});
|
|
9
|
+
const rgbColorSchema = z.object({
|
|
10
|
+
type: z.literal('rgb').describe('Color type'),
|
|
11
|
+
r: z.number().describe('Red'),
|
|
12
|
+
g: z.number().describe('Green'),
|
|
13
|
+
b: z.number().describe('Blue'),
|
|
14
|
+
});
|
|
15
|
+
const noColorSchema = z.object({
|
|
16
|
+
type: z.literal('none').describe('Color type'),
|
|
17
|
+
});
|
|
18
|
+
export const colorSchema = z
|
|
19
|
+
.discriminatedUnion('type', [cmykColorSchema, rgbColorSchema, noColorSchema])
|
|
20
|
+
.optional();
|
|
21
|
+
export const strokeSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
color: colorSchema.describe('Stroke color'),
|
|
24
|
+
width: z.number().optional().describe('Stroke width'),
|
|
25
|
+
})
|
|
26
|
+
.optional();
|
|
27
|
+
export const COLOR_HELPERS_JSX = `
|
|
28
|
+
function createColor(colorObj) {
|
|
29
|
+
if (!colorObj || colorObj.type === "none") return new NoColor();
|
|
30
|
+
if (colorObj.type === "cmyk") {
|
|
31
|
+
var c = new CMYKColor();
|
|
32
|
+
c.cyan = colorObj.c;
|
|
33
|
+
c.magenta = colorObj.m;
|
|
34
|
+
c.yellow = colorObj.y;
|
|
35
|
+
c.black = colorObj.k;
|
|
36
|
+
return c;
|
|
37
|
+
}
|
|
38
|
+
if (colorObj.type === "rgb") {
|
|
39
|
+
var c = new RGBColor();
|
|
40
|
+
c.red = colorObj.r;
|
|
41
|
+
c.green = colorObj.g;
|
|
42
|
+
c.blue = colorObj.b;
|
|
43
|
+
return c;
|
|
44
|
+
}
|
|
45
|
+
return new NoColor();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function applyOptionalFill(item, colorObj) {
|
|
49
|
+
if (typeof colorObj === "undefined") return;
|
|
50
|
+
if (!colorObj || colorObj.type === "none") {
|
|
51
|
+
item.filled = false;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
item.fillColor = createColor(colorObj);
|
|
55
|
+
item.filled = true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function applyStroke(item, strokeObj, defaultStroked) {
|
|
59
|
+
if (!strokeObj) {
|
|
60
|
+
item.stroked = defaultStroked;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof strokeObj.width === "number") {
|
|
64
|
+
item.strokeWidth = strokeObj.width;
|
|
65
|
+
}
|
|
66
|
+
if (strokeObj.color && strokeObj.color.type === "none") {
|
|
67
|
+
item.stroked = false;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (strokeObj.color) {
|
|
71
|
+
item.strokeColor = createColor(strokeObj.color);
|
|
72
|
+
}
|
|
73
|
+
item.stroked = true;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AAC;AAEd,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;CACtD,CAAC;KACD,QAAQ,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-effects.d.ts","sourceRoot":"","sources":["../../../src/tools/read/get-effects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-effects.d.ts","sourceRoot":"","sources":["../../../src/tools/read/get-effects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkKpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4BhD"}
|
|
@@ -140,9 +140,7 @@ try {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
} else {
|
|
143
|
-
var
|
|
144
|
-
var count = doc.pageItems.length < limit ? doc.pageItems.length : limit;
|
|
145
|
-
for (var j = 0; j < count; j++) {
|
|
143
|
+
for (var j = 0; j < doc.pageItems.length; j++) {
|
|
146
144
|
items.push(getEffectInfo(doc.pageItems[j], coordSystem));
|
|
147
145
|
}
|
|
148
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-effects.js","sourceRoot":"","sources":["../../../src/tools/read/get-effects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D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,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-images.d.ts","sourceRoot":"","sources":["../../../src/tools/read/get-images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"get-images.d.ts","sourceRoot":"","sources":["../../../src/tools/read/get-images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA0JpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmEhD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { readImageDimensions } from '../../utils/image-header.js';
|
|
3
4
|
const jsxCode = `
|
|
4
5
|
try {
|
|
5
6
|
var err = preflightChecks();
|
|
@@ -34,7 +35,9 @@ try {
|
|
|
34
35
|
pixelWidth: null,
|
|
35
36
|
pixelHeight: null,
|
|
36
37
|
artboardIndex: abIndex,
|
|
37
|
-
bounds: bounds
|
|
38
|
+
bounds: bounds,
|
|
39
|
+
widthPt: null,
|
|
40
|
+
heightPt: null
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
try {
|
|
@@ -45,6 +48,17 @@ try {
|
|
|
45
48
|
|
|
46
49
|
try { info.name = item.name || ""; } catch(e) {}
|
|
47
50
|
|
|
51
|
+
// Store placed dimensions in points for Node.js-side DPI calculation
|
|
52
|
+
try {
|
|
53
|
+
var pBounds = item.geometricBounds;
|
|
54
|
+
var pWidthPt = pBounds[2] - pBounds[0];
|
|
55
|
+
var pHeightPt = -(pBounds[3] - pBounds[1]);
|
|
56
|
+
if (pWidthPt < 0) pWidthPt = -pWidthPt;
|
|
57
|
+
if (pHeightPt < 0) pHeightPt = -pHeightPt;
|
|
58
|
+
info.widthPt = pWidthPt;
|
|
59
|
+
info.heightPt = pHeightPt;
|
|
60
|
+
} catch(e) {}
|
|
61
|
+
|
|
48
62
|
images.push(info);
|
|
49
63
|
}
|
|
50
64
|
|
|
@@ -108,9 +122,10 @@ try {
|
|
|
108
122
|
try {
|
|
109
123
|
var m = rItem.matrix;
|
|
110
124
|
if (m && placedWidthPt > 0 && placedHeightPt > 0) {
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
var
|
|
125
|
+
// Use vector magnitude to handle rotation correctly
|
|
126
|
+
// mValueA/mValueB form horizontal basis vector, mValueC/mValueD form vertical
|
|
127
|
+
var scaleX = Math.sqrt(m.mValueA * m.mValueA + m.mValueB * m.mValueB);
|
|
128
|
+
var scaleY = Math.sqrt(m.mValueC * m.mValueC + m.mValueD * m.mValueD);
|
|
114
129
|
if (scaleX > 0 && scaleY > 0) {
|
|
115
130
|
rInfo.pixelWidth = Math.round(placedWidthPt / scaleX);
|
|
116
131
|
rInfo.pixelHeight = Math.round(placedHeightPt / scaleY);
|
|
@@ -151,7 +166,32 @@ export function register(server) {
|
|
|
151
166
|
openWorldHint: false,
|
|
152
167
|
},
|
|
153
168
|
}, async (params) => {
|
|
154
|
-
const result = await executeJsx(jsxCode, params);
|
|
169
|
+
const result = (await executeJsx(jsxCode, params));
|
|
170
|
+
// Post-process: compute pixel dimensions and DPI for linked images
|
|
171
|
+
if (result?.images) {
|
|
172
|
+
for (const img of result.images) {
|
|
173
|
+
if (img.type === 'linked' && img.filePath && !img.linkBroken) {
|
|
174
|
+
try {
|
|
175
|
+
const dims = readImageDimensions(img.filePath);
|
|
176
|
+
if (dims && img.widthPt && img.heightPt) {
|
|
177
|
+
img.pixelWidth = dims.width;
|
|
178
|
+
img.pixelHeight = dims.height;
|
|
179
|
+
const widthInches = img.widthPt / 72;
|
|
180
|
+
const heightInches = img.heightPt / 72;
|
|
181
|
+
const ppiH = Math.round(dims.width / widthInches);
|
|
182
|
+
const ppiV = Math.round(dims.height / heightInches);
|
|
183
|
+
img.resolution = Math.min(ppiH, ppiV);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
// Skip unreadable files
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Clean up internal fields
|
|
191
|
+
delete img.widthPt;
|
|
192
|
+
delete img.heightPt;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
155
195
|
return {
|
|
156
196
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
157
197
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-images.js","sourceRoot":"","sources":["../../../src/tools/read/get-images.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"get-images.js","sourceRoot":"","sources":["../../../src/tools/read/get-images.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmJf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,2CAA2C;QACxD,WAAW,EAAE;YACX,iBAAiB,EAAE,CAAC;iBACjB,IAAI,CAAC,CAA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AAC;wBACxC,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC;wBACP,wBAAwB;oBAC1B,CAAC;gBACH,CAAC;gBACD,2BAA2B;gBAC3B,OAAO,GAAG,CAAC,OAAO,CAAC;gBACnB,OAAO,GAAG,CAAC,QAAQ,CAAC;YACtB,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -82,8 +82,8 @@ if (preflight) {
|
|
|
82
82
|
var bounds = getBounds(tf, coordSystem, boundsAbRect);
|
|
83
83
|
|
|
84
84
|
// フォント情報(先頭 textRange)
|
|
85
|
-
var fontFamily =
|
|
86
|
-
var fontSize =
|
|
85
|
+
var fontFamily = null;
|
|
86
|
+
var fontSize = null;
|
|
87
87
|
try {
|
|
88
88
|
if (tf.textRanges.length > 0) {
|
|
89
89
|
var firstRange = tf.textRanges[0];
|
|
@@ -91,7 +91,7 @@ if (preflight) {
|
|
|
91
91
|
fontSize = firstRange.characterAttributes.size;
|
|
92
92
|
}
|
|
93
93
|
} catch (e) {
|
|
94
|
-
//
|
|
94
|
+
// フォント情報が取得できない場合は null のまま
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// 段落スタイル名
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight-check.d.ts","sourceRoot":"","sources":["../../../src/tools/utility/preflight-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"preflight-check.d.ts","sourceRoot":"","sources":["../../../src/tools/utility/preflight-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkVpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2FhD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { executeJsx } from '../../executor/jsx-runner.js';
|
|
3
|
+
import { readImageDimensions } from '../../utils/image-header.js';
|
|
3
4
|
const jsxCode = `
|
|
4
5
|
try {
|
|
5
6
|
var err = preflightChecks();
|
|
@@ -8,6 +9,7 @@ try {
|
|
|
8
9
|
} else {
|
|
9
10
|
var params = readParamsFile(PARAMS_PATH);
|
|
10
11
|
var coordSystem = (params && params.coordinate_system) ? params.coordinate_system : "artboard-web";
|
|
12
|
+
var minDPI = (params && params.min_dpi) ? params.min_dpi : 300;
|
|
11
13
|
var doc = app.activeDocument;
|
|
12
14
|
var results = [];
|
|
13
15
|
var docColorSpace = doc.documentColorSpace;
|
|
@@ -121,7 +123,7 @@ try {
|
|
|
121
123
|
}
|
|
122
124
|
} catch(e) {}
|
|
123
125
|
|
|
124
|
-
// 3. Low resolution images (
|
|
126
|
+
// 3. Low resolution images (embedded raster)
|
|
125
127
|
try {
|
|
126
128
|
for (var ri = 0; ri < doc.rasterItems.length; ri++) {
|
|
127
129
|
var raster = doc.rasterItems[ri];
|
|
@@ -132,43 +134,61 @@ try {
|
|
|
132
134
|
if (widthPt < 0) widthPt = -widthPt;
|
|
133
135
|
if (heightPt < 0) heightPt = -heightPt;
|
|
134
136
|
|
|
135
|
-
var matrix = raster.matrix;
|
|
136
|
-
var ppiH = 72;
|
|
137
|
-
var ppiV = 72;
|
|
138
137
|
try {
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
category: "image_resolution",
|
|
162
|
-
message: "Please verify raster image resolution (exact DPI calculation unavailable due to API limitations)",
|
|
163
|
-
uuid: uuid4,
|
|
164
|
-
details: { name: raster.name || "", widthPt: widthPt, heightPt: heightPt }
|
|
165
|
-
});
|
|
138
|
+
var m = raster.matrix;
|
|
139
|
+
if (m && widthPt > 0 && heightPt > 0) {
|
|
140
|
+
// Use vector magnitude to handle rotation correctly
|
|
141
|
+
var sX = Math.sqrt(m.mValueA * m.mValueA + m.mValueB * m.mValueB);
|
|
142
|
+
var sY = Math.sqrt(m.mValueC * m.mValueC + m.mValueD * m.mValueD);
|
|
143
|
+
if (sX > 0 && sY > 0) {
|
|
144
|
+
var pxW = Math.round(widthPt / sX);
|
|
145
|
+
var pxH = Math.round(heightPt / sY);
|
|
146
|
+
var ppiH = Math.round(pxW / (widthPt / 72));
|
|
147
|
+
var ppiV = Math.round(pxH / (heightPt / 72));
|
|
148
|
+
var effectivePPI = Math.min(ppiH, ppiV);
|
|
149
|
+
if (effectivePPI < minDPI) {
|
|
150
|
+
var uuid4 = ensureUUID(raster);
|
|
151
|
+
results.push({
|
|
152
|
+
level: "error",
|
|
153
|
+
category: "low_resolution",
|
|
154
|
+
message: "Embedded image resolution " + effectivePPI + " DPI is below minimum " + minDPI + " DPI",
|
|
155
|
+
uuid: uuid4,
|
|
156
|
+
details: { name: raster.name || "", effectivePPI: effectivePPI, minDPI: minDPI, pixelWidth: pxW, pixelHeight: pxH }
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
166
160
|
}
|
|
167
161
|
} catch(e2) {}
|
|
168
162
|
} catch(e) {}
|
|
169
163
|
}
|
|
170
164
|
} catch(e) {}
|
|
171
165
|
|
|
166
|
+
// 3b. Collect linked image data for Node.js-side DPI check
|
|
167
|
+
var placedImageData = [];
|
|
168
|
+
try {
|
|
169
|
+
for (var pli = 0; pli < doc.placedItems.length; pli++) {
|
|
170
|
+
var pItem = doc.placedItems[pli];
|
|
171
|
+
try {
|
|
172
|
+
var pFile = pItem.file;
|
|
173
|
+
if (pFile && pFile.exists) {
|
|
174
|
+
var pUuid = ensureUUID(pItem);
|
|
175
|
+
var pBounds = pItem.geometricBounds;
|
|
176
|
+
var pWPt = pBounds[2] - pBounds[0];
|
|
177
|
+
var pHPt = -(pBounds[3] - pBounds[1]);
|
|
178
|
+
if (pWPt < 0) pWPt = -pWPt;
|
|
179
|
+
if (pHPt < 0) pHPt = -pHPt;
|
|
180
|
+
placedImageData.push({
|
|
181
|
+
uuid: pUuid,
|
|
182
|
+
name: pItem.name || "",
|
|
183
|
+
filePath: pFile.fsName,
|
|
184
|
+
widthPt: pWPt,
|
|
185
|
+
heightPt: pHPt
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} catch(e) {}
|
|
189
|
+
}
|
|
190
|
+
} catch(e) {}
|
|
191
|
+
|
|
172
192
|
// 4. Non-outlined fonts (textFrames exist)
|
|
173
193
|
try {
|
|
174
194
|
if (doc.textFrames.length > 0) {
|
|
@@ -304,7 +324,9 @@ try {
|
|
|
304
324
|
coordinateSystem: coordSystem,
|
|
305
325
|
documentColorSpace: isCMYKDoc ? "CMYK" : "RGB",
|
|
306
326
|
checkCount: results.length,
|
|
307
|
-
results: results
|
|
327
|
+
results: results,
|
|
328
|
+
placedImageData: placedImageData,
|
|
329
|
+
minDPI: minDPI
|
|
308
330
|
});
|
|
309
331
|
}
|
|
310
332
|
} catch (e) {
|
|
@@ -320,6 +342,13 @@ export function register(server) {
|
|
|
320
342
|
.enum(['artboard-web', 'document'])
|
|
321
343
|
.optional()
|
|
322
344
|
.default('artboard-web'),
|
|
345
|
+
min_dpi: z
|
|
346
|
+
.number()
|
|
347
|
+
.int()
|
|
348
|
+
.min(1)
|
|
349
|
+
.optional()
|
|
350
|
+
.default(300)
|
|
351
|
+
.describe('Minimum acceptable DPI for images (default: 300)'),
|
|
323
352
|
},
|
|
324
353
|
annotations: {
|
|
325
354
|
readOnlyHint: true,
|
|
@@ -328,7 +357,47 @@ export function register(server) {
|
|
|
328
357
|
openWorldHint: false,
|
|
329
358
|
},
|
|
330
359
|
}, async (params) => {
|
|
331
|
-
const result = await executeJsx(jsxCode, params);
|
|
360
|
+
const result = (await executeJsx(jsxCode, params));
|
|
361
|
+
// Post-process: check PlacedItem DPI using Node.js file reading
|
|
362
|
+
const minDpi = result?.minDPI ?? params.min_dpi ?? 300;
|
|
363
|
+
if (result?.placedImageData) {
|
|
364
|
+
for (const placed of result.placedImageData) {
|
|
365
|
+
if (!placed.filePath || placed.widthPt <= 0 || placed.heightPt <= 0)
|
|
366
|
+
continue;
|
|
367
|
+
try {
|
|
368
|
+
const dims = readImageDimensions(placed.filePath);
|
|
369
|
+
if (dims) {
|
|
370
|
+
const widthInches = placed.widthPt / 72;
|
|
371
|
+
const heightInches = placed.heightPt / 72;
|
|
372
|
+
const ppiH = Math.round(dims.width / widthInches);
|
|
373
|
+
const ppiV = Math.round(dims.height / heightInches);
|
|
374
|
+
const effectivePPI = Math.min(ppiH, ppiV);
|
|
375
|
+
if (effectivePPI < minDpi) {
|
|
376
|
+
result.results.push({
|
|
377
|
+
level: 'error',
|
|
378
|
+
category: 'low_resolution',
|
|
379
|
+
message: `Linked image resolution ${effectivePPI} DPI is below minimum ${minDpi} DPI`,
|
|
380
|
+
uuid: placed.uuid,
|
|
381
|
+
details: {
|
|
382
|
+
name: placed.name,
|
|
383
|
+
effectivePPI,
|
|
384
|
+
minDPI: minDpi,
|
|
385
|
+
pixelWidth: dims.width,
|
|
386
|
+
pixelHeight: dims.height,
|
|
387
|
+
filePath: placed.filePath,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
// Skip unreadable files
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
delete result.placedImageData;
|
|
398
|
+
delete result.minDPI;
|
|
399
|
+
result.checkCount = result.results.length;
|
|
400
|
+
}
|
|
332
401
|
return {
|
|
333
402
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
334
403
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight-check.js","sourceRoot":"","sources":["../../../src/tools/utility/preflight-check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"preflight-check.js","sourceRoot":"","sources":["../../../src/tools/utility/preflight-check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Uf,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,MAAiB;IACxC,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,8BAA8B;QAC3C,WAAW,EAAE;YACX,iBAAiB,EAAE,CAAC;iBACjB,IAAI,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;iBAClC,QAAQ,EAAE;iBACV,OAAO,CAA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,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBAC1C,IAAI,YAAY,GAAG,MAAM,EAAE,CAAC;4BAC1B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;gCAClB,KAAK,EAAE,OAAO;gCACd,QAAQ,EAAE,gBAAgB;gCAC1B,OAAO,EAAE,2BAA2B,YAAY,yBAAyB,MAAM,MAAM;gCACrF,IAAI,EAAE,MAAM,CAAC,IAAI;gCACjB,OAAO,EAAE;oCACP,IAAI,EAAE,MAAM,CAAC,IAAI;oCACjB,YAAY;oCACZ,MAAM,EAAE,MAAM;oCACd,UAAU,EAAE,IAAI,CAAC,KAAK;oCACtB,WAAW,EAAE,IAAI,CAAC,MAAM;oCACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iCAC1B;6BACF,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,wBAAwB;gBAC1B,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC,eAAe,CAAC;YAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;YACrB,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC5C,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ImageDimensions {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Reads pixel dimensions from an image file header.
|
|
7
|
+
* Supports PNG, JPEG, GIF, BMP, and TIFF.
|
|
8
|
+
* Returns null for unsupported or unreadable formats.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readImageDimensions(filePath: string): ImageDimensions | null;
|
|
11
|
+
//# sourceMappingURL=image-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-header.d.ts","sourceRoot":"","sources":["../../src/utils/image-header.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA2ID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAwC5E"}
|