n8n-nodes-supermachine 0.10.2 → 1.0.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.
@@ -323,6 +323,50 @@ class Supermachine {
323
323
  }];
324
324
  }
325
325
  },
326
+ async getSizePresets() {
327
+ const imageRatio = this.getCurrentNodeParameter('imageRatio');
328
+ if (!imageRatio || imageRatio === 'Custom') {
329
+ return [];
330
+ }
331
+ const sizeConfig = {
332
+ '1:1': ['1024x1024', '1280x1280'],
333
+ '3:4': ['768x1024', '884x1184'],
334
+ '9:16': ['576x1024', '720x1280'],
335
+ '4:3': ['1024x768', '1184x884'],
336
+ '16:9': ['1024x576', '1280x720'],
337
+ };
338
+ const sizes = sizeConfig[imageRatio] || [];
339
+ return sizes.map((size) => {
340
+ const [w, h] = size.split('x');
341
+ return {
342
+ name: size,
343
+ value: size,
344
+ description: imageRatio + ' ratio (' + w + '×' + h + ')',
345
+ };
346
+ });
347
+ },
348
+ async getSizePresetsV3() {
349
+ const imageRatioV3 = this.getCurrentNodeParameter('imageRatioV3');
350
+ if (!imageRatioV3 || imageRatioV3 === 'Custom') {
351
+ return [];
352
+ }
353
+ const sizeConfig = {
354
+ '1:1': ['1024x1024', '1280x1280'],
355
+ '3:4': ['768x1024', '884x1184'],
356
+ '9:16': ['576x1024', '720x1280'],
357
+ '4:3': ['1024x768', '1184x884'],
358
+ '16:9': ['1024x576', '1280x720'],
359
+ };
360
+ const sizes = sizeConfig[imageRatioV3] || [];
361
+ return sizes.map((size) => {
362
+ const [w, h] = size.split('x');
363
+ return {
364
+ name: size,
365
+ value: size,
366
+ description: imageRatioV3 + ' ratio (' + w + '×' + h + ')',
367
+ };
368
+ });
369
+ },
326
370
  },
327
371
  };
328
372
  async execute() {
@@ -550,11 +594,30 @@ class Supermachine {
550
594
  folderIdNumber = folderIdValue;
551
595
  }
552
596
  }
597
+ // AUTO-FILL WIDTH/HEIGHT FROM IMAGE RATIO PRESET
598
+ const imageRatioV3 = this.getNodeParameter('imageRatioV3', i, '9:16');
599
+ const sizePresetV3 = this.getNodeParameter('sizePresetV3', i, '');
600
+ let width = 576;
601
+ let height = 1024;
602
+ if (imageRatioV3 !== 'Custom' && sizePresetV3) {
603
+ // Parse preset like "576x1024"
604
+ const [w, h] = sizePresetV3.split('x').map(Number);
605
+ if (w && h) {
606
+ width = w;
607
+ height = h;
608
+ }
609
+ }
610
+ else if (imageRatioV3 === 'Custom') {
611
+ // Use custom width/height
612
+ width = this.getNodeParameter('widthV3', i, 576);
613
+ height = this.getNodeParameter('heightV3', i, 1024);
614
+ }
615
+ // END AUTO-FILL
553
616
  const body = {
554
617
  prompt: this.getNodeParameter('promptV3', i),
555
618
  modelName: this.getNodeParameter('modelNameV3', i),
556
- width: this.getNodeParameter('widthV3', i, 576),
557
- height: this.getNodeParameter('heightV3', i, 1024),
619
+ width: width,
620
+ height: height,
558
621
  steps: additionalFieldsV3.steps || 20,
559
622
  imageNumber: additionalFieldsV3.imageNumber || 1,
560
623
  generationMode: 'GENERATE',
@@ -687,11 +750,30 @@ class Supermachine {
687
750
  prompt = `${prompt} a photo of ${characterEmbedCode}`.trim();
688
751
  }
689
752
  }
753
+ // AUTO-FILL WIDTH/HEIGHT FROM IMAGE RATIO PRESET
754
+ const imageRatio = this.getNodeParameter('imageRatio', i, '1:1');
755
+ const sizePreset = this.getNodeParameter('sizePreset', i, '');
756
+ let width = 1024;
757
+ let height = 768;
758
+ if (imageRatio !== 'Custom' && sizePreset) {
759
+ // Parse preset like "1024x768"
760
+ const [w, h] = sizePreset.split('x').map(Number);
761
+ if (w && h) {
762
+ width = w;
763
+ height = h;
764
+ }
765
+ }
766
+ else if (imageRatio === 'Custom') {
767
+ // Use custom width/height
768
+ width = this.getNodeParameter('width', i, 1024);
769
+ height = this.getNodeParameter('height', i, 768);
770
+ }
771
+ // END AUTO-FILL
690
772
  const body = {
691
773
  prompt: prompt,
692
774
  model: this.getNodeParameter('model', i),
693
- width: this.getNodeParameter('width', i, 1024),
694
- height: this.getNodeParameter('height', i, 768),
775
+ width: width,
776
+ height: height,
695
777
  };
