Fix broken images on egui.rs (move from git lfs to normal git) (#5480)

The images in the widget gallery on egui.rs are broken:

![image](https://github.com/user-attachments/assets/305e1041-e3e3-472d-9a52-1b90e8da053d)

~Not sure why yet, and I fail to reproduce locally.~
It's because they are on git lfs.
This commit is contained in:
Emil Ernerfeldt 2024-12-16 14:16:54 +01:00 committed by GitHub
parent 3bdb19e864
commit f0ec2f05c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 6 deletions

5
.gitattributes vendored
View File

@ -1,5 +1,8 @@
* text=auto eol=lf
Cargo.lock linguist-generated=false
*.png filter=lfs diff=lfs merge=lfs -text
# The icon.png is needed when including eframe via git, so it may not be in lfs
# Exclude some small files from LFS:
crates/eframe/data/* !filter !diff !merge text=auto eol=lf
crates/egui_demo_lib/data/* !filter !diff !merge text=auto eol=lf
crates/egui/assets/* !filter !diff !merge text=auto eol=lf

View File

@ -13,11 +13,18 @@ jobs:
- name: Check that png files are on git LFS
run: |
binary_extensions="png"
exclude="crates/eframe/data"
exclude_paths=(
"crates/eframe/data"
"crates/egui_demo_lib/data/"
"crates/egui/assets/"
)
# Find binary files that are not tracked by Git LFS
for ext in $binary_extensions; do
if comm -23 <(git ls-files | grep -v "^$exclude" | sort) <(git lfs ls-files -n | sort) | grep "\.${ext}$"; then
# Create grep pattern to exclude multiple paths
exclude_pattern=$(printf "|^%s" "${exclude_paths[@]}" | sed 's/^|//')
if comm -23 <(git ls-files | grep -Ev "$exclude_pattern" | sort) <(git lfs ls-files -n | sort) | grep "\.${ext}$"; then
echo "Error: Found binary file with extension .$ext not tracked by git LFS. See CONTRIBUTING.md"
exit 1
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -28,8 +28,8 @@ default = ["glow", "persistence"]
# image_viewer adds about 0.9 MB of WASM
web_app = ["http", "persistence"]
http = ["ehttp", "image", "poll-promise", "egui_extras/image"]
image_viewer = ["image", "egui_extras/all_loaders", "rfd"]
http = ["ehttp", "image/jpeg", "poll-promise", "egui_extras/image"]
image_viewer = ["image/jpeg", "egui_extras/all_loaders", "rfd"]
persistence = [
"eframe/persistence",
"egui_extras/serde",
@ -56,6 +56,10 @@ eframe = { workspace = true, default-features = false, features = [
egui = { workspace = true, features = ["callstack", "default", "log"] }
egui_demo_lib = { workspace = true, features = ["default", "chrono"] }
egui_extras = { workspace = true, features = ["default", "image"] }
image = { workspace = true, default-features = false, features = [
# Ensure we can display the test images
"png",
] }
log.workspace = true
profiling.workspace = true
@ -70,7 +74,6 @@ wgpu = { workspace = true, features = ["webgpu", "webgl"], optional = true }
# feature "http":
ehttp = { version = "0.5", optional = true }
image = { workspace = true, optional = true, features = ["jpeg", "png"] }
poll-promise = { version = "0.3", optional = true, default-features = false }
# feature "persistence":

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -78,6 +78,12 @@ impl ImageLoader for ImageCrateLoader {
}
}
if bytes.starts_with(b"version https://git-lfs") {
return Err(LoadError::FormatNotSupported {
detected_format: Some("git-lfs".to_owned()),
});
}
// (3)
log::trace!("started loading {uri:?}");
let result = crate::image::load_image_bytes(&bytes).map(Arc::new);