refactor: improve logging
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 1m43s
CI / Build Linux (push) Successful in 1m56s
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 1m43s
CI / Build Linux (push) Successful in 1m56s
This commit is contained in:
+27
-5
@@ -20,6 +20,12 @@ use std::path::Path;
|
||||
pub struct PluginImpl;
|
||||
|
||||
impl Plugin for PluginImpl {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn is_available(&self) -> bool {
|
||||
tracing::trace!("Checking availability for jpeg_to_png plugin (always true)");
|
||||
true
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"jpeg_to_png"
|
||||
}
|
||||
@@ -39,6 +45,7 @@ impl Plugin for PluginImpl {
|
||||
200
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, input, _temp_dir))]
|
||||
fn convert(
|
||||
&self,
|
||||
input: &[u8],
|
||||
@@ -46,11 +53,26 @@ impl Plugin for PluginImpl {
|
||||
_to: &str,
|
||||
_temp_dir: &Path,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
tracing::debug!("jpeg_to_png starting conversion");
|
||||
tracing::trace!("Loading JPEG image from memory ({} bytes)", input.len());
|
||||
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)
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to decode JPEG image: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
|
||||
tracing::trace!("JPEG image loaded successfully. Dimensions: {}x{}", img.width(), img.height());
|
||||
|
||||
let mut output = Cursor::new(Vec::new());
|
||||
tracing::trace!("Encoding image as PNG");
|
||||
img.write_to(&mut output, ImageFormat::Png)
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to encode image as PNG: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
|
||||
let out_bytes = output.into_inner();
|
||||
tracing::debug!("jpeg_to_png conversion completed. Output size: {} bytes", out_bytes.len());
|
||||
Ok(out_bytes)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user