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

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -