imazen / imageflow-dotnet

The official .NET API for Imageflow, the Rust image processing and optimization engine for web servers
GNU Affero General Public License v3.0
143 stars 25 forks source link

Extracting raw pixel data from transformed images? #43

Closed tpst closed 7 months ago

tpst commented 2 years ago

Hello, I really like the library. I'm trying it out primarily for image resizing for DICOM files, where I am mostly manipulating the raw pixel values. In this case, there is a fair bit of overhead as the steps i'm taking are:

  1. raw pixel data to a bitmap, then bitmap to stream
  2. decode the stream
  3. apply resizer command
  4. encode to bytes

At which point, if I need the raw pixel values again, i'm left trying to manually decode the pixel values from the image byte array.

Is there a way to easily extract these from the finished image job, or better yet, manipulate a pixel array directly without encoding to a particular image type?

Thanks

lilith commented 2 years ago

I assume you're encoding to lossless PNG or WebP?

I've considered adding an uncompressed bitmap format for cases like this to speed load/saves; essentially raw pixel data in a stream. The challenge is that there are endless raw pixel data formats. What is yours?

tpst commented 2 years ago

I assume you're encoding to lossless PNG or WebP

Yes thats right, I have used LodePngEncoder.

I'm not too familiar with all the different raw pixel formats you mentioned. I am primarily working with a 2D or 1D row-wise array of 16 bit greyscale colour values.

lilith commented 2 years ago

Imageflow is really focused on the web, specifically RGBA. For 16-bit grayscale you'll end up going down to 8-bit during encode/decode, which may or may not be ok with you.