fix: preserve canvas image generation aspect ratio
This commit is contained in:
parent
e5bcf6f403
commit
5b2418701f
@ -3660,18 +3660,7 @@ export function CanvasChatPanel({
|
||||
sourceImageUrls,
|
||||
});
|
||||
const placeholderNode = placeholderNodes[index];
|
||||
const size = anchorNode
|
||||
? {
|
||||
width: Math.max(
|
||||
1,
|
||||
Math.round(Number(anchorNode.size?.width || dimensions.width))
|
||||
),
|
||||
height: Math.max(
|
||||
1,
|
||||
Math.round(Number(anchorNode.size?.height || dimensions.height))
|
||||
),
|
||||
}
|
||||
: { width: dimensions.width, height: dimensions.height };
|
||||
const size = { width: dimensions.width, height: dimensions.height };
|
||||
const position = getAnchoredGenerationPosition({
|
||||
anchorNode,
|
||||
existingNodes: currentNodes,
|
||||
@ -8388,10 +8377,12 @@ export function CanvasChatPanel({
|
||||
: selectedImageNodesRef.current,
|
||||
});
|
||||
const imageParamSnapshot = imageParamsRef.current || imageParams;
|
||||
const aspectRatio =
|
||||
imageParamSnapshot.aspectRatio && imageParamSnapshot.aspectRatio !== "auto"
|
||||
? imageParamSnapshot.aspectRatio
|
||||
: "1:1";
|
||||
const hasExplicitAspectRatio =
|
||||
Boolean(imageParamSnapshot.aspectRatio) &&
|
||||
imageParamSnapshot.aspectRatio !== "auto";
|
||||
const aspectRatio = hasExplicitAspectRatio
|
||||
? String(imageParamSnapshot.aspectRatio)
|
||||
: "1:1";
|
||||
const [ratioWidthRaw, ratioHeightRaw] = aspectRatio.split(":").map((item) => Number(item));
|
||||
const ratioWidth = Number.isFinite(ratioWidthRaw) && ratioWidthRaw > 0 ? ratioWidthRaw : 1;
|
||||
const ratioHeight = Number.isFinite(ratioHeightRaw) && ratioHeightRaw > 0 ? ratioHeightRaw : 1;
|
||||
@ -8406,18 +8397,19 @@ export function CanvasChatPanel({
|
||||
width: Math.max(190, Math.round((baseSide * ratioWidth) / ratioHeight)),
|
||||
height: baseSide,
|
||||
};
|
||||
const placeholderSize = anchorNode
|
||||
? {
|
||||
width: Math.max(
|
||||
180,
|
||||
Math.round(Number(anchorNode.size?.width || ratioPlaceholderSize.width))
|
||||
),
|
||||
height: Math.max(
|
||||
180,
|
||||
Math.round(Number(anchorNode.size?.height || ratioPlaceholderSize.height))
|
||||
),
|
||||
}
|
||||
: ratioPlaceholderSize;
|
||||
const placeholderSize =
|
||||
anchorNode && !hasExplicitAspectRatio
|
||||
? {
|
||||
width: Math.max(
|
||||
180,
|
||||
Math.round(Number(anchorNode.size?.width || ratioPlaceholderSize.width))
|
||||
),
|
||||
height: Math.max(
|
||||
180,
|
||||
Math.round(Number(anchorNode.size?.height || ratioPlaceholderSize.height))
|
||||
),
|
||||
}
|
||||
: ratioPlaceholderSize;
|
||||
const position = getAnchoredGenerationPosition({
|
||||
anchorNode,
|
||||
existingNodes: currentNodes,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user