Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
fix: upscaling square 2K images fell back to Lanczos; prompt box height on Linux
Gabriele Lozupone754cbfc537f1
diff --git a/crates/qls-core/src/engine.rs b/crates/qls-core/src/engine.rsindex f6ab329..5234f7c 100644--- a/crates/qls-core/src/engine.rs+++ b/crates/qls-core/src/engine.rs@@ -929,7 +929,7 @@ impl Engine {let (inp, t) = (input.clone(), *tile);let png = blocking(move || pipeline::tile_png_b64(&inp, &t)).await?;let resp = client.upscale(&UpscaleRequest { image: png, upscaler: Some(upscaler.to_string()), tile_size: (tile_px > 0).then_some(tile_px), output_format: "png".into() }).await?;- let up = blocking(move || Ok(imaging::decode_image(&crate::sdcpp::b64_decode(&resp.images[0].b64_json)?)?.pixels)).await?;+ let up = blocking(move || imaging::decode_engine_image(&crate::sdcpp::b64_decode(&resp.images[0].b64_json)?, pipeline::ESRGAN_MAX_OUTPUT_SIDE)).await?;stitcher.add(tile, &up)?;}Ok(Some(blocking(move || stitcher.finish(&content)).await?))diff --git a/crates/qls-core/src/imaging.rs b/crates/qls-core/src/imaging.rsindex 9fe0962..409eda3 100644--- a/crates/qls-core/src/imaging.rs+++ b/crates/qls-core/src/imaging.rs@@ -112,6 +112,21 @@ fn decode_heic(bytes: &[u8]) -> Result<LoadedImage, AppError> {})}+/// Decodes an image produced by our own engine (an upscaler tile). Not subject to the input+/// limit: a 2048² tile through an x4 model is 8192² (67 MP), and the request plan already bounds+/// it to `max_side` per side.+pub fn decode_engine_image(bytes: &[u8], max_side: u32) -> Result<RgbaImage, AppError> {+ let mut reader = ImageReader::new(Cursor::new(bytes))+ .with_guessed_format()+ .map_err(|e| AppError::new(ErrorCode::ImageDecode, "The engine returned an unreadable image.").detail(e.to_string()))?;+ reader.no_limits();+ let img = reader.decode().map_err(|e| AppError::new(ErrorCode::ImageDecode, "The engine returned an unreadable image.").detail(e.to_string()))?;+ if img.width() == 0 || img.height() == 0 || img.width() > max_side || img.height() > max_side {+ return Err(AppError::new(ErrorCode::ImageDecode, format!("The engine returned an unexpected size ({}×{}).", img.width(), img.height())));+ }+ Ok(img.into_rgba8())+}+pub fn load_image(path: &std::path::Path) -> Result<LoadedImage, AppError> {let bytes = std::fs::read(path).map_err(|e| AppError::io("read the image", path, e))?;decode_image(&bytes)@@ -609,6 +624,17 @@ mod tests {RgbaImage::from_fn(w, h, |x, y| Rgba([(x * 255 / w.max(1)) as u8, (y * 255 / h.max(1)) as u8, 77, 255]))}+ #[test]+ fn engine_tiles_may_exceed_the_input_limit() {+ // An x4 tile of a 2048² image is 8192² (67 MP): over the import limit, but ours.+ let (w, h) = (8192, 8192);+ assert!(w as u64 * h as u64 > MAX_INPUT_PIXELS);+ let png = encode_png(&RgbaImage::from_pixel(w, h, Rgba([10, 20, 30, 255])), &[], None, true).unwrap();+ assert!(decode_image(&png).is_err(), "imports keep the limit");+ assert_eq!(decode_engine_image(&png, 8192).unwrap().dimensions(), (w, h));+ assert!(decode_engine_image(&png, 4096).is_err(), "larger than the plan allows");+ }+/// Builds a JPEG with an EXIF APP1 segment carrying the given orientation.fn jpeg_with_orientation(img: &RgbaImage, orientation: u16) -> Vec<u8> {let jpeg = encode_jpeg(img, 95).unwrap();diff --git a/src/components/Composer.tsx b/src/components/Composer.tsxindex 185ddb3..87a640b 100644--- a/src/components/Composer.tsx+++ b/src/components/Composer.tsx@@ -293,8 +293,22 @@ export function Composer() {useEffect(() => {const ta = taRef.current;if (!ta) return;- ta.style.height = "auto";- ta.style.height = Math.min(200, ta.scrollHeight) + "px";+ const fit = () => {+ ta.style.height = "auto";+ ta.style.height = Math.min(200, ta.scrollHeight) + "px";+ };+ fit();+ // Also when its width changes: WebKitGTK (Linux) lays the box out while the window is still+ // hidden at startup, so the first measure wraps the placeholder into a column.+ let width = ta.clientWidth;+ const ro = new ResizeObserver(() => {+ if (ta.clientWidth !== width) {+ width = ta.clientWidth;+ fit();+ }+ });+ ro.observe(ta);+ return () => ro.disconnect();}, [c.prompt]);const outPx = hasOutpaint(c.outpaint) && c.refs[0] ? expansionPixels(c.outpaint!, c.refs[0].width, c.refs[0].height) : null;