Skip to content

Commit 81825b5

Browse files
committed
release: 1.2.0
2 parents e2ed2e8 + 5a49a24 commit 81825b5

File tree

10 files changed

+123
-152
lines changed

10 files changed

+123
-152
lines changed

CREDITS.md

Lines changed: 67 additions & 65 deletions
Large diffs are not rendered by default.

refract/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "refract"
3-
version = "1.1.0"
3+
version = "1.2.0"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"
@@ -99,7 +99,6 @@ description = "Image and/or directory paths to re-encode. Directories will be cr
9999

100100
[build-dependencies]
101101
argyle = "0.13.*"
102-
dowser = "0.15.*"
103102

104103
[build-dependencies.refract_core]
105104
path = "../refract_core"
@@ -108,10 +107,10 @@ features = [ "png" ]
108107

109108
[dependencies]
110109
dactyl = "0.13.*"
111-
dowser = "0.15.*"
110+
dowser = "0.16.*"
112111
fyi_ansi = "2.2.*"
113112
open = "=5.3.2"
114-
rfd = "=0.15.3"
113+
rfd = "=0.15.4"
115114
unicode-width = "0.2.*"
116115
write_atomic = "0.7.*"
117116

@@ -132,5 +131,5 @@ path = "../refract_core"
132131
features = [ "images" ]
133132

134133
[dependencies.utc2k]
135-
version = "0.15.*"
134+
version = "0.17.*"
136135
features = [ "local" ]

