@innovastudio/contentbuilder 1.4.99 → 1.4.100

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.99",
4
+ "version": "1.4.100",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -82013,31 +82013,56 @@ class ContentBuilder {
82013
82013
  }
82014
82014
  }
82015
82015
  }
82016
+ async upscaleImage(src, callback) {
82017
+ const width = 512;
82018
+ const height = 512;
82019
+ const img = new Image();
82020
+ img.src = src;
82021
+ img.onload = async () => {
82022
+ const canvas = document.createElement('canvas');
82023
+ canvas.width = width;
82024
+ canvas.height = height;
82025
+ const ctx = canvas.getContext('2d');
82026
+ ctx.drawImage(img, 0, 0, width, height);
82027
+ const resizedBase64 = canvas.toDataURL('image/jpeg');
82028
+ let image = resizedBase64;
82029
+ image = image.replace(/^data:image\/(png|jpeg);base64,/, '');
82030
+ const messages = {
82031
+ image: image,
82032
+ folder_path: ''
82033
+ };
82034
+ const response = await fetch(this.upscaleImageUrl, {
82035
+ signal: this.signal,
82036
+ // Abort
82037
+ method: 'POST',
82038
+ headers: {
82039
+ 'Content-Type': 'application/json'
82040
+ },
82041
+ body: JSON.stringify(messages)
82042
+ });
82043
+ const result = await response.json();
82044
+ callback([result.url]);
82045
+ };
82046
+ }
82016
82047
  async generateImage(prompt, callback) {
82017
82048
  this.controller = new AbortController(); // Create a new AbortController
82018
82049
  this.signal = this.controller.signal; // Get a new signal object
82019
82050
 
82020
- let model = 'realistic-vision-v3';
82021
- let negative_prompt = '';
82022
- if (model.includes('realistic-vision')) {
82023
- if (negative_prompt === '') negative_prompt = 'duplicate, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, bad_prompt_version2, bad-hands-5, badhandv4, bad anatomy, deformed, mutated, amputated, missing finger, extra finger, fused fingers, missing leg, extra leg, fused legs, missing digit, extra digit, fused digits, missing hand, extra hand, fused hands, missing arm, extra arm, fused arms, missing limb, extra limb, fused limbs, fused bodies, merged bodies, extra bodies, dual bodies, extra navel, elongated body, missing joint, extra joint, fused joints, deformed hip, twisted limbs, twisted legs, twisted arms, missing head, extra head, double head, twins, missing ear, extra ear, deformed ear, black and white, monochrome, multiple views, blurry, text, signature, head out of frame, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, grayscale, glans, bad hands, error, extra digit, fewer digits, cropped, jpeg artifacts, watermark, username, bad feet, poorly drawn hands, poorly drawn face, mutation, too many fingers, long neck, long body, long arms, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross proportions, cropped head , bad eyes, extra breast, missing breast, fused breasts, unnatural proportions, necklace';
82024
- }
82025
- let width = 1024;
82026
- let height = 1024;
82027
- let steps = 25;
82028
- let guidance = 7.5;
82029
- let scheduler = 'dpmsolver++';
82030
- let output_format = 'jpeg';
82051
+ let model = this.imageModel || 'realistic-vision-v3';
82052
+ let negative_prompt = this.imageNegativePrompt || 'duplicate, (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, bad_prompt_version2, bad-hands-5, badhandv4, bad anatomy, deformed, mutated, amputated, missing finger, extra finger, fused fingers, missing leg, extra leg, fused legs, missing digit, extra digit, fused digits, missing hand, extra hand, fused hands, missing arm, extra arm, fused arms, missing limb, extra limb, fused limbs, fused bodies, merged bodies, extra bodies, dual bodies, extra navel, elongated body, missing joint, extra joint, fused joints, deformed hip, twisted limbs, twisted legs, twisted arms, missing head, extra head, double head, twins, missing ear, extra ear, deformed ear, black and white, monochrome, multiple views, blurry, text, signature, head out of frame, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, grayscale, glans, bad hands, error, extra digit, fewer digits, cropped, jpeg artifacts, watermark, username, bad feet, poorly drawn hands, poorly drawn face, mutation, too many fingers, long neck, long body, long arms, cross-eyed, mutated hands, polar lowres, bad body, bad proportions, gross proportions, cropped head , bad eyes, extra breast, missing breast, fused breasts, unnatural proportions, necklace';
82053
+ let steps = this.imageSteps || 25;
82054
+ let guidance = this.imageGuidance || 7.5;
82055
+ let scheduler = this.imageScheduler || 'dpmsolver++';
82031
82056
  const messages = {
82032
- model: 'realistic-vision-v3',
82057
+ model,
82033
82058
  prompt: prompt,
82034
- negative_prompt: negative_prompt,
82035
- width: width,
82036
- height: height,
82037
- steps: steps,
82038
- guidance: guidance,
82039
- scheduler: scheduler,
82040
- output_format: output_format,
82059
+ negative_prompt,
82060
+ width: 512,
82061
+ height: 512,
82062
+ steps,
82063
+ guidance,
82064
+ scheduler,
82065
+ output_format: 'jpeg',
82041
82066
  folder_path: ''
82042
82067
  };
82043
82068
  try {
@@ -82057,7 +82082,9 @@ class ContentBuilder {
82057
82082
  return;
82058
82083
  }
82059
82084
  const imageUrl = result.url;
82060
- callback([imageUrl]);
82085
+
82086
+ //callback([imageUrl]);
82087
+ this.upscaleImage(imageUrl, callback);
82061
82088
  } catch (error) {
82062
82089
  if (error.name === 'AbortError') ; else {
82063
82090
  // CORS or code errors goes here