Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: image dimension mismatch crash blocking recording on Windows

Louis Beaumont1c900525d69d
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index 08a2ddcee..6e235228e 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -771,7 +771,7 @@ jobs:
$env:PATH += ";C:\Program Files\Amazon\AWSCLIV2"
}
$version = (Select-String -Path apps/screenpipe-app-tauri/src-tauri/Cargo.toml -Pattern '^version = "(.*)"').Matches[0].Groups[1].Value
- $bundleDir = "apps/screenpipe-app-tauri/src-tauri/target/release/bundle"
+ $bundleDir = "apps/screenpipe-app-tauri/src-tauri/target/x86_64-pc-windows-msvc/release/bundle"
$r2Endpoint = "https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
$r2Prefix = "s3://screenpipe-releases/releases/$version/x86_64-pc-windows-msvc"
diff --git a/Cargo.lock b/Cargo.lock
index 00c92c4c8..578a2cfae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6641,7 +6641,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"anyhow",
"bytemuck",
@@ -6694,7 +6694,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -6745,7 +6745,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"anyhow",
"chrono",
@@ -6769,7 +6769,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"anyhow",
"chrono",
@@ -6787,7 +6787,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"anyhow",
"image",
@@ -6802,7 +6802,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"anyhow",
"async-trait",
@@ -6873,7 +6873,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.135"
+version = "0.3.136"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/crates/screenpipe-vision/src/frame_comparison.rs b/crates/screenpipe-vision/src/frame_comparison.rs
index aeb430e7f..60d032ca2 100644
--- a/crates/screenpipe-vision/src/frame_comparison.rs
+++ b/crates/screenpipe-vision/src/frame_comparison.rs
@@ -305,7 +305,16 @@ pub struct FrameComparisonStats {
/// Returns a difference score between 0.0 (identical) and 1.0 (completely different).
pub fn compare_histogram(image1: &DynamicImage, image2: &DynamicImage) -> anyhow::Result<f64> {
let image_one = image1.to_luma8();
- let image_two = image2.to_luma8();
+ let mut image_two = image2.to_luma8();
+ // Resize to match if dimensions differ (e.g. monitor resolution change)
+ if image_one.dimensions() != image_two.dimensions() {
+ image_two = image::imageops::resize(
+ &image_two,
+ image_one.width(),
+ image_one.height(),
+ FilterType::Nearest,
+ );
+ }
image_compare::gray_similarity_histogram(Metric::Hellinger, &image_one, &image_two)
.map_err(|e| anyhow::anyhow!("Failed to compare images: {}", e))
}
@@ -314,13 +323,22 @@ pub fn compare_histogram(image1: &DynamicImage, image2: &DynamicImage) -> anyhow
/// Returns a difference score between 0.0 (identical) and 1.0 (completely different).
pub fn compare_ssim(image1: &DynamicImage, image2: &DynamicImage) -> f64 {
let image_one = image1.to_luma8();
- let image_two = image2.to_luma8();
+ let mut image_two = image2.to_luma8();
+ // Resize to match if dimensions differ (e.g. monitor resolution change)
+ if image_one.dimensions() != image_two.dimensions() {
+ image_two = image::imageops::resize(
+ &image_two,
+ image_one.width(),
+ image_one.height(),
+ FilterType::Nearest,
+ );
+ }
let result = image_compare::gray_similarity_structure(
&image_compare::Algorithm::MSSIMSimple,
&image_one,
&image_two,
)
- .expect("Images had different dimensions");
+ .expect("images should have matching dimensions after resize");
1.0 - result.score // Convert similarity to difference
}
diff --git a/crates/screenpipe-vision/src/utils.rs b/crates/screenpipe-vision/src/utils.rs
index f5542ff41..15b201a0e 100644
--- a/crates/screenpipe-vision/src/utils.rs
+++ b/crates/screenpipe-vision/src/utils.rs
@@ -58,17 +58,35 @@ pub fn compare_images_histogram(
image2: &DynamicImage,
) -> anyhow::Result<f64> {
let image_one = image1.to_luma8();
- let image_two = image2.to_luma8();
+ let mut image_two = image2.to_luma8();
+ // Resize to match if dimensions differ (e.g. monitor resolution change)
+ if image_one.dimensions() != image_two.dimensions() {
+ image_two = image::imageops::resize(
+ &image_two,
+ image_one.width(),
+ image_one.height(),
+ image::imageops::FilterType::Nearest,
+ );
+ }
image_compare::gray_similarity_histogram(Metric::Hellinger, &image_one, &image_two)
.map_err(|e| anyhow::anyhow!("Failed to compare images: {}", e))
}
pub fn compare_images_ssim(image1: &DynamicImage, image2: &DynamicImage) -> f64 {
let image_one = image1.to_luma8();
- let image_two = image2.to_luma8();
+ let mut image_two = image2.to_luma8();
+ // Resize to match if dimensions differ (e.g. monitor resolution change)
+ if image_one.dimensions() != image_two.dimensions() {
+ image_two = image::imageops::resize(
+ &image_two,
+ image_one.width(),
+ image_one.height(),
+ image::imageops::FilterType::Nearest,
+ );
+ }
let result: Similarity =
image_compare::gray_similarity_structure(&Algorithm::MSSIMSimple, &image_one, &image_two)
- .expect("Images had different dimensions");
+ .expect("images should have matching dimensions after resize");
result.score
}