Git Product home page Git Product logo

Comments (5)

saucecontrol avatar saucecontrol commented on May 30, 2024

Howdy!

I've got that information available within the pipeline, but it's not presently exposed in the API because it's mostly an implementation detail and may change during processing. Can you elaborate a bit on what you might use it for?

In practice, the input bpp won't necessarily have any relation to the output bpp, and if your output is a compressed format, bpp may not have any real meaning at all. If, for example, you start with an 80bpp CMYK image, that will be converted within the pipeline to a 24bpp BGR format, and if your output is JPEG, that will involve another conversion to Y'CbCr within the encoder. And Y'CbCr JPEGs can be chroma-subsampled, so the true uncompressed bpp might be 12, 16, or 24 depending on subsampling.

Things are different if you're consuming the IPixelSource created by MagicImageProcessor.BuildPipeline since you need to know the exact data layout of that pixel data in order to use it. For that case, the IPixelSource does expose its pixel format, which is always one of: 8bpp greyscale, 24bpp BGR, or 32bpp BGRA. I'm working now on adding some explicit conversion transforms so that you can switch between those formats, but it will still be limited to those 3.

from photosauce.

wahmedswl avatar wahmedswl commented on May 30, 2024

Thanks for your quick response. We are migrating from Leadtools, so during save we can configure BPP, so is there anyway BPP can be set.

We are migrating due to speed, and we use 24 BPP and if its default then simple

MagicImageProcessor.ProcessImage is sufficient.

Thanks

from photosauce.

saucecontrol avatar saucecontrol commented on May 30, 2024

Ah, I think I understand. Right now, the input format does partially drive the output format. If your input has transparency (you can check this with the ImageFileInfo HasAlpha property), your output will also have an alpha channel if the save format supports it. It should be that setting an opaque MatteColor will change the output to RGB/BGR (dropping the alpha channel), but that is not currently the case. I plan to have that fixed for the next version.

If you need control to explcitly set the output to one of the 3 formats I listed above, that will be possible in the next version as well. I'm getting close to having that release ready. Probably just another week or two.

from photosauce.

wahmedswl avatar wahmedswl commented on May 30, 2024

that would be great, thanks :-)

from photosauce.

saucecontrol avatar saucecontrol commented on May 30, 2024

I've added a couple of things in v0.9.0:

  1. If you use a MatteColor that is opaque, the output will be 24bpp BGR even if the input was RGBA/BGRA.
  2. If you need to ensure a specific format regardless of input, you can use a custom pipeline and the FormatConversionTransform filter. It would go something like this:
var settings = new ProcessImageSettings { Width = 400, SaveFormat = FileFormat.Png };
string inimg = @"c:\img\greyscale.jpg";
string outimg = @"c:\img\rgb.png";
using (var pipeline = MagicImageProcessor.BuildPipeline(inimg, settings))
{
    pipeline.AddTransform(new FormatConversionTransform(PixelFormats.Bgr24bpp));

    using (var fs = new FileStream(outimg, FileMode.Create))
        pipeline.ExecutePipeline(fs);
}

from photosauce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.