1
0
Fork 0
mirror of synced 2024-06-02 10:35:02 +12:00

Heic WEBP

This commit is contained in:
Rafał Mikrut 2022-06-08 20:41:51 +02:00
parent 061463a2cc
commit a92cd1657c
14 changed files with 107 additions and 85 deletions

View file

@ -32,17 +32,10 @@ jobs:
linux-cli-${{github.ref}}-${{github.sha}}
- name: Install basic libraries
run: sudo apt-get update; sudo apt install libgtk-4-dev libasound2-dev -y
- name: Build CLI Debug
run: cargo build --bin czkawka_cli
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
if: ${{ matrix.type == 'debug'}}
run: sudo apt-get update; sudo apt install libgtk-4-dev libheif-dev -y
- name: Build CLI Release
run: cargo build --release --bin czkawka_cli
run: cargo build --release --bin czkawka_cli --features heif
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
@ -150,21 +143,26 @@ jobs:
linux-gui-${{github.ref}}-${{github.sha}}
- name: Install Gtk, Mingw, unzip, zip and wget
run: sudo apt-get update; sudo apt install libgtk-4-dev libasound2-dev fuse libfuse2 -y
run: sudo apt-get update; sudo apt install libgtk-4-dev fuse libfuse2
if: ${{ matrix.toolchain == '1.60.0' }}
- name: Build GUI Debug
run: cargo build --bin czkawka_gui
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
if: ${{ matrix.type == 'debug'}}
- name: Install Gtk, Mingw, unzip, zip and wget and libheif
run: sudo apt-get update; sudo apt install libgtk-4-dev fuse libfuse2 libheif-dev -y
if: ${{ matrix.toolchain == 'stable' }}
- name: Build GUI Release
run: cargo build --release --bin czkawka_gui
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
if: ${{ matrix.type == 'release'}}
if: ${{ matrix.type == 'release'}} and ${{ matrix.toolchain == '1.60.0' }}
- name: Build GUI Release
run: cargo build --release --bin czkawka_gui --features heif
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0"
if: ${{ matrix.type == 'release'}} and ${{ matrix.toolchain == 'stable' }}
- name: Store Linux GUI
uses: actions/upload-artifact@v2
@ -214,7 +212,7 @@ jobs:
linux-appimage-gui-${{github.ref}}-${{github.sha}}
- name: Install Gtk,
run: sudo apt-get update; sudo apt install libgtk-4-dev libasound2-dev librsvg2-dev wget fuse libfuse2 -y
run: sudo apt-get update; sudo apt install libgtk-4-dev libheif-dev librsvg2-dev wget fuse libfuse2 -y
- name: Build GUI Release
run: cargo build --release --bin czkawka_gui

View file

@ -31,15 +31,8 @@ jobs:
restore-keys: |
mac-cli-${{github.ref}}-${{github.sha}}
- name: Build CLI Debug
run: cargo build --bin czkawka_cli
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
if: ${{ matrix.type == 'debug'}}
- name: Build CLI Release
run: cargo build --release --bin czkawka_cli
run: cargo build --release --bin czkawka_cli --features heif
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
@ -73,17 +66,10 @@ jobs:
run: rm '/usr/local/bin/2to3'
- name: Install GTK4
run: brew install rust gtk4
- name: Build GUI Debug
run: cargo build --bin czkawka_gui
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
if: ${{ matrix.type == 'debug'}}
run: brew install rust gtk4 libheif
- name: Build GUI Release
run: cargo build --release --bin czkawka_gui
run: cargo build --release --bin czkawka_gui --features heif
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"

View file

@ -28,8 +28,8 @@ jobs:
components: rustfmt, clippy
override: true
- name: Install Gtk
run: sudo apt-get update; sudo apt install -y libgtk-4-dev libasound2-dev
- name: Install Gtk 4
run: sudo apt-get update; sudo apt install -y libgtk-4-dev libheif-dev -y
- name: Check the format
run: cargo fmt --all -- --check

View file

@ -9,8 +9,16 @@ homepage = "https://github.com/qarmin/czkawka"
repository = "https://github.com/qarmin/czkawka"
[dependencies]
czkawka_core = { path = "../czkawka_core", version = "4.1.0" }
structopt = "0.3.26"
# For enum types
image_hasher = "1.0.0"
image_hasher = "1.0.0"
[dependencies.czkawka_core]
path = "../czkawka_core"
version = "4.1.0"
features = []
[features]
default = []
heif = ["czkawka_core/heif"]

View file

@ -69,5 +69,5 @@ libheif-rs = { version = "0.15.0", optional = true }
anyhow = { version = "1.0.57", optional = true }
[features]
default = ["heif"]
default = []
heif = ["dep:libheif-rs", "dep:anyhow"]

View file

@ -20,15 +20,15 @@ pub const RAW_IMAGE_EXTENSIONS: &[&str] = &[
".cr2", ".ari",
];
pub const IMAGE_RS_EXTENSIONS: &[&str] = &[
".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".webp", ".gif", ".ico", ".exr", ".hdr",
".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".webp", ".gif", ".ico", ".exr",
];
pub const IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS: &[&str] = &[".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".bmp", ".webp", ".exr", ".hdr"];
pub const IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS: &[&str] = &[".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".bmp", ".webp", ".exr"];
pub const IMAGE_RS_BROKEN_FILES_EXTENSIONS: &[&str] = &[
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".gif", ".bmp", ".ico", ".jfif", ".jpe", ".pnz", ".dib", ".webp", ".exr", ".hdr",
".jpg", ".jpeg", ".png", ".tiff", ".tif", ".tga", ".ff", ".jif", ".jfi", ".gif", ".bmp", ".ico", ".jfif", ".jpe", ".pnz", ".dib", ".webp", ".exr",
];
pub const HEIC_EXTENSIONS: &[&str] = &[".heic"];
pub const HEIC_EXTENSIONS: &[&str] = &[".heif", ".heifs", ".heic", ".heics", ".avci", ".avcs", ".avif", ".avifs"];
pub const ZIP_FILES_EXTENSIONS: &[&str] = &[".zip"];

View file

@ -9,7 +9,6 @@ homepage = "https://github.com/qarmin/czkawka"
repository = "https://github.com/qarmin/czkawka"
[dependencies]
czkawka_core = { path = "../czkawka_core", version = "4.1.0"}
gdk4 = "0.4.7"
glib = "0.15.11"
@ -57,3 +56,11 @@ version = "0.4.7"
default-features = false # just in case
features = ["v4_6"]
[dependencies.czkawka_core]
path = "../czkawka_core"
version = "4.1.0"
features = []
[features]
default = []
heif = ["czkawka_core/heif"]

View file

@ -1,10 +1,12 @@
use std::cell::RefCell;
use std::rc::Rc;
#[cfg(feature = "heif")]
use czkawka_core::common::get_dynamic_image_from_heic;
use czkawka_core::common::HEIC_EXTENSIONS;
use gdk4::gdk_pixbuf::{InterpType, Pixbuf};
use gtk4::prelude::*;
use gtk4::{CheckButton, Image, ListStore, Orientation, ScrolledWindow, TreeIter, TreeModel, TreePath, TreeSelection, Widget};
use gtk4::{Align, CheckButton, Image, ListStore, Orientation, ScrolledWindow, TreeIter, TreeModel, TreePath, TreeSelection, Widget};
use image::DynamicImage;
use crate::flg;
@ -16,7 +18,7 @@ use crate::help_functions::{
use crate::localizer_core::generate_translation_hashmap;
const BIG_PREVIEW_SIZE: i32 = 600;
const SMALL_PREVIEW_SIZE: i32 = 100;
const SMALL_PREVIEW_SIZE: i32 = 130;
pub fn connect_button_compare(gui_data: &GuiData) {
let button_compare = gui_data.bottom_buttons.buttons_compare.clone();
@ -352,10 +354,15 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
let big_img = Image::new();
let mut pixbuf = get_pixbuf_from_dynamic_image(&DynamicImage::new_rgb8(1, 1)).unwrap();
if name.to_lowercase().ends_with(".heic") || name.to_lowercase().ends_with(".webp") {
let name_lowercase = name.to_lowercase();
let is_heic = HEIC_EXTENSIONS.iter().any(|extension| name_lowercase.ends_with(extension));
let is_webp = name.to_lowercase().ends_with(".webp");
if is_heic || is_webp {
#[allow(clippy::never_loop)]
'czystka: loop {
if name.ends_with(".heic") {
#[cfg(feature = "heif")]
if is_heic {
match get_dynamic_image_from_heic(&full_path) {
Ok(t) => {
match get_pixbuf_from_dynamic_image(&t) {
@ -373,7 +380,7 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
};
break 'czystka;
}
if name.ends_with(".webp") {
if is_webp {
match image::open(&full_path) {
Ok(t) => {
match get_pixbuf_from_dynamic_image(&t) {
@ -523,10 +530,11 @@ fn populate_similar_scrolled_view(
column_selection: i32,
) {
scrolled_window.set_child(None::<&Widget>);
scrolled_window.set_propagate_natural_height(true);
let all_gtk_box = gtk4::Box::new(Orientation::Horizontal, 5);
all_gtk_box.set_widget_name("all_box");
all_gtk_box.set_halign(Align::Fill);
all_gtk_box.set_valign(Align::Fill);
for (number, (path, _name, big_thumbnail, small_thumbnail, tree_path)) in image_cache.iter().enumerate() {
let small_box = gtk4::Box::new(Orientation::Vertical, 3);
@ -583,6 +591,17 @@ fn populate_similar_scrolled_view(
smaller_box.append(&button_right);
small_box.append(&smaller_box);
small_box.set_halign(Align::Fill);
small_box.set_valign(Align::Fill);
small_box.set_hexpand_set(true);
small_box.set_vexpand_set(true);
small_thumbnail.set_halign(Align::Fill);
small_thumbnail.set_valign(Align::Fill);
small_thumbnail.set_hexpand(true);
small_thumbnail.set_hexpand_set(true);
small_thumbnail.set_vexpand(true);
small_thumbnail.set_vexpand_set(true);
small_box.append(small_thumbnail);
all_gtk_box.append(&small_box);

View file

@ -8,7 +8,9 @@ use gtk4::gdk_pixbuf::InterpType;
use gtk4::prelude::*;
use gtk4::{CheckButton, Image, SelectionMode, TextView, TreeView};
use czkawka_core::common::{get_dynamic_image_from_heic, HEIC_EXTENSIONS, IMAGE_RS_EXTENSIONS, RAW_IMAGE_EXTENSIONS};
#[cfg(feature = "heif")]
use czkawka_core::common::get_dynamic_image_from_heic;
use czkawka_core::common::{HEIC_EXTENSIONS, IMAGE_RS_EXTENSIONS, RAW_IMAGE_EXTENSIONS};
use czkawka_core::similar_images::SIMILAR_VALUES;
use czkawka_core::similar_videos::MAX_TOLERANCE;
@ -698,7 +700,7 @@ fn show_preview(
return; // Preview is already created, no need to recreate it
}
}
println!("Trying to {}", name);
let is_heic;
let is_webp;
if let Some(extension) = Path::new(&name).extension() {
@ -713,6 +715,7 @@ fn show_preview(
}
let mut pixbuf = if is_heic || is_webp {
let image = if is_heic {
#[cfg(feature = "heif")]
match get_dynamic_image_from_heic(file_name) {
Ok(t) => t,
Err(e) => {
@ -727,6 +730,9 @@ fn show_preview(
break 'dir;
}
}
#[cfg(not(feature = "heif"))]
panic!("")
} else if is_webp {
match image::open(file_name) {
Ok(t) => t,

View file

@ -11,14 +11,7 @@
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel" id="label_group_info">
<property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Group XD/PER XD (99 images in current group)</property>
</object>
</child>
<child>
<object class="GtkButton" id="button_go_next_compare_group">
<object class="GtkButton" id="button_go_previous_compare_group">
<property name="focusable">1</property>
<property name="receives-default">1</property>
<child>
@ -29,7 +22,14 @@
</object>
</child>
<child>
<object class="GtkButton" id="button_go_previous_compare_group">
<object class="GtkLabel" id="label_group_info">
<property name="halign">center</property>
<property name="hexpand">1</property>
<property name="label" translatable="yes">Group XD/PER XD (99 images in current group)</property>
</object>
</child>
<child>
<object class="GtkButton" id="button_go_next_compare_group">
<property name="focusable">1</property>
<property name="receives-default">1</property>
<child>
@ -63,16 +63,22 @@
<property name="homogeneous">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkImage" id="image_compare_left"/>
<object class="GtkImage" id="image_compare_left">
<property name="height-request">100</property>
</object>
</child>
<child>
<object class="GtkImage" id="image_compare_right"/>
<object class="GtkImage" id="image_compare_right">
<property name="height-request">100</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window_compare_choose_images">
<property name="focusable">1</property>
<property name="max-content-height">150</property>
<property name="min-content-height">150</property>
</object>
</child>
</object>

View file

@ -24,10 +24,10 @@
(4,1,"GtkDialog","window_compare",None,None,None,None,None),
(4,2,"GtkBox",None,1,None,None,None,None),
(4,3,"GtkBox",None,2,None,None,None,None),
(4,4,"GtkLabel","label_group_info",3,None,None,None,None),
(4,5,"GtkButton","button_go_next_compare_group",3,None,None,None,1),
(4,4,"GtkLabel","label_group_info",3,None,None,None,1),
(4,5,"GtkButton","button_go_next_compare_group",3,None,None,None,2),
(4,6,"GtkImage",None,5,None,None,None,None),
(4,7,"GtkButton","button_go_previous_compare_group",3,None,None,None,2),
(4,7,"GtkButton","button_go_previous_compare_group",3,None,None,None,None),
(4,8,"GtkImage",None,7,None,None,None,None),
(4,9,"GtkBox",None,2,None,None,None,1),
(4,10,"GtkCheckButton","check_button_left_preview_text",9,None,None,None,None),
@ -260,8 +260,6 @@
(8,26,"GtkLabel",None,24,None,None,None,1),
(9,1,"GtkDialog","window_settings",None,None,None,None,None),
(9,3,"GtkBox","potatoo",1,None,None,None,None),
(9,4,"GtkBox",None,3,None,None,None,None),
(9,5,"GtkComboBoxText",None,4,None,None,None,None),
(9,6,"GtkNotebook","notebook_settings",3,None,None,None,1),
(9,7,"GtkNotebookPage",None,6,None,None,None,None),
(9,8,"GtkBox",None,7,None,None,None,None),
@ -336,6 +334,10 @@
(4,11,"GtkWidget","focusable","1",None,None,None,None,None),
(4,12,"GtkBox","homogeneous","1",None,None,None,None,None),
(4,12,"GtkWidget","vexpand","1",None,None,None,None,None),
(4,13,"GtkWidget","height-request","100",None,None,None,None,None),
(4,14,"GtkWidget","height-request","100",None,None,None,None,None),
(4,15,"GtkScrolledWindow","max-content-height","150",None,None,None,None,None),
(4,15,"GtkScrolledWindow","min-content-height","150",None,None,None,None,None),
(4,15,"GtkWidget","focusable","1",None,None,None,None,None),
(5,1,"GtkAdjustment","page-increment","10",None,None,None,None,None),
(5,1,"GtkAdjustment","step-increment","1",None,None,None,None,None),
@ -803,8 +805,6 @@
(9,1,"GtkWindow","title","Czkawka Options",1,None,None,None,None),
(9,3,"GtkOrientable","orientation","vertical",None,None,None,None,None),
(9,3,"GtkWidget","vexpand","1",None,None,None,None,None),
(9,4,"GtkOrientable","orientation","vertical",None,None,None,None,None),
(9,5,"GtkWidget","valign","center",None,None,None,None,None),
(9,6,"GtkNotebook","tab-pos","left",None,None,None,None,None),
(9,6,"GtkWidget","focusable","1",None,None,None,None,None),
(9,6,"GtkWidget","vexpand","1",None,None,None,None,None),

View file

@ -10,16 +10,6 @@
<object class="GtkBox" id="potatoo">
<property name="orientation">vertical</property>
<property name="vexpand">1</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBoxText">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkNotebook" id="notebook_settings">
<property name="focusable">1</property>

View file

@ -6,6 +6,8 @@ If you only want the terminal version without a GUI, just skip all the packages
FFmpeg is not included here because it is not needed to build - it is dynamically loaded.
Support for heif images is optional and require to install libheif library.
| Program | Min | What for |
|---------|------|-------------------------------------------------------------------------------|
@ -26,12 +28,12 @@ sudo yum install gtk3-devel glib2-devel
```
#### macOS
You need to install Rust via Homebrew and GTK Libraries
You need to install Rust via Homebrew, GTK Libraries and optionally heif library(to have support for heic files, which are quite popular on mac)
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install rustup
rustup-init
brew install gtk+3 adwaita-icon-theme librsvg
brew install gtk+3 adwaita-icon-theme librsvg libheif
```
### Windows

View file

@ -29,7 +29,7 @@ One very straight-forward way to do this is by using [Homebrew](https://brew.sh/
Installation in the terminal:
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gtk+3 adwaita-icon-theme ffmpeg librsvg
brew install gtk+3 adwaita-icon-theme ffmpeg librsvg libheif
```
After that, go to the location where you downloaded Czkawka and add the `executable` permission to this file.
```shell
@ -43,7 +43,7 @@ At the end execute it:
**Warning**
Prebuilt binaries are available only for x86_64, so if you use ARM machine like e.g. Mac M1, you need to compile manually app or install special version of required libraries which can be done via this:
```shell
arch -x86_64 /usr/local/bin/brew install gtk+3 adwaita-icon-theme ffmpeg librsvg
arch -x86_64 /usr/local/bin/brew install gtk+3 adwaita-icon-theme ffmpeg librsvg libheif
```
### Windows