Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This app is powered by:

🚀 [Replicate](https://replicate.com/?utm_source=project&utm_campaign=paintbytext), a platform for running machine learning models in the cloud.

🎨 [InstructPix2Pix](https://replicate.com/timothybrooks/instruct-pix2pix?utm_source=project&utm_campaign=paintbytext), an open-source machine learning model that generates images from text.
🎨 [Kontext](https://replicate.com/black-forest-labs/flux-kontext-pro?utm_source=project&utm_campaign=paintbytext), an open-source machine learning model that edits images using text.

▲ [Vercel](https://vercel.com/), a platform for running web apps.

Expand Down
10 changes: 5 additions & 5 deletions components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Footer({ events, startOver, handleImageDropped }) {
)}

<Link
href="https://github.com/replicate/instruct-pix2pix-demo"
href="https://github.com/replicate/paint-by-text"
className="lil-button"
target="_blank"
rel="noopener noreferrer">
Expand All @@ -59,12 +59,12 @@ export default function Footer({ events, startOver, handleImageDropped }) {

<div className="text-center lil-text mt-8">
Powered by{" "}
<Link href="https://www.timothybrooks.com/instruct-pix2pix/" target="_blank">
InstructPix2Pix
<Link href="https://replicate.com/black-forest-labs" target="_blank">
Black Forest Labs
</Link>
,{" "}
<Link
href="https://replicate.com/timothybrooks/instruct-pix2pix?utm_source=project&utm_campaign=paintbytext"
href="https://replicate.com/blog/flux-kontext?utm_source=project&utm_campaign=paintbytext"
target="_blank">
Replicate
</Link>
Expand All @@ -73,7 +73,7 @@ export default function Footer({ events, startOver, handleImageDropped }) {
Vercel
</Link>
, and{" "}
<Link href="https://github.com/replicate/instruct-pix2pix-demo" target="_blank">
<Link href="https://github.com/replicate/paint-by-text" target="_blank">
GitHub
</Link>
</div>
Expand Down
17 changes: 6 additions & 11 deletions lib/prepare-image-file-for-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ export default function prepareImageFileForUpload(file) {

let width = img.width;
let height = img.height;
if (width > height) {
if (width > MAX_WIDTH) {
width = MAX_WIDTH;
height = height * (MAX_WIDTH / width);
}
} else {
if (height > MAX_HEIGHT) {
width = width * (MAX_HEIGHT / height);
height = MAX_HEIGHT;
}
}
// Calculate the scaling factor to fit within the max dimensions while preserving aspect ratio
const widthRatio = MAX_WIDTH / width;
const heightRatio = MAX_HEIGHT / height;
const scale = Math.min(widthRatio, heightRatio, 1); // Don't upscale
width = Math.round(width * scale);
height = Math.round(height * scale);

const canvas = document.createElement("canvas");
canvas.width = width;
Expand Down
Loading