Traditionally, images are displayed in the orientation in which they are stored. It is possible to mark an image to be displayed in a different orientation by using the EXIF Orientation tag. Some web browsers and image software will automatically adjust the display based on this tag, while others will not. This can lead to compatibility problems. For example, Google Chrome will display the image in the orientation specified by the EXIF tag but Internet Explorer will ignore the tag.
We have a code snippet showing how to read the Orientation tag and rotate and/or flip the image to get it into the correct orientation, and then the EXIF data can be safely removed.
Set Image = Server.CreateObject("csImageFile64.Manage")
Image.ReadFile "C:\path\to\image.jpg"
Select Case Image.ExifValueByName("Orientation")
Case "1" : 'Do nothing
Case "2" : Image.FlipY
Case "3" : Image.Rotate 180
Case "4" : Image.FlipX
Case "5" : Image.Rotate 90
Image.FlipX
Case "6" : Image.Rotate -90
Case "7" : Image.FlipY
Image.Rotate -90
Case "8" : Image.Rotate 90
End Select
Image.ExifClear
There are eight possible values for the orientation representing the the four rotations, each of which can be mirrored. The default is 1, which matches the pixel scanlines.
This code shows the EXIF block being deleted after adjusting the orientation. Other options would be to set the Orientation tag to 1 or to delete the tag. EXIF data can be bulky and it the target is to reduce the file size, using ExifClear may be better.
© Chestysoft, 2024.
This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.