Compare commits
No commits in common. "main" and "0.9.9" have entirely different histories.
40
.gitea/workflows/build.yaml
Normal file
40
.gitea/workflows/build.yaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: build release package
|
||||||
|
run-name: ${{ gitea.actor }} is building newest nightly release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents:
|
||||||
|
write
|
||||||
|
steps:
|
||||||
|
- run: echo "Build process started by ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "Running build process on ${{ runner.os }}"
|
||||||
|
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
|
- name: Install cargo
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
- run: echo "Starting build"
|
||||||
|
- run: cargo build -r
|
||||||
|
- run: echo "Build finished"
|
||||||
|
- name: Create new release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "target/release/qoi"
|
||||||
|
body: "Automically generated release"
|
||||||
|
|
||||||
|
|
27
.github/workflows/release.yml
vendored
27
.github/workflows/release.yml
vendored
@ -1,27 +0,0 @@
|
|||||||
# .github/workflows/release.yml
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [created]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: release ${{ matrix.target }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- target: x86_64-pc-windows-gnu
|
|
||||||
archive: zip
|
|
||||||
- target: x86_64-unknown-linux-musl
|
|
||||||
archive: tar.gz tar.xz tar.zst
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
- name: Compile and release
|
|
||||||
uses: rust-build/rust-build.action@v1.4.5
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
RUSTTARGET: ${{ matrix.target }}
|
|
||||||
ARCHIVE_TYPES: ${{ matrix.archive }}
|
|
22
.github/workflows/rust.yml
vendored
22
.github/workflows/rust.yml
vendored
@ -1,22 +0,0 @@
|
|||||||
name: Rust
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Build
|
|
||||||
run: cargo build --verbose
|
|
||||||
- name: Run tests
|
|
||||||
run: cargo test --verbose
|
|
21
src/lib.rs
21
src/lib.rs
@ -64,10 +64,8 @@ pub mod qoi_lib {
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use std::error::Error;
|
/// # use std::error::Error;
|
||||||
/// # use crate::qoi::qoi_lib::*;
|
/// # use crate::qoi::qoi_lib::*;
|
||||||
/// # use log::*;
|
|
||||||
/// # fn main() -> Result<(), Box<ImgError>> {
|
/// # fn main() -> Result<(), Box<ImgError>> {
|
||||||
/// let level = LevelFilter::Debug;
|
/// init().expect("Failed to initialize logger");
|
||||||
/// init(level).expect("Failed to initialize logger");
|
|
||||||
/// #
|
/// #
|
||||||
/// # Ok(())
|
/// # Ok(())
|
||||||
/// #
|
/// #
|
||||||
@ -79,10 +77,8 @@ pub mod qoi_lib {
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use std::error::Error;
|
/// # use std::error::Error;
|
||||||
/// # use crate::qoi::qoi_lib::*;
|
/// # use crate::qoi::qoi_lib::*;
|
||||||
/// # use log::*;
|
|
||||||
/// # fn main() -> Result<(), ImgError> {
|
/// # fn main() -> Result<(), ImgError> {
|
||||||
/// let level = LevelFilter::Debug;
|
/// match init() {
|
||||||
/// match init(level) {
|
|
||||||
/// Ok(()) => (),
|
/// Ok(()) => (),
|
||||||
/// Err(e) => println!("Logger failed to initialize!")
|
/// Err(e) => println!("Logger failed to initialize!")
|
||||||
/// }
|
/// }
|
||||||
@ -619,15 +615,12 @@ pub mod qoi_lib {
|
|||||||
}
|
}
|
||||||
/// Writes Image as byte vector to file with name given as string slice.
|
/// Writes Image as byte vector to file with name given as string slice.
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use qoi::qoi_lib::*;
|
/// use qoi::qoi_lib::*
|
||||||
/// # fn main() {
|
|
||||||
///
|
///
|
||||||
/// let bytes: Vec<u8> = vec![];
|
/// let img = Image::new();
|
||||||
|
/// let bytes: Vec<u8> = img.to_bytes();
|
||||||
/// let name = "qoi-image";
|
/// let name = "qoi-image";
|
||||||
/// write_to_file(bytes, name);
|
/// write_to_file(bytes, name);
|
||||||
/// #
|
|
||||||
/// #
|
|
||||||
/// # }
|
|
||||||
/// ```
|
/// ```
|
||||||
pub fn write_to_file(bytes: Vec<u8>, filename: &str) -> std::io::Result<()> {
|
pub fn write_to_file(bytes: Vec<u8>, filename: &str) -> std::io::Result<()> {
|
||||||
let mut file_path: String = String::from(filename);
|
let mut file_path: String = String::from(filename);
|
||||||
@ -876,7 +869,7 @@ pub mod qoi_lib {
|
|||||||
assert_eq!(pix3.diff(&pix4), (-5, -5, -5));
|
assert_eq!(pix3.diff(&pix4), (-5, -5, -5));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* #[test]
|
#[test]
|
||||||
fn qoi_to_qoi_test() -> io::Result<()> {
|
fn qoi_to_qoi_test() -> io::Result<()> {
|
||||||
//Open path to test images
|
//Open path to test images
|
||||||
let path: &Path = Path::new("./qoi_test_images/");
|
let path: &Path = Path::new("./qoi_test_images/");
|
||||||
@ -1004,7 +997,7 @@ pub mod qoi_lib {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tag_test() {
|
fn tag_test() {
|
||||||
//init().expect("Logger initialisation failed!");
|
//init().expect("Logger initialisation failed!");
|
||||||
|
27
src/main.rs
27
src/main.rs
@ -2,7 +2,6 @@
|
|||||||
use clap::{Args,Parser, Subcommand};
|
use clap::{Args,Parser, Subcommand};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, Read};
|
use std::io::{BufReader, Read};
|
||||||
use std::process;
|
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use colors_transform::{Color, Hsl, Rgb};
|
use colors_transform::{Color, Hsl, Rgb};
|
||||||
@ -101,11 +100,7 @@ fn demo() {
|
|||||||
fn encode(in_path: &str, out_path: &str) {
|
fn encode(in_path: &str, out_path: &str) {
|
||||||
|
|
||||||
//Init png decoder, attempt to decode png into bitmap, throw error if unsuccessful
|
//Init png decoder, attempt to decode png into bitmap, throw error if unsuccessful
|
||||||
let file:File = File::open(in_path).unwrap_or_else(|e| {
|
let decoder = png::Decoder::new(File::open(in_path).unwrap());
|
||||||
println!("Error: {:?}", e.to_string());
|
|
||||||
process::exit(1);
|
|
||||||
});
|
|
||||||
let decoder = png::Decoder::new(file);
|
|
||||||
let mut reader = match decoder.read_info() {
|
let mut reader = match decoder.read_info() {
|
||||||
Ok(reader) => reader,
|
Ok(reader) => reader,
|
||||||
Err(e) => panic!("ERROR: couldn't read file: {e:}"),
|
Err(e) => panic!("ERROR: couldn't read file: {e:}"),
|
||||||
@ -134,13 +129,7 @@ fn encode(in_path: &str, out_path: &str) {
|
|||||||
Err(err) => panic!("Problem generating image: {:?}", err),
|
Err(err) => panic!("Problem generating image: {:?}", err),
|
||||||
};
|
};
|
||||||
|
|
||||||
//in case out_path is erroneously passed with suffix
|
write_to_file(encode_from_image(img), out_path).expect("ERROR: Can't write file.");
|
||||||
let filename = match out_path.strip_suffix(".png") {
|
|
||||||
Some(s) => s,
|
|
||||||
None => out_path
|
|
||||||
};
|
|
||||||
|
|
||||||
write_to_file(encode_from_image(img), filename).expect("ERROR: Can't write file.");
|
|
||||||
info!("Encoding successful!");
|
info!("Encoding successful!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,9 +183,9 @@ fn bench(input: &str, output: Option<String>) {
|
|||||||
}
|
}
|
||||||
match decode(&out_path) {
|
match decode(&out_path) {
|
||||||
Ok(img) => {
|
Ok(img) => {
|
||||||
//Never fails as long as memory does not corrupt thanks to above push_str op.
|
|
||||||
let png_path = out_path.strip_suffix(".qoi").unwrap();
|
let out_buf = img.to_bytes();
|
||||||
img.write_png(&png_path);
|
let _ = write_to_file(out_buf, out_path.strip_suffix(".qoi").unwrap()).expect("whoops!");
|
||||||
},
|
},
|
||||||
Err(e) => panic!("Error: {e:?}")
|
Err(e) => panic!("Error: {e:?}")
|
||||||
}
|
}
|
||||||
@ -300,12 +289,8 @@ fn main() {
|
|||||||
Commands::Encode(args) => {
|
Commands::Encode(args) => {
|
||||||
let out_path = match &args.output {
|
let out_path = match &args.output {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => args.input.strip_suffix(".png").unwrap_or_else(||{
|
None => &args.input
|
||||||
println!("Error: Could not construct output arg from input arg. Please provide explicitly");
|
|
||||||
process::exit(1);
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
encode(&args.input, &out_path);
|
encode(&args.input, &out_path);
|
||||||
},
|
},
|
||||||
Commands::Demo { } => demo()
|
Commands::Demo { } => demo()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user