Minor improvements
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
import { app } from "/scripts/app.js";
|
||||
|
||||
// Model-specific resolution presets with constraints
|
||||
// Includes: model-optimized sizes + photo print (4x6, 5x7, 8x10) + digital/social + canvas art ratios
|
||||
const MODEL_RESOLUTIONS = {
|
||||
"Flux": {
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[768, 1344], [832, 1216], [896, 1152], [928, 1664], [1024, 1536], [1024, 1792], [1080, 1920], [1152, 2048]],
|
||||
"landscape": [[1344, 768], [1216, 832], [1152, 896], [1536, 1024], [1664, 928], [1792, 1024], [1920, 1080], [2048, 1152]],
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1088, 1088], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[688, 2048], [768, 1344], [832, 1216], [896, 1152], [928, 1664], [1024, 1536], [1024, 1792], [1024, 2048], [1088, 1920], [1152, 2048], [1200, 1792], [1360, 2048], [1456, 2048], [1536, 2048], [1616, 2048], [1632, 2048], [1712, 2048]],
|
||||
"landscape": [[1280, 720], [1344, 768], [1216, 832], [1152, 896], [1536, 1024], [1664, 928], [1792, 1024], [1792, 1200], [1920, 1088], [2048, 688], [2048, 1024], [2048, 1152], [2048, 1360], [2048, 1456], [2048, 1536], [2048, 1616], [2048, 1632], [2048, 1712]],
|
||||
},
|
||||
"Qwen Image": {
|
||||
"square": [[1024, 1024], [1280, 1280], [1328, 1328], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[928, 1664], [1024, 1536], [1080, 1920], [1140, 1472], [1152, 2048]],
|
||||
"landscape": [[1472, 1140], [1536, 1024], [1664, 928], [1920, 1080], [2048, 1152]],
|
||||
"square": [[1024, 1024], [1080, 1080], [1280, 1280], [1328, 1328], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[680, 2048], [928, 1664], [1024, 1536], [1024, 2048], [1080, 1920], [1140, 1472], [1152, 2048], [1200, 1800], [1368, 2048], [1464, 2048], [1536, 2048], [1608, 2048], [1640, 2048], [1704, 2048]],
|
||||
"landscape": [[1280, 720], [1472, 1140], [1536, 1024], [1664, 928], [1800, 1200], [1920, 1080], [2048, 680], [2048, 1024], [2048, 1152], [2048, 1368], [2048, 1464], [2048, 1536], [2048, 1608], [2048, 1640], [2048, 1704]],
|
||||
},
|
||||
"Z-Image": {
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[720, 1280], [768, 1024], [1080, 1920], [1152, 2048]],
|
||||
"landscape": [[1024, 768], [1280, 720], [1920, 1080], [2048, 1152]],
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1080, 1080], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[680, 2048], [720, 1280], [768, 1024], [1024, 2048], [1080, 1920], [1152, 2048], [1200, 1800], [1368, 2048], [1464, 2048], [1536, 2048], [1608, 2048], [1640, 2048], [1704, 2048]],
|
||||
"landscape": [[1024, 768], [1280, 720], [1800, 1200], [1920, 1080], [2048, 680], [2048, 1024], [2048, 1152], [2048, 1368], [2048, 1464], [2048, 1536], [2048, 1608], [2048, 1640], [2048, 1704]],
|
||||
},
|
||||
"SD 1.5": {
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1280, 1280], [1536, 1536]],
|
||||
"portrait": [[512, 768], [512, 682], [512, 1024], [768, 1024], [768, 1344], [1080, 1920]],
|
||||
"landscape": [[768, 512], [1024, 512], [1024, 768], [1344, 768], [1536, 512], [1920, 1080]],
|
||||
"square": [[512, 512], [768, 768], [1024, 1024], [1080, 1080], [1280, 1280], [1536, 1536]],
|
||||
"portrait": [[512, 768], [512, 682], [512, 1024], [680, 2048], [768, 1024], [768, 1344], [1024, 2048], [1080, 1920], [1200, 1800], [1368, 2048], [1464, 2048], [1536, 2048], [1608, 2048], [1640, 2048], [1704, 2048]],
|
||||
"landscape": [[768, 512], [1024, 512], [1024, 768], [1280, 720], [1344, 768], [1536, 512], [1800, 1200], [1920, 1080], [2048, 680], [2048, 1024], [2048, 1368], [2048, 1464], [2048, 1536], [2048, 1608], [2048, 1640], [2048, 1704]],
|
||||
},
|
||||
"SDXL": {
|
||||
"square": [[1024, 1024], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[640, 1536], [768, 1344], [832, 1216], [896, 1152], [1024, 1536], [1080, 1920], [1152, 2048]],
|
||||
"landscape": [[1152, 896], [1216, 832], [1344, 768], [1536, 640], [1536, 1024], [1920, 1080], [2048, 1152]],
|
||||
"square": [[1024, 1024], [1080, 1080], [1280, 1280], [1536, 1536], [1920, 1920], [2048, 2048]],
|
||||
"portrait": [[640, 1536], [680, 2048], [768, 1344], [832, 1216], [896, 1152], [1024, 1536], [1024, 2048], [1080, 1920], [1152, 2048], [1200, 1800], [1368, 2048], [1464, 2048], [1536, 2048], [1608, 2048], [1640, 2048], [1704, 2048]],
|
||||
"landscape": [[1152, 896], [1216, 832], [1280, 720], [1344, 768], [1536, 640], [1536, 1024], [1800, 1200], [1920, 1080], [2048, 680], [2048, 1024], [2048, 1152], [2048, 1368], [2048, 1464], [2048, 1536], [2048, 1608], [2048, 1640], [2048, 1704]],
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,21 +62,22 @@ function calculateAspectRatio(width, height) {
|
||||
[0.56, "9:16"], // 0.5625
|
||||
[0.5, "1:2"], // 0.5
|
||||
[0.42, "5:12"], // 0.4166...
|
||||
[0.33, "1:3"], // 0.333... (panoramic)
|
||||
];
|
||||
|
||||
// Find closest common ratio (within 5% tolerance)
|
||||
const tolerance = 0.05;
|
||||
for (const [ratioValue, ratioStr] of commonRatios) {
|
||||
if (Math.abs(actualRatio - ratioValue) / ratioValue < tolerance) {
|
||||
return ratioStr;
|
||||
// Find closest common ratio by absolute difference
|
||||
let closestRatio = commonRatios[0];
|
||||
let minDiff = Math.abs(actualRatio - closestRatio[0]);
|
||||
|
||||
for (const ratio of commonRatios) {
|
||||
const diff = Math.abs(actualRatio - ratio[0]);
|
||||
if (diff < minDiff) {
|
||||
minDiff = diff;
|
||||
closestRatio = ratio;
|
||||
}
|
||||
}
|
||||
|
||||
// If no close match, calculate GCD-based ratio
|
||||
const divisor = gcd(width, height);
|
||||
const ratioWidth = width / divisor;
|
||||
const ratioHeight = height / divisor;
|
||||
return `${ratioWidth}:${ratioHeight}`;
|
||||
return closestRatio[1];
|
||||
}
|
||||
|
||||
function formatResolution(width, height) {
|
||||
|
||||
Reference in New Issue
Block a user