n8n-nodes-commandos-image 0.1.7 → 0.1.8
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.
|
@@ -27,20 +27,7 @@ const mapRatio = (model, ratio) => {
|
|
|
27
27
|
}
|
|
28
28
|
return ratio;
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
* Maps standard formats to specific model requirements (jpeg vs jpg)
|
|
32
|
-
*/
|
|
33
|
-
const mapFormat = (model, format) => {
|
|
34
|
-
const f = String(format || 'png').toLowerCase().trim();
|
|
35
|
-
if (model === 'nano-banana-pro') {
|
|
36
|
-
return (f === 'jpeg' || f === 'jpg') ? 'jpg' : f;
|
|
37
|
-
}
|
|
38
|
-
if (model.includes('google/nano-banana')) {
|
|
39
|
-
return (f === 'jpeg' || f === 'jpg') ? 'jpeg' : f;
|
|
40
|
-
}
|
|
41
|
-
return f;
|
|
42
|
-
};
|
|
43
|
-
const buildGenerationRequest = ({ model, prompt, ratio, references, outputFormat = 'png', quality = 'basic', resolution = '1K', }) => {
|
|
30
|
+
const buildGenerationRequest = ({ model, prompt, ratio, references, quality = 'basic', resolution = '1K', }) => {
|
|
44
31
|
const hasReferences = references.length > 0;
|
|
45
32
|
const requestedModel = model;
|
|
46
33
|
let resolvedModel = model;
|
|
@@ -105,7 +92,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, outputFormat
|
|
|
105
92
|
prompt,
|
|
106
93
|
aspect_ratio: ratio,
|
|
107
94
|
resolution,
|
|
108
|
-
output_format:
|
|
95
|
+
output_format: 'jpg', // ALWAYS JPG for Nano Banana Pro (lightweight)
|
|
109
96
|
...(hasReferences ? { image_input: references } : {}),
|
|
110
97
|
},
|
|
111
98
|
};
|
|
@@ -116,7 +103,7 @@ const buildGenerationRequest = ({ model, prompt, ratio, references, outputFormat
|
|
|
116
103
|
input: {
|
|
117
104
|
prompt,
|
|
118
105
|
image_size: ratio,
|
|
119
|
-
output_format:
|
|
106
|
+
output_format: 'jpeg', // ALWAYS JPEG for Nano Banana (lightweight)
|
|
120
107
|
...(hasReferences ? { image_urls: references } : {}),
|
|
121
108
|
},
|
|
122
109
|
};
|
|
@@ -264,22 +251,6 @@ class CommandosImage {
|
|
|
264
251
|
},
|
|
265
252
|
},
|
|
266
253
|
},
|
|
267
|
-
{
|
|
268
|
-
displayName: 'Output Format',
|
|
269
|
-
name: 'outputFormat',
|
|
270
|
-
type: 'options',
|
|
271
|
-
options: [
|
|
272
|
-
{ name: 'PNG', value: 'png' },
|
|
273
|
-
{ name: 'JPEG', value: 'jpeg' },
|
|
274
|
-
],
|
|
275
|
-
default: 'png',
|
|
276
|
-
displayOptions: {
|
|
277
|
-
show: {
|
|
278
|
-
operation: ['create'],
|
|
279
|
-
model: ['nano-banana', 'nano-banana-pro'],
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
254
|
{
|
|
284
255
|
displayName: 'Quality',
|
|
285
256
|
name: 'quality',
|
|
@@ -372,10 +343,6 @@ class CommandosImage {
|
|
|
372
343
|
const prompt = String(this.getNodeParameter('prompt', i) || '').trim();
|
|
373
344
|
const ratio = String(this.getNodeParameter('ratio', i));
|
|
374
345
|
const references = extractReferences(this.getNodeParameter('references', i, {}), model);
|
|
375
|
-
// Get optional parameters safely
|
|
376
|
-
const outputFormat = ['nano-banana', 'nano-banana-pro'].includes(model)
|
|
377
|
-
? String(this.getNodeParameter('outputFormat', i, 'png'))
|
|
378
|
-
: 'png';
|
|
379
346
|
const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model)
|
|
380
347
|
? String(this.getNodeParameter('quality', i, 'basic'))
|
|
381
348
|
: 'basic';
|
|
@@ -390,7 +357,6 @@ class CommandosImage {
|
|
|
390
357
|
prompt,
|
|
391
358
|
ratio,
|
|
392
359
|
references,
|
|
393
|
-
outputFormat,
|
|
394
360
|
quality,
|
|
395
361
|
resolution
|
|
396
362
|
});
|
|
@@ -405,11 +371,7 @@ class CommandosImage {
|
|
|
405
371
|
ratio: request.ratio,
|
|
406
372
|
references: request.references,
|
|
407
373
|
hasReferences: request.hasReferences,
|
|
408
|
-
|
|
409
|
-
model,
|
|
410
|
-
outputFormat,
|
|
411
|
-
version: '0.1.7',
|
|
412
|
-
}
|
|
374
|
+
_v: '0.1.8'
|
|
413
375
|
};
|
|
414
376
|
const response = await this.helpers.request({
|
|
415
377
|
method: 'POST',
|
|
@@ -17,7 +17,6 @@ type BuildParams = {
|
|
|
17
17
|
prompt: string;
|
|
18
18
|
ratio: string;
|
|
19
19
|
references: string[];
|
|
20
|
-
outputFormat?: string;
|
|
21
20
|
quality?: string;
|
|
22
21
|
resolution?: string;
|
|
23
22
|
};
|
|
@@ -53,26 +52,11 @@ const mapRatio = (model: string, ratio: string): string => {
|
|
|
53
52
|
return ratio;
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
/**
|
|
57
|
-
* Maps standard formats to specific model requirements (jpeg vs jpg)
|
|
58
|
-
*/
|
|
59
|
-
const mapFormat = (model: string, format: string): string => {
|
|
60
|
-
const f = String(format || 'png').toLowerCase().trim();
|
|
61
|
-
if (model === 'nano-banana-pro') {
|
|
62
|
-
return (f === 'jpeg' || f === 'jpg') ? 'jpg' : f;
|
|
63
|
-
}
|
|
64
|
-
if (model.includes('google/nano-banana')) {
|
|
65
|
-
return (f === 'jpeg' || f === 'jpg') ? 'jpeg' : f;
|
|
66
|
-
}
|
|
67
|
-
return f;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
55
|
const buildGenerationRequest = ({
|
|
71
56
|
model,
|
|
72
57
|
prompt,
|
|
73
58
|
ratio,
|
|
74
59
|
references,
|
|
75
|
-
outputFormat = 'png',
|
|
76
60
|
quality = 'basic',
|
|
77
61
|
resolution = '1K',
|
|
78
62
|
}: BuildParams): BuildResult => {
|
|
@@ -94,9 +78,9 @@ const buildGenerationRequest = ({
|
|
|
94
78
|
// Fallback for MJ or generic seedream
|
|
95
79
|
if (!hasReferences && (requestedModel === 'seedream' || requestedModel === 'midjourney')) {
|
|
96
80
|
if (requestedModel === 'seedream') {
|
|
97
|
-
|
|
81
|
+
// Handled above for 4.5
|
|
98
82
|
} else if (requestedModel === 'midjourney') {
|
|
99
|
-
|
|
83
|
+
resolvedModel = 'midjourney';
|
|
100
84
|
}
|
|
101
85
|
}
|
|
102
86
|
|
|
@@ -137,7 +121,7 @@ const buildGenerationRequest = ({
|
|
|
137
121
|
prompt,
|
|
138
122
|
aspect_ratio: ratio,
|
|
139
123
|
resolution,
|
|
140
|
-
output_format:
|
|
124
|
+
output_format: 'jpg', // ALWAYS JPG for Nano Banana Pro (lightweight)
|
|
141
125
|
...(hasReferences ? { image_input: references } : {}),
|
|
142
126
|
},
|
|
143
127
|
};
|
|
@@ -147,7 +131,7 @@ const buildGenerationRequest = ({
|
|
|
147
131
|
input: {
|
|
148
132
|
prompt,
|
|
149
133
|
image_size: ratio,
|
|
150
|
-
output_format:
|
|
134
|
+
output_format: 'jpeg', // ALWAYS JPEG for Nano Banana (lightweight)
|
|
151
135
|
...(hasReferences ? { image_urls: references } : {}),
|
|
152
136
|
},
|
|
153
137
|
};
|
|
@@ -189,7 +173,7 @@ const extractReferences = (raw: unknown, model: string): string[] => {
|
|
|
189
173
|
}
|
|
190
174
|
const collection = raw as { reference?: Array<{ url?: string }> };
|
|
191
175
|
const items = Array.isArray(collection.reference) ? collection.reference : [];
|
|
192
|
-
|
|
176
|
+
|
|
193
177
|
// Dynamic limit based on model docs
|
|
194
178
|
let limit = 8;
|
|
195
179
|
if (model === 'seedream') limit = 14;
|
|
@@ -294,22 +278,6 @@ export class CommandosImage implements INodeType {
|
|
|
294
278
|
},
|
|
295
279
|
},
|
|
296
280
|
},
|
|
297
|
-
{
|
|
298
|
-
displayName: 'Output Format',
|
|
299
|
-
name: 'outputFormat',
|
|
300
|
-
type: 'options',
|
|
301
|
-
options: [
|
|
302
|
-
{ name: 'PNG', value: 'png' },
|
|
303
|
-
{ name: 'JPEG', value: 'jpeg' },
|
|
304
|
-
],
|
|
305
|
-
default: 'png',
|
|
306
|
-
displayOptions: {
|
|
307
|
-
show: {
|
|
308
|
-
operation: ['create'],
|
|
309
|
-
model: ['nano-banana', 'nano-banana-pro'],
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
281
|
{
|
|
314
282
|
displayName: 'Quality',
|
|
315
283
|
name: 'quality',
|
|
@@ -406,11 +374,6 @@ export class CommandosImage implements INodeType {
|
|
|
406
374
|
const ratio = String(this.getNodeParameter('ratio', i));
|
|
407
375
|
const references = extractReferences(this.getNodeParameter('references', i, {}), model);
|
|
408
376
|
|
|
409
|
-
// Get optional parameters safely
|
|
410
|
-
const outputFormat = ['nano-banana', 'nano-banana-pro'].includes(model)
|
|
411
|
-
? String(this.getNodeParameter('outputFormat', i, 'png'))
|
|
412
|
-
: 'png';
|
|
413
|
-
|
|
414
377
|
const quality = ['seedream', 'gpt4o-image', 'flux-pro'].includes(model)
|
|
415
378
|
? String(this.getNodeParameter('quality', i, 'basic'))
|
|
416
379
|
: 'basic';
|
|
@@ -423,16 +386,15 @@ export class CommandosImage implements INodeType {
|
|
|
423
386
|
throw new NodeOperationError(this.getNode(), 'Prompt is required', { itemIndex: i });
|
|
424
387
|
}
|
|
425
388
|
|
|
426
|
-
const request = buildGenerationRequest({
|
|
427
|
-
model,
|
|
428
|
-
prompt,
|
|
429
|
-
ratio,
|
|
389
|
+
const request = buildGenerationRequest({
|
|
390
|
+
model,
|
|
391
|
+
prompt,
|
|
392
|
+
ratio,
|
|
430
393
|
references,
|
|
431
|
-
outputFormat,
|
|
432
394
|
quality,
|
|
433
395
|
resolution
|
|
434
396
|
});
|
|
435
|
-
|
|
397
|
+
|
|
436
398
|
if (!request.url) {
|
|
437
399
|
throw new NodeOperationError(
|
|
438
400
|
this.getNode(),
|
|
@@ -449,11 +411,7 @@ export class CommandosImage implements INodeType {
|
|
|
449
411
|
ratio: request.ratio,
|
|
450
412
|
references: request.references,
|
|
451
413
|
hasReferences: request.hasReferences,
|
|
452
|
-
|
|
453
|
-
model,
|
|
454
|
-
outputFormat,
|
|
455
|
-
version: '0.1.7',
|
|
456
|
-
}
|
|
414
|
+
_v: '0.1.8'
|
|
457
415
|
};
|
|
458
416
|
|
|
459
417
|
const response = await this.helpers.request({
|