Release / check-release (push) Successful in 15s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m31s
CI / Build Linux (push) Successful in 1m47s
57 lines
1.6 KiB
Rust
57 lines
1.6 KiB
Rust
// Copyright (C) 2026 Elias Wendland <eliaswendland@pm.me>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, version 3 exclusively.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
use crate::plugin::Plugin;
|
|
use image::ImageFormat;
|
|
use std::io::Cursor;
|
|
use std::path::Path;
|
|
|
|
pub struct PluginImpl;
|
|
|
|
impl Plugin for PluginImpl {
|
|
fn name(&self) -> &'static str {
|
|
"jpeg_to_png"
|
|
}
|
|
fn from_formats(&self) -> Vec<&'static str> {
|
|
vec!["jpeg"]
|
|
}
|
|
fn to_formats(&self) -> Vec<&'static str> {
|
|
vec!["png"]
|
|
}
|
|
fn familiarity(&self, _from: &str, _to: &str) -> u8 {
|
|
255
|
|
}
|
|
fn quality(&self, _from: &str, _to: &str) -> u8 {
|
|
255
|
|
}
|
|
fn speed(&self, _from: &str, _to: &str) -> u8 {
|
|
200
|
|
}
|
|
|
|
fn convert(
|
|
&self,
|
|
input: &[u8],
|
|
_from: &str,
|
|
_to: &str,
|
|
_temp_dir: &Path,
|
|
) -> Result<Vec<u8>, String> {
|
|
let img = image::load_from_memory_with_format(input, ImageFormat::Jpeg)
|
|
.map_err(|e| e.to_string())?;
|
|
let mut buf = Vec::new();
|
|
img.write_to(&mut Cursor::new(&mut buf), ImageFormat::Png)
|
|
.map_err(|e| e.to_string())?;
|
|
Ok(buf)
|
|
}
|
|
}
|