Comments (5)
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.
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.
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.
that would be great, thanks :-)
from photosauce.
I've added a couple of things in v0.9.0:
- If you use a
MatteColor
that is opaque, the output will be 24bpp BGR even if the input was RGBA/BGRA. - 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)
- Orientation is not rotating properly HOT 1
- System.Runtime.InteropServices.COMException at PhotoSauce.MagicScaler.WicPlanarCache.loadBuffer
- Problem with certain PNG images HOT 8
- Transparent Color on PadTransform HOT 1
- RobiniaDocs API Explorer
- Update libwebp HOT 4
- Option to retain gif loop count when resizing HOT 6
- Could not load type 'PhotoSauce.MagicScaler.Converters.ChannelChanger`1' HOT 8
- ColorMatrixTransform does not unpremultiply/premultiply HOT 1
- Default JPEG encoding options are not publicly accessible HOT 4
- EncoderInfo not set correctly if output to Stream
- MagicScalar Linux issue
- libpng throws bad adaptive filter will abort writing result HOT 3
- libpng fails to convert several files that WIC can handle HOT 2
- `ArgumentOutOfRangeException` reading JPEG XL image from their test page HOT 3
- After update the solution to .NET 8 version the NativeCodecs dependency started to fail HOT 3
- Noob question: Having a hard time understanding the native codec binary build steps.
- How to gain best possible quality, disregard performance.
- IMultiFrameDecoderOptions support missing for JPEG XL HOT 1
- Decoder FrameRange validation is not valid HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photosauce.