Results 1 to 3 of 3

Thread: Convert image files to JPG format BY WIA

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,622

    Resolved Convert image files to JPG format BY WIA

    Code:
    Function WiaSaveAsJpg(LoadFile1 As String, SaveJpgFile As String, Optional JpgQuality As Long = 85, Optional ErrInfo As String) As Boolean
     
    On Error GoTo Err1
    Dim Img 'As ImageFile
    Dim IP 'As ImageProcess
    
    Set Img = CreateObject("WIA.ImageFile")
    Set IP = CreateObject("WIA.ImageProcess")
    Img.LoadFile LoadFile1
    
    IP.Filters.Add IP.FilterInfos("Convert").FilterID
    IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
    IP.Filters(1).Properties("Quality").Value = JpgQuality
    
    Set Img = IP.Apply(Img)
    Img.SaveFile SaveJpgFile
    WiaSaveAsJpg = True
    Exit Function
    Err1:
    ErrInfo = Err.Number & "," & Err.Description
    End Function

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,622

    Re: Convert image files to JPG format BY WIA

    Img.LoadFile

    Is there a way to unload the file? How to continuously process the task of converting different images hundreds or thousands of times without closing the object after it is created?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,622

    Re: Convert image files to JPG format BY WIA

    Set image DPI--save picturebox as jpg(GdipCreateBitmapFromHBITMAP)-VBForums
    https://www.vbforums.com/showthread....%26%2365289%3B

    Convert image files to JPG ,Which is faster, wia or gdiplus?

    This is my test result (may be inaccurate, just for reference):


    GDIPLUS and WIA convert PNG to JPG file (SIZE:6MB ,3840*2160)
    GDIPLUS, WIA
    The first time, two sets of tests: 175.6,206//175.5, 244.4
    The second time, two sets of tests: 175.54,189.36//175.17,190
    The third time, 2 sets of tests: 176.23,187//176,190 milliseconds
    GDIPLUS is 7-8.5% faster than WIA
    --------------------
    Convert BMP to jpg, test 3 times (a total of 6 bmp files, Hard disk space occupied by each image 31.6 mb)
    81.07, 212 //
    79.4,105.67
    80,106
    Test results, GDIPLUS is 33% faster than WIA
    Last edited by xiaoyao; Sep 5th, 2021 at 06:23 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width