Advanced Image Manipulation

Status
Not open for further replies.

treva26

Registered User.
Local time
Today, 15:09
Joined
Sep 19, 2007
Messages
113
This code uses the LaunchApp32 function to silently run an image manipulation program called IrfanView (freeware). A copy of this program must be available to the database.

The attached database includes a form that allows you to do LOTS of cool things to images, without visibly leaving the database.

I used this to enable automatic and silent cropping and resizing of personnel photos for an HR database.

See Irfanview's help file - Command Line Arguments for a full list of options.

The basic code is as follows:

Code:
'Put at the top of the module
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal _
     dwAccess As Long, ByVal fInherit As Integer, ByVal hObject _
     As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
      hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
      hObject As Long) As Long


Function LaunchApp32(MYAppname As String) As Integer
 Const SYNCHRONIZE = 1048576
 Const INFINITE = -1&
 Dim ProcessID&
 Dim ProcessHandle&
 Dim Ret&
 LaunchApp32 = -1
 ProcessID = Shell(MYAppname, vbNormalFocus)
   If ProcessID <> 0 Then
       ProcessHandle = OpenProcess(SYNCHRONIZE, True, ProcessID&)
       Ret = WaitForSingleObject(ProcessHandle, INFINITE)
       Ret = CloseHandle(ProcessHandle)
   Else
        MsgBox "ERROR : Unable to start " & MYAppname
        LaunchApp32 = 0
   End If
End Function


sub flipH() ' This will flip the image
Irfan1 = "C:\Program Files\IrfanView\i_view32.exe"
Temppic2 = ""C:\Documents and Settings\tlancaster\My Documents\image1.jpg"
Compression0 = 75
stAppName = Irfan1 & " " & Temppic2
stAppName = stAppName & " /hflip " & " /jpgq=" & Compression0 & " /convert=" & Temppic2
LaunchApp32 (stAppName)
end sub
 

Attachments

It would be nice to be able to select an area with the mouse to crop...
But I imagine that would be rather complicated!
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom