saucecontrol / PhotoSauce

MagicScaler high-performance, high-quality image processing pipeline for .NET
http://photosauce.net/
MIT License
569 stars 49 forks source link

Orientation is not rotating properly #115

Closed rohank05 closed 1 year ago

rohank05 commented 1 year ago

So I am using orientation to rotate the image. I am using 90 to rotate but sometimes it is rotating 180 sometimes it is rotating 270 sometimes it doesn't even rotate

if (angle < 0) { angle = 360 - angle; } switch (angle) { case 90: var orientation = Orientation.Rotate90; transforms.Add(new OrientationTransform(orientation)); break; case 180: orientation = Orientation.Rotate180; transforms.Add(new OrientationTransform(orientation)); break; case 270: orientation = Orientation.Rotate270; transforms.Add(new OrientationTransform(orientation)); break; default: throw new ArgumentException("Only 90/180/270 degree rotation is supported"); }

using (var pl = MagicImageProcessor.BuildPipeline(sourceStream, settings)) { foreach (var transform in transforms) { pl.AddTransform(transform); } pl.WriteOutput(stream); }

saucecontrol commented 1 year ago

Do you have a complete repro you can share, along with input image?

My guess is you've got input images that have orientation metadata embedded, which will be auto-corrected when using the default OrientationMode setting. This correction is applied as part of the base pipeline, before any additional orientation steps you add.