How can I modify the EXIF orientation tag of an image?

145

Solution 1

You can retrieve the existing orientation information via exiftool as follows:

exiftool -Orientation -n image.jpg

This will display the internal value of the orientation information held in the MIE tags. You can return the value as an English string by omitting the -n flag. You can find additional information here regarding particular rotation/orientation values.

Changing the orientation data with exiftool can be done as follows:

exiftool -Orientation=1 -n image.jpg

Here, the orientation is set to 1, indicating no rotation. These numbers are defined as per the EXIF specification; you can see what effect different rotation values have in the link above.

(note: you must use the -n argument when setting orientation to indicate that the value is numeric. If you forget, exiftool will interpret the orientation=x number as a string and set the wrong rotation ie. exiftool -orientation=1 image.jpg will actually set the orientation to 3 which is 'Rotate 180')

Solution 2

My solution was the same as @Breakthrough, but I had to put the -n before -Orientation, such as

exiftool -n -Orientation=1 image.jpg

Share:
145

Related videos on Youtube

A. Savva
Author by

A. Savva

Updated on September 18, 2022

Comments

  • A. Savva
    A. Savva over 1 year

    I am uploading programmatically a report on the server through the use of rs.exe and a visual basic file. When the user views the report, the server asks for credentials to log in to the Data Source.

    Credentials prompt

    Now, when I upload a report through Visual Studio, there is an option to use specific credentials that you can pre-set so the user is not prompted. I also notice that there is a setting in the report where you can define credentials.

    Credentials settings

    My question is, how do I enable the use of specific data source credentials on uploading the report with Visual Basic so the user is not prompted for the data source credentials?

    My VB code:

    Public Sub Main()
        Try
            Dim definition As [Byte]() = Nothing
            Dim warnings As Warning() = Nothing
            Dim stream As FileStream = File.OpenRead(RDL_LOCATION)
    
            definition = New [Byte](stream.Length) {}
            stream.Read(definition, 0, CInt(stream.Length))
            warnings = rs.CreateReport(REPORT_NAME, "/" + REPORT_FOLDER, True, definition, Nothing)
            If Not (warnings Is Nothing) Then
                Dim warning As Warning
                For Each warning In warnings
                    Console.WriteLine(warning.Message)
                Next warning
            Else
                AddPolicies("/" + REPORT_FOLDER + "/" + REPORT_NAME, "False")
                Console.WriteLine("Report: {0} PUBLISHED!", REPORT_NAME)
            End If
        Catch e As IOException
            Console.WriteLine(e.Message)
            Console.Read()
        End Try
    End Sub