Help with properly closing files after processing

Discussions about image processing and document imaging.
Post Reply
trekr
Posts: 3
Joined: Wed Jan 23, 2008 9:04 am

Help with properly closing files after processing

Post by trekr » Wed Jan 23, 2008 9:14 am

The following macro runs fine, but from the memory usage meter for my computer the macro appears to not be closing/releasing the memory after processing. I'm clearly new at this so I'm hoping that someone will be able to tell me exactly what I need to do to close these files.

On a separate note, is there any other option that would approximate the "autolevel" fix performed in Photoshop? I was pointed to SetEqualizeIntensityEffect, but this doesn't really seem to do what I'm looking for. When I use this on a photo that has a green tint, the green becomes much more pronounced after this effect is applied. Decreasing the saturation seems to look closer to what I'm trying to accomplish, but it varies of course with the quality of the original photo. Color isn't important, ie black and white or grayscale will work fine for my purposes. Any help is appreciated.

Code: Select all

'sImagepath = InputBox("Please input the image file path e.g. c:\image1.jpg")
Set ogdpicture = CreateObject("gdpicturepro4.imaging")
ogdpicture.SetLicenseNumber ("XXXX") 'Demo code version
ogdpicture.CreateImageFromFile (simagepath)
ogdpicture.SetContrastEffect (30)
'oGdPicture.SetEqualizeIntensityEffect
ogdpicture.SetSaturationEffect (-100)
ogdpicture.SaveAsPdf ("C::\Users\A.pdf")
ogdpicture.CloseNativeImage
'ogdpicture.CloseImage ("C:\Users\A.jpg")
'MsgBox "Save c:\image.pdf completed"

clocklear
Posts: 16
Joined: Fri Jan 11, 2008 11:04 pm

Re: Help with properly closing files after processing

Post by clocklear » Thu Jan 24, 2008 2:48 pm

Sounds like you aren't properly releasing the image handle for each image. CreateImageFromFile returns the image handle of the newly created image, and you pass this to the CloseImage method like this:

Code: Select all

'sImagepath = InputBox("Please input the image file path e.g. c:\image1.jpg")
Set ogdpicture = CreateObject("gdpicturepro4.imaging")
ogdpicture.SetLicenseNumber ("XXXX") 'Demo code version
Set lnHandle = ogdpicture.CreateImageFromFile (simagepath)
ogdpicture.SetContrastEffect (30)
'oGdPicture.SetEqualizeIntensityEffect
ogdpicture.SetSaturationEffect (-100)
ogdpicture.SaveAsPdf ("C::\Users\A.pdf")
ogdpicture.CloseNativeImage
'ogdpicture.CloseImage (lnHandle)
'MsgBox "Save c:\image.pdf completed"
I'm afraid I can't help much with your other problem.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests