From 9ae77ba7babef497424e57c0ab3da31d0d92d513 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 9 Sep 2026 08:47:23 -0700 Subject: [PATCH] Migrate legacy tensorflow image png decoder to memory-safe pixel_bridge. PiperOrigin-RevId: 978573777 --- pixel_bridge/rust/image.rs | 2 ++ pixel_bridge/rust/reader.rs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pixel_bridge/rust/image.rs b/pixel_bridge/rust/image.rs index 4d64124..b62c201 100644 --- a/pixel_bridge/rust/image.rs +++ b/pixel_bridge/rust/image.rs @@ -163,6 +163,7 @@ pub enum PixelType { F32, } +#[doc(hidden)] impl From for PixelType { fn from(value: RustColorType) -> Self { match value { @@ -204,6 +205,7 @@ pub struct Strides { pub channels: usize, } +#[doc(hidden)] impl From for ColorType { fn from(value: RustColorType) -> Self { match value { diff --git a/pixel_bridge/rust/reader.rs b/pixel_bridge/rust/reader.rs index dbdb698..1d18b16 100644 --- a/pixel_bridge/rust/reader.rs +++ b/pixel_bridge/rust/reader.rs @@ -48,9 +48,9 @@ pub enum Format { Ico, } -impl From for ImageFormat { - fn from(value: Format) -> ImageFormat { - match value { +impl Format { + fn to_image_format(self) -> ImageFormat { + match self { Format::Png => ImageFormat::Png, Format::Jpeg => ImageFormat::Jpeg, Format::Gif => ImageFormat::Gif, @@ -96,7 +96,7 @@ impl ImageReader { let Some(ref mut inner) = self.inner else { return; }; - inner.set_format(format.into()) + inner.set_format(format.to_image_format()) } /// Read the image.