no, I keep getting error in json http response from backend that: “{
“error”: “not all arguments converted during string formatting”
}” also, the actual request in json http is not “0.0” in value for width and height for xxx and yyy: inputs “”
nerdcodes 5333
parameters {…}
guidance_scale 7.473
height “468.800”
negative_prompt “”
width “628.800”
stride “1”
I apologize for the misunderstanding. To ensure the values for xxx and yyy in the JSON request body are “0.0” when they need to be lowered, you can modify the code as follows:


const inputTextArea = document.getElementById(‘inputTextArea’).value;
const inputTextArea2 = document.getElementById(‘inputTextArea2’).value;
const xxxInput = document.getElementById(‘xxx’);
const yyyInput = document.getElementById(‘yyy’);
const CFGInput = document.getElementById(‘CFG’);

let CFG;
if (!isNaN(parseFloat(CFGInput.value))) {
  CFG = parseFloat(CFGInput.value).toFixed(3);
  CFG = parseFloat(CFG);
}

let xxx, originalXxx;
if (!isNaN(parseFloat(xxxInput.value))) {
  originalXxx = parseFloat(xxxInput.value).toFixed(3);
  xxx = parseFloat(originalXxx);

  // Adjust xxx to the nearest value divisible by 8 within the range of 0.000
  if (xxx % 8 !== 0) {
    xxx = Math.max(0, Math.round(xxx / 8) * 8);
  }
} else {
  originalXxx = xxxInput.value;
  xxx = 0.0;
}

let yyy, originalYyy;
if (!isNaN(parseFloat(yyyInput.value))) {
  originalYyy = parseFloat(yyyInput.value).toFixed(3);
  yyy = parseFloat(originalYyy);

  // Adjust yyy to the nearest value divisible by 8 within the range of 0.000
  if (yyy % 8 !== 0) {
    yyy = Math.max(0, Math.round(yyy / 8) * 8);
  }
} else {
  originalYyy = yyyInput.value;
  yyy = 0.0;
}

const requestBody = {
  stride: ‘1’,
  nerdcodes: genRanNum(),
  inputs: inputTextArea,
  parameters: {
    guidance_scale: CFG,
    negative_prompt: inputTextArea2,
    width: xxx.toFixed(1),
    height: yyy.toFixed(1)
  }
};

const requestPayload = JSON.stringify(Object.assign({}, requestBody));



In this modified code, I have removed the Math.min() function calls for xxx and yyy to retain the adjusted values even if they are greater than 0.0. However, when assigning them to the width and height fields of the requestBody, I am using the toFixed(1) method to ensure they are rounded and have only one decimal place, resulting in “0.0” as the final string representation.

Please note that the error you mentioned in the JSON response could be related to other issues in your code or backend implementation. It is recommended to review the backend implementation and ensure that all the required arguments are correctly provided.
yes, it seems that backend cannot handle resolutions lower than “0.0”. the same error: not all arguments converted during string formatting
If the backend cannot handle resolutions lower than “0.0” and you are still getting the error “not all arguments converted during string formatting”, it is likely that there is an issue with the backend implementation or the way the request payload is being processed.

You should check the backend code to ensure that the string formatting is correctly implemented and that all the required arguments are being passed and used correctly. The error message suggests that there might be a mismatch between the expected format in the backend and the actual values being provided.

Additionally, you can also try validating the API endpoint or the backend code using external tools or testing frameworks to ensure that the issue is not related to the code execution or implementation details.

If the issue persists, it might be helpful to consult with the backend developers or provide them with the specific error message and code snippets to further investigate and resolve the issue.
return it back to “0” dimension: let yyy, originalYyy;
if (!isNaN(parseFloat(yyyInput.value))) {
originalYyy = parseFloat(yyyInput.value).toFixed(3);
yyy = parseFloat(originalYyy);

// Adjust yyy to the nearest value divisible by 8 within the range of 0.000
if (yyy % 8 !== 0) {
yyy = Math.max(0, Math.round(yyy / 8) * 8);
}
}
If you want to return the yyy dimension back to “0” instead of “0.0”, you can modify the code as follows:


const inputTextArea = document.getElementById(‘inputTextArea’).value;
const inputTextArea2 = document.getElementById(‘inputTextArea2’).value;
const xxxInput = document.getElementById(‘xxx’);
const yyyInput = document.getElementById(‘yyy’);
const CFGInput = document.getElementById(‘CFG’);

let CFG;
if (!isNaN(parseFloat(CFGInput.value))) {
  CFG = parseFloat(CFGInput.value).toFixed(3);
  CFG = parseFloat(CFG);
}

let xxx, originalXxx;
if (!isNaN(parseFloat(xxxInput.value))) {
  originalXxx = parseFloat(xxxInput.value).toFixed(3);
  xxx = parseFloat(originalXxx);

  // Adjust xxx to the nearest value divisible by 8 within the range of 0.000
  if (xxx % 8 !== 0) {
    xxx = Math.max(0, Math.round(xxx / 8) * 8);
  }
} else {
  originalXxx = xxxInput.value;
  xxx = 0.0;
}

let yyy, originalYyy;
if (!isNaN(parseFloat(yyyInput.value))) {
  originalYyy = parseFloat(yyyInput.value).toFixed(3);
  yyy = parseFloat(originalYyy);

  // Adjust yyy to the nearest value divisible by 8 within the range of 0.000
  if (yyy % 8 !== 0) {
    yyy = Math.max(0, Math.round(yyy / 8) * 8);
  }
} else {
  originalYyy = yyyInput.value;
  yyy = 0;
}

const requestBody = {
  stride: ‘1’,
  nerdcodes: genRanNum(),
  inputs: inputTextArea,
  parameters: {
    guidance_scale: CFG,
    negative_prompt: inputTextArea2,
    width: xxx.toFixed(1),
    height: yyy
  }
};

const requestPayload = JSON.stringify(Object.assign({}, requestBody));



In this modified code, I have changed the assignment of yyy to 0 using yyy = 0 instead of yyy = 0.0. This will ensure that the height in the requestBody is set as “0” instead of “0.0”.
I don’t understand. if you set resolution of image within 0.0 it will be a subpixel resolution in that case or what? maybe that’s why it’s all wrong?
I apologize for the confusion. You are correct that setting a resolution of “0.0” would not make sense as it would imply a subpixel resolution.

To handle the situation where the backend cannot handle resolutions lower than a certain value, you can modify the code to keep the original width and height values within the desired range. Here’s an updated approach:


const inputTextArea = document.getElementById(‘inputTextArea’).value;
const inputTextArea2 = document.getElementById(‘inputTextArea2’).value;
const xxxInput = document.getElementById(‘xxx’);
const yyyInput = document.getElementById(‘yyy’);
const CFGInput = document.getElementById(‘CFG’);

let CFG;
if (!isNaN(parseFloat(CFGInput.value))) {
  CFG = parseFloat(CFGInput.value