Resize .jpg in VB6

I am trying, using VB6, to resize and save a .jpg with the largest side being 150px.

It has been so long since I've used VB6 that I'm having trouble figuring out how to start?

I think I used to do this using a command line and Imagemagick.
hrolsonsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
Windows Image Acquisition Library 2.0 is your "friend"
Check this code
Public Function CreateThumbnail(inPath As String) As Variant
'ok a fully qualified path is passed in.
'lets resize this puppy and put it into the small folder
'you can clean up TempImages after


Dim img As WIA.ImageFile
Dim IP As ImageProcess

Set img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
IP.Filters.Add IP.FilterInfos("Scale").FilterID
            
img.LoadFile inPath

IP.Filters(1).Properties("MaximumWidth") = 160
IP.Filters(1).Properties("MaximumHeight") = img.Height / img.Width * 160

Set img = IP.Apply(img)
CreateThumbnail = img.FileData.BinaryData



End Function

Open in new window

I use it like this
rsImages.Fields("thumbnail") = CreateThumbnail(.SelectedItems(1))

Open in new window

hrolsonsAuthor Commented:
So I used your function like this:

x = CreateThumbnail("c:\temp\temp.jpg")

It ran, but I can't find the thumbnail it created.
John TsioumprisSoftware & Systems EngineerCommented:
Put a breakpoint to see what you might missing...did you forgot to reference the library ?
Clipboard01.jpg
Ensure Business Longevity with As-A-Service

Using the as-a-service approach for your business model allows you to grow your revenue stream with new practice areas, without forcing you to part ways with existing clients just because they don’t fit the mold of your new service offerings.

hrolsonsAuthor Commented:
Yes, I included the reference.  The code all runs without error, it's just I don't know where the thumbnail is.
John TsioumprisSoftware & Systems EngineerCommented:
Just put a breakpoint on the
CreateThumbnail = img.FileData.BinaryData

Open in new window

Essentially the whole process takes place in memory ....in my code it is stored to recordset...if you want to output it to a file you have to use ADODB stream.
Martin LissOlder than dirtCommented:
It seems to be putting it into the recordset. rsImages. What do you do with that recordset?
John TsioumprisSoftware & Systems EngineerCommented:
Check this code
Public Function CreateThumbnail(inPath As String)
Dim stream As New ADODB.stream
Dim img As WIA.ImageFile
Dim IP As ImageProcess

Set img = CreateObject("WIA.ImageFile")
Set IP = CreateObject("WIA.ImageProcess")
IP.Filters.Add IP.FilterInfos("Scale").FilterID
            
img.LoadFile inPath

IP.Filters(1).Properties("MaximumWidth") = 160
IP.Filters(1).Properties("MaximumHeight") = img.Height / img.Width * 160

Set img = IP.Apply(img)


stream.Open
stream.Type = adTypeBinary
stream.Write img.FileData.BinaryData
stream.SaveToFile "D:\Share\small.jpg", adSaveCreateNotExist
stream.Close
End Function

Open in new window

I had to recreate it from scratch ...i really need to restore my old work.... :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hrolsonsAuthor Commented:
Thank you so much!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.