Photo rotates when attached (1 Viewer)

SetanPutih

Registered User
Joined
Jun 27, 2019
Messages
27
Hi guys,

Some help would be much appreciated. I've created a database containing client details. Amongst the client details is a photo of the client attached. Why does Access sometimes rotate the photo? How do i prevent this from happening so that all photos appear as portrait?

Thanks
 

vba_php

Custom Title Here
Joined
Oct 6, 2019
Messages
2,081
Setan,

I think I remember this happening to me once or twice, but I can't remember under what circumstances. It might be an access bug (which isn't surprising) but might not be. I can't help regarding what happened in my case because I can't remember the details, but it seems as though there might be a couple of answers here:

https://www.google.com/search?q=ms+access+photo+rotated+when+inserted
 

theDBguy

I’m here to help
Joined
Oct 29, 2018
Messages
7,845
Hi guys,

Some help would be much appreciated. I've created a database containing client details. Amongst the client details is a photo of the client attached. Why does Access sometimes rotate the photo? How do i prevent this from happening so that all photos appear as portrait?

Thanks
Hi. You'll have to explain how you're doing this, because I just gave it a try, and I didn't get this problem. The photo showed up on my form right side up. Maybe I didn't do it the same way you did it.
 

Micron

AWF VIP
Joined
Oct 20, 2018
Messages
1,798
In one recent application I included code to automatically rotate the image by 90 degrees to fix it
I have done that as well. However, I can say the choice to rotate a photo can be misguided, depending on what you use to make that decision. Short explanation is that Windows Explorer will often misrepresent the orientation of an image if it has undergone such processing elsewhere. You think it is portrait but it is in fact landscape. Simply rebuild the icon cache before making a decision. That can be done by changing from icon to list view and back again. That came to me after several hours of trying to figure out why my rotating code caused images to be mis-oriented.
 

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,365
I also knew that 'trick'.
However it didn't solve the issue for me which is why I used code.

Rotating each image using code worked perfectly for portrait images.
Landscape images need a further button click to display correctly.
 

Attachments

Micron

AWF VIP
Joined
Oct 20, 2018
Messages
1,798
I don't understand what the picture represents or what rebuilding the icon cache didn't solve if that's what you mean by "trick". Maybe we had 2 different issues.

I'd alter an image orientation and then the db would show me something else. I might have made that decision based on Explorer or PS. I'd look at it in PS and wonder what the heck was going on after using Explorer to rotate. Or I'd make the change in PS and look at it in Windows and say "what the heck?" again. Maybe I'd alter it again (which might only make matters worse) or just look at it in the db. Drove me nuts until I figured out what the problem was, which was exacerbated by doing batch edits.
Landscape images need a further button click to display correctly.
Not sure what you mean by that either. Perhaps you're referring to doing it in stages. I passed the degree value to my function (90, 180, 270) and just did it once.
 

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,365
Hi Micron
Only just noticed your reply.
You were quite right to question my previous post which makes little sense as written. That's what happens when typing posts very late at night.

I was trying to say the following:
I have often experienced rotation when using digital photos from my phone or camera in Access.
Typically I find unmodified images are rotated by 90 degrees anticlockwise.
However modifying e.g. the orientation from portrait to landscape can cause a 180 degree rotation
Rebuilding the icon cache doesn't solve the issue in my experience.

Hence in more than one app I added code to automatically rotate photos 90 degrees clockwise.
Where further 90 degree rotation is needed the user can do this with a button click

The app in my earlier link includes the code which was taken from Daniel Pineault's devhut.net website:

Code:
Option Compare Database
Option Explicit

' Procedure : WIA_RotateImage
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Roate an image by a designated number of degrees using WIA
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
'             (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: Uses Late Binding, so none required
'
' Windows Image Acquisition (WIA)
'             https://msdn.microsoft.com/en-us/library/windows/desktop/ms630368(v=vs.85).aspx
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sInitialImage : Fully qualified path and filename of the original image to resize
' sOutputImage  : Fully qualified path and filename of where to save the new image
' lRotAng       : Number of degree to roate the image
'
' Usage:
' ~~~~~~
' Call WIA_RotateImage("C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg", _
'                      "C:\Users\MyUser\Desktop\Chrysanthemum_small.jpg", _
'                      90)
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **********************************************************
' 1         2017-01-18              Initial Release
' 2         2018-09-20              Updated Copyright
'--------------------------------------------------------------------------

Public Function WIA_RotateImage(sInitialImage As String, _
                                sOutputImage As String, _
                                lRotAng As Long) As Boolean
    On Error GoTo Error_Handler
    Dim oWIA                  As Object    'WIA.ImageFile
    Dim oIP                   As Object    'ImageProcess
 
    'Should check if the output file already exists and if so,
    'prompt the user to overwrite it or not
 
    Set oWIA = CreateObject("WIA.ImageFile")
    Set oIP = CreateObject("WIA.ImageProcess")
 
    oIP.filters.Add oIP.FilterInfos("RotateFlip").FilterID
    oIP.filters(1).Properties("RotationAngle") = lRotAng
 
    oWIA.LoadFile sInitialImage
    Set oWIA = oIP.Apply(oWIA)
    oWIA.SaveFile sOutputImage
    WIA_RotateImage = True
 
Error_Handler_Exit:
    On Error Resume Next
    If Not oIP Is Nothing Then Set oIP = Nothing
    If Not oWIA Is Nothing Then Set oWIA = Nothing
    Exit Function
 
Error_Handler:
    MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: WIA_RotateImage" & vbCrLf & _
           "Error Description: " & Err.description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occurred!"
    Resume Error_Handler_Exit
End Function
Hope that makes a bit more sense now ...but if not just ignore the post
 

MickJav

AWF VIP
Joined
Nov 28, 2005
Messages
1,278
What I do is edit the image in the default image editor I just rotate it a total of 360 then save it then go back to your program and update the picture this can be by moving to another record or closing the screen.
NOTE: You can write some vba code to update the image.


NOTE: Using the code to rotate an image in access will also update the original so if you have to rotate the image 90 should you need to view the image in windows it will be rotated 90 so what may look right in access will look wrong everywhere else.
 
Last edited:

isladogs

CID Moderator
Staff member
Joined
Jan 14, 2017
Messages
12,365
What I do is edit the image in the default image editor I just rotate it a total of 360 then save it then go back to your program and update the picture this can be by moving to another record or closing the screen.
NOTE: You can write some vba code to update the image.

NOTE: Using the code to rotate an image in access will also update the original so if you have to rotate the image 90 should you need to view the image in windows it will be rotated 90 so what may look right in access will look wrong everywhere else.
The code I use does NOT affect the original image so it doesn't affect how it looks in other programs
 

MickJav

AWF VIP
Joined
Nov 28, 2005
Messages
1,278
The code I use does NOT affect the original image so it doesn't affect how it looks in other programs
Sorry I was talking in general you can do what you do as your program only deals with one image which from the sound of it would work in this instance.

Mick
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom