This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

How do I change the Dpi of an image without loading a bitmap?

Hello,
to process a large image I need to use a pipeline. The Dpi can only be set for a bitmap or an imagegenerator.

I came up with the following so far:
using (var reader = ImageReader.Create(@"..\largeinput.tif")
using (var generator = new ImageGenerator(reader, RgbColor.White)
using (var combiner = new Combiner(CombineMode.AlphaOverlay, reader))
using (var writer = new TiffWriter(@"..\output.tif");)
{
    generator.DpiX = 123;
    generator.DpiY = 123;
    Pipeline.Run(generator + combiner + writer);
}


The use of an imagegenerator also implies the use of a backgroundcolor, which I have to get from the readers bitmap again (because of
bitmap.ColorManagement.BackgroundColor;
beeing the only source of a background color).
I wonder wether there is a easier way to assign Dpi. 🤔
You can use the ResolutionModifier class to change resolution:

using (var reader = ImageReader.Create(@"..\largeinput.tif"))
using (var resolutionModifier = new ResolutionModifier(123, 123))
using (var writer = new TiffWriter(@"..\output.tif"))
{
	Pipeline.Run(reader+ resolutionModifier + writer);
}
🤦 Thanks, that does it. I totally didn't fint that one between the rest.