n8n-nodes-commandos-image 0.1.10 → 0.1.11
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.
|
@@ -16,15 +16,25 @@ const resolveGenerationUrl = (resolvedModel) => {
|
|
|
16
16
|
return GENERATION_URL_DEFAULT;
|
|
17
17
|
};
|
|
18
18
|
const mapRatio = (model, ratio) => {
|
|
19
|
-
|
|
19
|
+
const isSeedream = model.includes('seedream');
|
|
20
|
+
const isGpt = model === 'gpt4o-image';
|
|
21
|
+
if (isSeedream) {
|
|
20
22
|
if (ratio === '2:3')
|
|
21
23
|
return 'portrait_3_2';
|
|
22
24
|
if (ratio === '3:2')
|
|
23
25
|
return 'landscape_2_3';
|
|
24
26
|
}
|
|
27
|
+
if (isGpt) {
|
|
28
|
+
if (ratio === '1:1')
|
|
29
|
+
return '1024x1024';
|
|
30
|
+
if (ratio === '2:3')
|
|
31
|
+
return '1024x1792';
|
|
32
|
+
if (ratio === '3:2')
|
|
33
|
+
return '1792x1024';
|
|
34
|
+
}
|
|
25
35
|
return ratio;
|
|
26
36
|
};
|
|
27
|
-
const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'basic', resolution = '1K',
|
|
37
|
+
const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'basic', resolution = '1K', }) => {
|
|
28
38
|
const hasReferences = references.length > 0;
|
|
29
39
|
const requestedModel = model;
|
|
30
40
|
let resolvedModel = model;
|
|
@@ -50,9 +60,9 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'b
|
|
|
50
60
|
body = {
|
|
51
61
|
filesUrl: references,
|
|
52
62
|
prompt,
|
|
53
|
-
size: ratio,
|
|
54
|
-
callBackUrl: 'https://api.comandos.ai/internal/kie/callback',
|
|
63
|
+
size: mapRatio(resolvedModel, ratio),
|
|
55
64
|
fallbackModel: 'FLUX_MAX',
|
|
65
|
+
// callBackUrl is handled by server automatically
|
|
56
66
|
};
|
|
57
67
|
}
|
|
58
68
|
else if (resolvedModel.includes('flux-2/')) {
|
|
@@ -62,7 +72,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'b
|
|
|
62
72
|
prompt,
|
|
63
73
|
aspect_ratio: ratio,
|
|
64
74
|
resolution,
|
|
65
|
-
output_format: 'jpeg',
|
|
75
|
+
output_format: 'jpeg', // Force lightweight
|
|
66
76
|
...(hasReferences ? { input_urls: references } : {}),
|
|
67
77
|
},
|
|
68
78
|
};
|
|
@@ -74,7 +84,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'b
|
|
|
74
84
|
prompt,
|
|
75
85
|
aspect_ratio: mapRatio(resolvedModel, ratio),
|
|
76
86
|
quality,
|
|
77
|
-
output_format: 'jpeg',
|
|
87
|
+
output_format: 'jpeg', // Force lightweight
|
|
78
88
|
...(hasReferences ? { image_urls: references } : {}),
|
|
79
89
|
},
|
|
80
90
|
};
|
|
@@ -86,7 +96,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'b
|
|
|
86
96
|
prompt,
|
|
87
97
|
aspect_ratio: ratio,
|
|
88
98
|
resolution,
|
|
89
|
-
output_format:
|
|
99
|
+
output_format: 'jpg', // Force lightweight
|
|
90
100
|
...(hasReferences ? { image_input: references } : {}),
|
|
91
101
|
},
|
|
92
102
|
};
|
|
@@ -97,7 +107,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'b
|
|
|
97
107
|
input: {
|
|
98
108
|
prompt,
|
|
99
109
|
image_size: ratio,
|
|
100
|
-
output_format: 'jpeg',
|
|
110
|
+
output_format: 'jpeg', // Force lightweight
|
|
101
111
|
...(hasReferences ? { image_urls: references } : {}),
|
|
102
112
|
},
|
|
103
113
|
};
|
|
@@ -230,19 +240,6 @@ class CommandosImage {
|
|
|
230
240
|
show: { operation: ['create'], model: ['gpt4o-image'] },
|
|
231
241
|
},
|
|
232
242
|
},
|
|
233
|
-
{
|
|
234
|
-
displayName: 'Output Format',
|
|
235
|
-
name: 'outputFormatBananaPro',
|
|
236
|
-
type: 'options',
|
|
237
|
-
options: [
|
|
238
|
-
{ name: 'PNG', value: 'png' },
|
|
239
|
-
{ name: 'JPG', value: 'jpg' },
|
|
240
|
-
],
|
|
241
|
-
default: 'jpg',
|
|
242
|
-
displayOptions: {
|
|
243
|
-
show: { operation: ['create'], model: ['nano-banana-pro'] },
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
243
|
{
|
|
247
244
|
displayName: 'Quality',
|
|
248
245
|
name: 'quality',
|
|
@@ -319,11 +316,10 @@ class CommandosImage {
|
|
|
319
316
|
const references = extractReferences(this.getNodeParameter('references', i, {}), model);
|
|
320
317
|
const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model) ? String(this.getNodeParameter('quality', i, 'basic')) : 'basic';
|
|
321
318
|
const resolution = ['flux-pro', 'nano-banana-pro'].includes(model) ? String(this.getNodeParameter('resolution', i, '1K')) : '1K';
|
|
322
|
-
const outputFormat = (model === 'nano-banana-pro') ? String(this.getNodeParameter('outputFormatBananaPro', i, 'jpg')) : undefined;
|
|
323
319
|
if (!prompt)
|
|
324
320
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Prompt is required', { itemIndex: i });
|
|
325
|
-
const request = buildGenerationRequest({ model, prompt, ratio, references, quality, resolution
|
|
326
|
-
const payload = { ...request, licenseKey, _v: '0.1.
|
|
321
|
+
const request = buildGenerationRequest({ model, prompt, ratio, references, quality, resolution });
|
|
322
|
+
const payload = { ...request, licenseKey, _v: '0.1.11' };
|
|
327
323
|
const response = await this.helpers.request({
|
|
328
324
|
method: 'POST',
|
|
329
325
|
url: `${COMMANDOS_API_URL}/tasks`,
|
|
@@ -19,7 +19,6 @@ type BuildParams = {
|
|
|
19
19
|
references: string[];
|
|
20
20
|
quality?: string;
|
|
21
21
|
resolution?: string;
|
|
22
|
-
outputFormat?: string;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
type BuildResult = {
|
|
@@ -43,10 +42,20 @@ const resolveGenerationUrl = (resolvedModel: string): string => {
|
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
const mapRatio = (model: string, ratio: string): string => {
|
|
46
|
-
|
|
45
|
+
const isSeedream = model.includes('seedream');
|
|
46
|
+
const isGpt = model === 'gpt4o-image';
|
|
47
|
+
|
|
48
|
+
if (isSeedream) {
|
|
47
49
|
if (ratio === '2:3') return 'portrait_3_2';
|
|
48
50
|
if (ratio === '3:2') return 'landscape_2_3';
|
|
49
51
|
}
|
|
52
|
+
|
|
53
|
+
if (isGpt) {
|
|
54
|
+
if (ratio === '1:1') return '1024x1024';
|
|
55
|
+
if (ratio === '2:3') return '1024x1792';
|
|
56
|
+
if (ratio === '3:2') return '1792x1024';
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
return ratio;
|
|
51
60
|
};
|
|
52
61
|
|
|
@@ -57,7 +66,6 @@ const buildGenerationRequest = ({
|
|
|
57
66
|
references,
|
|
58
67
|
quality = 'basic',
|
|
59
68
|
resolution = '1K',
|
|
60
|
-
outputFormat,
|
|
61
69
|
}: BuildParams): BuildResult => {
|
|
62
70
|
const hasReferences = references.length > 0;
|
|
63
71
|
const requestedModel = model;
|
|
@@ -85,9 +93,9 @@ const buildGenerationRequest = ({
|
|
|
85
93
|
body = {
|
|
86
94
|
filesUrl: references,
|
|
87
95
|
prompt,
|
|
88
|
-
size: ratio,
|
|
89
|
-
callBackUrl: 'https://api.comandos.ai/internal/kie/callback',
|
|
96
|
+
size: mapRatio(resolvedModel, ratio),
|
|
90
97
|
fallbackModel: 'FLUX_MAX',
|
|
98
|
+
// callBackUrl is handled by server automatically
|
|
91
99
|
};
|
|
92
100
|
} else if (resolvedModel.includes('flux-2/')) {
|
|
93
101
|
body = {
|
|
@@ -96,7 +104,7 @@ const buildGenerationRequest = ({
|
|
|
96
104
|
prompt,
|
|
97
105
|
aspect_ratio: ratio,
|
|
98
106
|
resolution,
|
|
99
|
-
output_format: 'jpeg',
|
|
107
|
+
output_format: 'jpeg', // Force lightweight
|
|
100
108
|
...(hasReferences ? { input_urls: references } : {}),
|
|
101
109
|
},
|
|
102
110
|
};
|
|
@@ -107,7 +115,7 @@ const buildGenerationRequest = ({
|
|
|
107
115
|
prompt,
|
|
108
116
|
aspect_ratio: mapRatio(resolvedModel, ratio),
|
|
109
117
|
quality,
|
|
110
|
-
output_format: 'jpeg',
|
|
118
|
+
output_format: 'jpeg', // Force lightweight
|
|
111
119
|
...(hasReferences ? { image_urls: references } : {}),
|
|
112
120
|
},
|
|
113
121
|
};
|
|
@@ -118,7 +126,7 @@ const buildGenerationRequest = ({
|
|
|
118
126
|
prompt,
|
|
119
127
|
aspect_ratio: ratio,
|
|
120
128
|
resolution,
|
|
121
|
-
output_format:
|
|
129
|
+
output_format: 'jpg', // Force lightweight
|
|
122
130
|
...(hasReferences ? { image_input: references } : {}),
|
|
123
131
|
},
|
|
124
132
|
};
|
|
@@ -128,7 +136,7 @@ const buildGenerationRequest = ({
|
|
|
128
136
|
input: {
|
|
129
137
|
prompt,
|
|
130
138
|
image_size: ratio,
|
|
131
|
-
output_format: 'jpeg',
|
|
139
|
+
output_format: 'jpeg', // Force lightweight
|
|
132
140
|
...(hasReferences ? { image_urls: references } : {}),
|
|
133
141
|
},
|
|
134
142
|
};
|
|
@@ -257,19 +265,6 @@ export class CommandosImage implements INodeType {
|
|
|
257
265
|
show: { operation: ['create'], model: ['gpt4o-image'] },
|
|
258
266
|
},
|
|
259
267
|
},
|
|
260
|
-
{
|
|
261
|
-
displayName: 'Output Format',
|
|
262
|
-
name: 'outputFormatBananaPro',
|
|
263
|
-
type: 'options',
|
|
264
|
-
options: [
|
|
265
|
-
{ name: 'PNG', value: 'png' },
|
|
266
|
-
{ name: 'JPG', value: 'jpg' },
|
|
267
|
-
],
|
|
268
|
-
default: 'jpg',
|
|
269
|
-
displayOptions: {
|
|
270
|
-
show: { operation: ['create'], model: ['nano-banana-pro'] },
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
268
|
{
|
|
274
269
|
displayName: 'Quality',
|
|
275
270
|
name: 'quality',
|
|
@@ -346,12 +341,11 @@ export class CommandosImage implements INodeType {
|
|
|
346
341
|
const references = extractReferences(this.getNodeParameter('references', i, {}), model);
|
|
347
342
|
const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model) ? String(this.getNodeParameter('quality', i, 'basic')) : 'basic';
|
|
348
343
|
const resolution = ['flux-pro', 'nano-banana-pro'].includes(model) ? String(this.getNodeParameter('resolution', i, '1K')) : '1K';
|
|
349
|
-
const outputFormat = (model === 'nano-banana-pro') ? String(this.getNodeParameter('outputFormatBananaPro', i, 'jpg')) : undefined;
|
|
350
344
|
|
|
351
345
|
if (!prompt) throw new NodeOperationError(this.getNode(), 'Prompt is required', { itemIndex: i });
|
|
352
346
|
|
|
353
|
-
const request = buildGenerationRequest({ model, prompt, ratio, references, quality, resolution
|
|
354
|
-
const payload = { ...request, licenseKey, _v: '0.1.
|
|
347
|
+
const request = buildGenerationRequest({ model, prompt, ratio, references, quality, resolution });
|
|
348
|
+
const payload = { ...request, licenseKey, _v: '0.1.11' };
|
|
355
349
|
const response = await this.helpers.request({
|
|
356
350
|
method: 'POST',
|
|
357
351
|
url: `${COMMANDOS_API_URL}/tasks`,
|