696
778
  if (additionalFields.negativePrompt) {
697
779
  body.negativePrompt = additionalFields.negativePrompt;
@@ -74,6 +74,46 @@ exports.getImageFields = [
74
74
  description: 'Model AI dùng để generate ảnh. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
75
75
  required: true,
76
76
  },
77
+ // Image Ratio for Generate v1
78
+ {
79
+ displayName: 'Image Ratio',
80
+ name: 'imageRatio',
81
+ type: 'options',
82
+ displayOptions: {
83
+ show: {
84
+ resource: ['image'],
85
+ operation: ['generate'],
86
+ },
87
+ },
88
+ options: [
89
+ { name: '1:1 (Square)', value: '1:1' },
90
+ { name: '3:4 (Portrait)', value: '3:4' },
91
+ { name: '9:16 (Vertical)', value: '9:16' },
92
+ { name: '4:3 (Landscape)', value: '4:3' },
93
+ { name: '16:9 (Widescreen)', value: '16:9' },
94
+ { name: 'Custom', value: 'Custom' },
95
+ ],
96
+ default: '1:1',
97
+ description: 'Aspect ratio preset. Select Custom to manually set width/height.',
98
+ },
99
+ {
100
+ displayName: 'Size Preset',
101
+ name: 'sizePreset',
102
+ type: 'options',
103
+ displayOptions: {
104
+ show: {
105
+ resource: ['image'],
106
+ operation: ['generate'],
107
+ imageRatio: ['1:1', '3:4', '9:16', '4:3', '16:9'],
108
+ },
109
+ },
110
+ typeOptions: {
111
+ loadOptionsMethod: 'getSizePresets',
112
+ loadOptionsDependsOn: ['imageRatio'],
113
+ },
114
+ default: '',
115
+ description: 'Pre-defined sizes for selected ratio. Width and height will auto-fill.',
116
+ },
77
117
  {
78
118
  displayName: 'Prompt',
79
119
  name: 'prompt',
@@ -104,6 +144,7 @@ exports.getImageFields = [
104
144
  show: {
105
145
  resource: ['image'],
106
146
  operation: ['generate'],
147
+ imageRatio: ['Custom'],
107
148
  },
108
149
  },
109
150
  default: 1024,
@@ -121,6 +162,7 @@ exports.getImageFields = [
121
162
  show: {
122
163
  resource: ['image'],
123
164
  operation: ['generate'],
165
+ imageRatio: ['Custom'],
124
166
  },
125
167
  },
126
168
  default: 768,
@@ -429,6 +471,45 @@ exports.getImageFields = [
429
471
  required: true,
430
472
  description: 'AI model to use for image generation',
431
473
  },
474
+ // Image Ratio for Generate v3
475
+ {
476
+ displayName: 'Image Ratio',
477
+ name: 'imageRatioV3',
478
+ type: 'options',
479
+ displayOptions: {
480
+ show: {
481
+ resource: ['image'],
482
+ operation: ['generateV3'],
483
+ },
484
+ },
485
+ options: [
486
+ { name: '1:1 (Square)', value: '1:1' },
487
+ { name: '3:4 (Portrait)', value: '3:4' },
488
+ { name: '9:16 (Vertical)', value: '9:16' },
489
+ { name: '4:3 (Landscape)', value: '4:3' },
490
+ { name: '16:9 (Widescreen)', value: '16:9' },
491
+ { name: 'Custom', value: 'Custom' },
492
+ ],
493
+ default: '9:16',
494
+ description: 'Aspect ratio preset. Select Custom to manually set width/height.',
495
+ },
496
+ {
497
+ displayName: 'Size Preset',
498
+ name: 'sizePresetV3',
499
+ type: 'options',
500
+ displayOptions: {
501
+ show: {
502
+ resource: ['image'],
503
+ operation: ['generateV3'],
504
+ imageRatioV3: ['1:1', '3:4', '9:16', '4:3', '16:9'],
505
+ },
506
+ },
507
+ typeOptions: {
508
+ loadOptionsMethod: 'getSizePresetsV3',
509
+ },
510
+ default: '',
511
+ description: 'Pre-defined sizes for selected ratio. Width and height will auto-fill.',
512
+ },
432
513
  {
433
514
  displayName: 'Prompt',
434
515
  name: 'promptV3',
@@ -459,6 +540,7 @@ exports.getImageFields = [
459
540
  show: {
460
541
  resource: ['image'],
461
542
  operation: ['generateV3'],
543
+ imageRatioV3: ['Custom'],
462
544
  },
463
545
  },
464
546
  default: 576,
@@ -476,6 +558,7 @@ exports.getImageFields = [
476
558
  show: {
477
559
  resource: ['image'],
478
560
  operation: ['generateV3'],
561
+ imageRatioV3: ['Custom'],
479
562
  },
480
563
  },
481
564
  default: 1024,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-supermachine",
3
- "version": "0.10.2",
3
+ "version": "1.0.1",
4
4
  "description": "n8n community node for Supermachine AI Image API — Generate images, manage models, LoRAs, and characters",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",