c# - ImageProcessor seems to rotate image 90 degrees after resizing -
i downloaded imageprocessor library using nuget c#. using upload , resize image website. upload process works fine except, when try view uploaded image appears backward rotated 90 original image. here code using:
isupportedimageformat format = new jpegformat { quality = 70 }; using (memorystream instream = new memorystream(_img)) { using (memorystream outstream = new memorystream()) { // initialize imagefactory using overload preserve exif metadata. using (imagefactory imagefactory = new imagefactory(preserveexifdata: false)) { // load, resize, set format , quality , save image. imagefactory.load(instream) .resize(new resizelayer(new size(width, height), resizemode: resizemode)) .format(format) .save(outstream); } return outstream.toarray(); } }
if not preserving exif metadata imagefactory class has method autorotate
alter image compensate original orientation.
http://imageprocessor.org/imageprocessor/imagefactory/autorotate/
your new code follows.
isupportedimageformat format = new jpegformat { quality = 70 }; using (memorystream instream = new memorystream(_img)) { using (memorystream outstream = new memorystream()) { // initialize imagefactory using overload preserve exif metadata. using (imagefactory imagefactory = new imagefactory(preserveexifdata: false)) { // load, resize, set format , quality , save image. imagefactory.load(instream) .autorotate() .resize(new resizelayer(new size(width, height), resizemode: resizemode)) .format(format) .save(outstream); } return outstream.toarray(); } }
Comments
Post a Comment