Coder Social home page Coder Social logo

Exif rotation and save about imagesharp HOT 4 CLOSED

bertasoft avatar bertasoft commented on June 24, 2024
Exif rotation and save

from imagesharp.

Comments (4)

JimBobSquarePants avatar JimBobSquarePants commented on June 24, 2024

Iā€™m not sure what you are expecting here. The image was rotated to match the exif orientation.

from imagesharp.

bertasoft avatar bertasoft commented on June 24, 2024

I'm expected that the rotated is like this

Rotated

from imagesharp.

JimBobSquarePants avatar JimBobSquarePants commented on June 24, 2024

That's an incorrect assumption. AutoOrient update the orientation of the image to match the EXIF metadata properties and removes those properties from the metadata.

As you can see on your breakpoints. The input image has physical dimensions of 1536x2048 (portrait) but is displayed rotated 90degrees (landscape). Once processed the image pixels are 2048x1536 which matches the landscape display orientation of the input.

from imagesharp.

bertasoft avatar bertasoft commented on June 24, 2024

Ok, how can I have the rotated version of the image like my example?

Something that follow the exif infos and give me the jpg rotated, any c# code example?

Now i'm using something like this

private const int exifOrientationID = 0x112; //274

public static void ExifRotate(this Image img)
{
if (!img.PropertyIdList.Contains(exifOrientationID))
return;

var prop = img.GetPropertyItem(exifOrientationID);
int val = BitConverter.ToUInt16(prop.Value, 0);
var rot = RotateFlipType.RotateNoneFlipNone;

if (val == 3 || val == 4)
    rot = RotateFlipType.Rotate180FlipNone;
else if (val == 5 || val == 6)
    rot = RotateFlipType.Rotate90FlipNone;
else if (val == 7 || val == 8)
    rot = RotateFlipType.Rotate270FlipNone;

if (val == 2 || val == 4 || val == 5 || val == 7)
    rot |= RotateFlipType.RotateNoneFlipX;

if (rot != RotateFlipType.RotateNoneFlipNone)
{
    img.RotateFlip(rot);
    img.RemovePropertyItem(exifOrientationID);
}

}

Thanks for clarification,

from imagesharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.