refract/build.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
use argyle::KeyWordsBuilder;
6-
use dowser::Extension;
76
use std::{
87
fs::File,
98
io::Write,
@@ -22,7 +21,6 @@ fn main() {
2221
println!("cargo:rerun-if-changed=skel");
2322

2423
build_cli();
25-
build_exts();
2624
build_imgs();
2725
}
2826

@@ -45,44 +43,6 @@ fn build_cli() {
4543
builder.save(_out_path("argyle.rs").expect("Missing OUT_DIR."));
4644
}
4745

48-
/// # Build Extensions.
49-
///
50-
/// While we're here, we may as we pre-compute our various image extension
51-
/// constants.
52-
fn build_exts() {
53-
let out = format!(
54-
r"
55-
/// # Extension: AVIF.
56-
const E_AVIF: Extension = {};
57-
/// # Extension: JPEG.
58-
const E_JPEG: Extension = {};
59-
/// # Extension: JPG.
60-
const E_JPG: Extension = {};
61-
/// # Extension: JXL.
62-
const E_JXL: Extension = {};
63-
/// # Extension: PNG.
64-
const E_PNG: Extension = {};
65-
/// # Extension: WEBP.
66-
const E_WEBP: Extension = {};
67-
",
68-
Extension::codegen(b"avif"),
69-
Extension::codegen(b"jpeg"),
70-
Extension::codegen(b"jpg"),
71-
Extension::codegen(b"jxl"),
72-
Extension::codegen(b"png"),
73-
Extension::codegen(b"webp"),
74-
);
75-
76-
// Save them as a slice value!
77-
let mut file = _out_path("refract-extensions.rs")
78-
.and_then(|p| File::create(p).ok())
79-
.expect("Missing OUT_DIR.");
80-
81-
file.write_all(out.as_bytes())
82-
.and_then(|_| file.flush())
83-
.expect("Unable to save extensions.");
84-
}
85-
8646
/// # Build Images.
8747
///
8848
/// Pre-decode a couple images for embed to lessen the runtime costs of using

refract/src/app.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl App {
596596
///
597597
/// Under the hood, this defers to either `view_home`, `view_encoder`, or
598598
/// `view_ab` depending on the state of things.
599-
pub(super) fn view(&self) -> Container<Message> {
599+
pub(super) fn view(&self) -> Container<'_, Message> {
600600
// If we're processing an image, return the A/B screen.
601601
if self.current.as_ref().is_some_and(CurrentImage::active) {
602602
// Unless we _just_ switched encoders, in which case we should
@@ -624,7 +624,7 @@ impl App {
624624
///
625625
/// (A warning/error message may also be presented, but they're short-
626626
/// lived and uncommon.)
627-
fn view_home(&self) -> Container<Message> {
627+
fn view_home(&self) -> Container<'_, Message> {
628628
container(
629629
column!(
630630
self.view_settings(),
@@ -641,7 +641,7 @@ impl App {
641641
/// # View: About.
642642
///
643643
/// This returns the application name, version, and repository URL.
644-
fn view_about(&self) -> Column<Message> {
644+
fn view_about(&self) -> Column<'_, Message> {
645645
column!(
646646
rich_text!(
647647
emphasize!(span("Refract "), Skin::PINK),
@@ -663,7 +663,7 @@ impl App {
663663
/// If the user did something that did nothing instead of something, this
664664
/// returns a message explaining why they got nothing instead of something,
665665
/// lest they think it's our fault!
666-
fn view_error(&self) -> Option<Container<Message>> {
666+
fn view_error(&self) -> Option<Container<'_, Message>> {
667667
use iced::widget::container::Style;
668668

669669
self.error.map(|err|
@@ -690,7 +690,7 @@ impl App {
690690
///
691691
/// This returns button widgets for adding file(s) or directories, and
692692
/// some basic instructions for same.
693-
fn view_enqueue_buttons(&self) -> Container<Message> {
693+
fn view_enqueue_buttons(&self) -> Container<'_, Message> {
694694
container(
695695
column!(
696696
row!(
@@ -865,7 +865,7 @@ impl App {
865865
///
866866
/// This collects and returns the contents of the `view_settings_*`
867867
/// helpers, along with the add-file buttons and about information.
868-
fn view_settings(&self) -> Container<Message> {
868+
fn view_settings(&self) -> Container<'_, Message> {
869869
container(
870870
row!(
871871
self.view_settings_fmt(),
@@ -889,7 +889,7 @@ impl App {
889889
///
890890
/// This returns a list of checkboxes corresponding to the available
891891
/// next-gen image formats (the encoders that will be used).
892-
fn view_settings_fmt(&self) -> Column<Message> {
892+
fn view_settings_fmt(&self) -> Column<'_, Message> {
893893
column!(
894894
emphasize!(text("Formats"), Skin::PINK),
895895
chk!(self, "AVIF", FMT_AVIF),
@@ -902,7 +902,7 @@ impl App {
902902
/// # View: Mode Checkboxes.
903903
///
904904
/// This returns checkboxes for the various compression modes.
905-
fn view_settings_mode(&self) -> Column<Message> {
905+
fn view_settings_mode(&self) -> Column<'_, Message> {
906906
column!(
907907
emphasize!(text("Compression"), Skin::PINK),
908908
chk!(self, "Lossless", MODE_LOSSLESS),
@@ -922,7 +922,7 @@ impl App {
922922
///
923923
/// This returns checkboxes for the program's one-off settings, i.e.
924924
/// night mode and automatic saving.
925-
fn view_settings_other(&self) -> Column<Message> {
925+
fn view_settings_other(&self) -> Column<'_, Message> {
926926
column!(
927927
emphasize!(text("Other"), Skin::PINK),
928928
tip!(
@@ -948,7 +948,7 @@ impl App {
948948
///
949949
/// The constant format changes can get confusing. This screen is used to
950950
/// (very briefly) announce the changes.
951-
fn view_encoder(&self, kind: ImageKind) -> Container<Message> {
951+
fn view_encoder(&self, kind: ImageKind) -> Container<'_, Message> {
952952
use iced::widget::container::Style;
953953

954954
container(
@@ -1001,7 +1001,7 @@ impl App {
10011001
///
10021002
/// It comprises a title-like bar, image stack, and footer with
10031003
/// instructions, progress, and action buttons.
1004-
fn view_ab(&self) -> Container<Message> {
1004+
fn view_ab(&self) -> Container<'_, Message> {
10051005
container(
10061006
column!(
10071007
self.view_ab_header(),
@@ -1027,7 +1027,7 @@ impl App {
10271027
/// This returns the "Accept" and "Reject" buttons used for candidate image
10281028
/// feedback, though they'll only be enabled if the program is ready to
10291029
/// receive said feedback.
1030-
fn view_ab_feedback(&self) -> Column<Message> {
1030+
fn view_ab_feedback(&self) -> Column<'_, Message> {
10311031
let Some(current) = &self.current else { return Column::new(); };
10321032
let active = current.candidate.is_some();
10331033
let b_side = active && self.has_flag(OTHER_BSIDE);
@@ -1102,7 +1102,7 @@ impl App {
11021102
/// 1. In A/B mode, it contains the format and quality details for the image actively being displayed, i.e. the source or candidate.
11031103
/// 2. In lossless-only mode, it lets the user know that no feedback will be required.
11041104
/// 3. Otherwise a generic "reticulating splines" message, since there's nothing to do but wait.
1105-
fn view_ab_header(&self) -> Container<Message> {
1105+
fn view_ab_header(&self) -> Container<'_, Message> {
11061106
use iced::widget::container::Style;
11071107

11081108
let mut row = Row::new()
@@ -1182,7 +1182,7 @@ impl App {
11821182
///
11831183
/// It also includes a checkbox to toggle night mode, since visually it
11841184
/// fits better in this column than anywhere else.
1185-
fn view_ab_progress(&self) -> Column<Message> {
1185+
fn view_ab_progress(&self) -> Column<'_, Message> {
11861186
let Some(current) = self.current.as_ref() else { return Column::new(); };
11871187

11881188
let active = current.candidate.is_some();
@@ -1245,7 +1245,7 @@ impl App {
12451245
///
12461246
/// The image itself is technically optional, but should always be present
12471247
/// in practice.
1248-
fn view_image(&self) -> Stack<Message> {
1248+
fn view_image(&self) -> Stack<'_, Message> {
12491249
Stack::with_capacity(3)
12501250
.push(self.view_image_checkers_a())
12511251
.push_maybe(self.view_image_checkers_b())
@@ -1258,7 +1258,7 @@ impl App {
12581258
///
12591259
/// Produce a checkered background to make it easier to visualize image
12601260
/// transparency.
1261-
fn view_image_checkers_a(&self) -> Container<Message> {
1261+
fn view_image_checkers_a(&self) -> Container<'_, Message> {
12621262
container(
12631263
image(self.cache.checkers_a.clone())
12641264
.content_fit(ContentFit::None)
@@ -1272,7 +1272,7 @@ impl App {
12721272
///
12731273
/// This adds a "B" to every fourth square for added emphasis, but only
12741274
/// when viewing a candidate image.
1275-
fn view_image_checkers_b(&self) -> Option<Container<Message>> {
1275+
fn view_image_checkers_b(&self) -> Option<Container<'_, Message>> {
12761276
if self.has_flag(OTHER_BSIDE) && self.has_candidate() {
12771277
Some(
12781278
container(
@@ -1296,7 +1296,7 @@ impl App {
12961296
///
12971297
/// This method is technically fallible, but in practice it should never
12981298
/// not return something.
1299-
fn view_image_image(&self) -> Option<Container<Message>> {
1299+
fn view_image_image(&self) -> Option<Container<'_, Message>> {
13001300
use iced::widget::scrollable::{
13011301
Direction,
13021302
Rail,
@@ -1355,7 +1355,7 @@ impl App {
13551355
///
13561356
/// This returns a simple legend illustrating the available keyboard
13571357
/// shortcuts that can be used in lieu of the button widgets.
1358-
fn view_keyboard_shortcuts(&self) -> Column<Message> {
1358+
fn view_keyboard_shortcuts(&self) -> Column<'_, Message> {
13591359
let Some(current) = self.current.as_ref() else { return Column::new(); };
13601360
let src_kind = current.input_kind();
13611361
let dst_kind = current.output_kind().unwrap_or(ImageKind::Invalid);
@@ -2287,7 +2287,7 @@ fn cli_log_arg(arg: &str) {
22872287
///
22882288
/// Split the file name into stem and extension parts, trimming the stem if
22892289
/// too long, and checking that the extension is appropriate for JPEG/PNG.
2290-
fn split_ext(src: &Path) -> Option<(Cow<str>, &str)> {
2290+
fn split_ext(src: &Path) -> Option<(Cow<'_, str>, &str)> {
22912291
use unicode_width::UnicodeWidthStr;
22922292

22932293
let ext = src.extension().and_then(OsStr::to_str)?;

refract/src/img.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,23 @@ use std::path::{
1818

1919

2020

21-
// The E_AVIF, E_JPEG, E_JPG, E_JXL, E_PNG, and E_WEBP constants are generated
22-
// by build.rs.
23-
include!(concat!(env!("OUT_DIR"), "/refract-extensions.rs"));
21+
/// # Extension: AVIF.
22+
const E_AVIF: Extension = Extension::new("avif").unwrap();
23+
24+
/// # Extension: JPEG.
25+
const E_JPEG: Extension = Extension::new("jpeg").unwrap();
26+
27+
/// # Extension: JPG.
28+
const E_JPG: Extension = Extension::new("jpg").unwrap();
29+
30+
/// # Extension: JXL.
31+
const E_JXL: Extension = Extension::new("jxl").unwrap();
32+
33+
/// # Extension: PNG.
34+
const E_PNG: Extension = Extension::new("png").unwrap();
35+
36+
/// # Extension: WEBP.
37+
const E_WEBP: Extension = Extension::new("webp").unwrap();
2438

2539
// The image helpers for icons, logos, checkboards, etc., are likewise
2640
// generated by build.rs.
@@ -30,10 +44,7 @@ include!(concat!(env!("OUT_DIR"), "/refract-img.rs"));
3044

3145
/// # Is JPEG/PNG File.
3246
pub(super) fn is_jpeg_png(path: &Path) -> bool {
33-
Extension::try_from3(path).map_or_else(
34-
|| matches!(Extension::try_from4(path), Some(E_JPEG)),
35-
|e| matches!(e, E_JPG | E_PNG),
36-
)
47+
matches!(Extension::from_path(path), Some(E_JPEG | E_JPG | E_PNG))
3748
}
3849

3950
/// # Fix Path Extension.
@@ -46,22 +57,19 @@ pub(super) fn with_ng_extension(path: &Path, kind: ImageKind) -> Option<PathBuf>
4657
// Check the extension, though; we may need to add our own on top.
4758
let ext = match kind {
4859
ImageKind::Avif =>
49-
if Extension::try_from4(&out) == Some(E_AVIF) { return Some(out); }
60+
if E_AVIF.matches_path(&out) { return Some(out); }
5061
else { ".avif" },
5162
ImageKind::Jxl =>
52-
if Extension::try_from3(&out) == Some(E_JXL) { return Some(out); }
63+
if E_JXL.matches_path(&out) { return Some(out); }
5364
else { ".jxl" },
5465
ImageKind::Webp =>
55-
if Extension::try_from4(&out) == Some(E_WEBP) { return Some(out); }
66+
if E_WEBP.matches_path(&out) { return Some(out); }
5667
else { ".webp" },
5768
ImageKind::Jpeg =>
58-
if Extension::try_from3(&out).map_or_else(
59-
|| Extension::try_from4(&out) == Some(E_JPEG),
60-
|e| e == E_JPG
61-
) { return Some(out); }
69+
if matches!(Extension::from_path(&out), Some(E_JPEG | E_JPG)) { return Some(out); }
6270
else { ".jpg" },
6371
ImageKind::Png =>
64-
if Extension::try_from3(&out) == Some(E_PNG) { return Some(out); }
72+
if E_PNG.matches_path(&out) { return Some(out); }
6573
else { ".png" },
6674
ImageKind::Invalid => return None,
6775
};

refract_core/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "refract_core"
3-
version = "1.1.0"
3+
version = "1.2.0"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"
@@ -25,9 +25,9 @@ version = "=1.0.10"
2525
optional = true
2626

2727
[dependencies.lodepng]
28-
version = "=3.11.0"
28+
version = "=3.12.1"
2929
default-features = false
30-
features = [ "rust_backend" ]
30+
features = [ "zlibrs" ]
3131
optional = true
3232

3333
[dependencies.jpegxl-sys]

refract_core/src/enc/quality.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl QualityValueFmt {
234234
///
235235
/// This requires allocation for `Self::Float` variants, but everything
236236
/// else can enjoy a cheap borrow.
237-
pub fn as_str(&self) -> Cow<str> {
237+
pub fn as_str(&self) -> Cow<'_, str> {
238238
match self {
239239
Self::None => Cow::Borrowed(""),
240240
Self::Int(n) => Cow::Borrowed(n.as_str()),

refract_core/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl Input {
294294
///
295295
/// Return the pixels as 4-byte RGBA, upsampling the colorspace as
296296
/// necessary.
297-
pub fn pixels_rgba(&self) -> Cow<[u8]> {
297+
pub fn pixels_rgba(&self) -> Cow<'_, [u8]> {
298298
// The expected size.
299299
let size = self.width() * self.height() * 4;
300300

refract_core/src/traits/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ pub(super) trait Decoder {
4646
/// This is implemented for image formats capable of encoding from RGBA pixels
4747
/// into a raw image.
4848
pub(super) trait Encoder {
49+
#[allow(dead_code, clippy::allow_attributes, reason = "Feature-specific.")]
4950
/// # Minimum Quality.
5051
const MIN_QUALITY: NonZeroU8 = NonZeroU8::MIN;
5152

53+
#[allow(dead_code, clippy::allow_attributes, reason = "Feature-specific.")]
5254
/// # Maximum Quality.
5355
const MAX_QUALITY: NonZeroU8 = NZ_100;
5456

0 commit comments

Comments
 (0)