BMP TO JPEG Convert Automatic-VBForums
Results 1 to 17 of 17

Thread: BMP TO JPEG Convert Automatic

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    BMP TO JPEG Convert Automatic

    Hi All

    I would like to convert BMP files to JPEG files in with no user active automatic
    so it scans the a folder for bmp files and convert them to jpg and then delete the bmp files
    deleting is the easy bit.

    I have looked at other post that uses dll's and cannot get them to work not sure if becuase i am using
    windows 7 to run them or if there is away with out using plug-ins

    Kind regards

    Steve

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,886

    Re: BMP TO JPEG Convert Automatic

    GDI+ has the function you need to convert BMP to JPG. I include a zip file with a VB project to use GDI+ to convert any format to any format (well not all formats but some)
    Attached Files Attached Files


    Anything I post is an example for demonstration purposes only and is not intended to be the solution to your request nor do I claim that it is. If you find that it is useful then it is entirely up to you to make whatever necessary changes you feel are adequate for your purposes.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    @jmsrickland

    Thats great thanks for your help!!

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,012

    Re: BMP TO JPEG Convert Automatic

    This is actually far easier to do.

    Windows has had a library for this for quite some time. It didn't come along in final form until after XP SP2, so you have to install it into XP but modern versions of Windows include it

    Code:
        Dim ImgF As WIA.ImageFile
        Dim ImgP As WIA.ImageProcess
        
        Set ImgF = New WIA.ImageFile
        ImgF.LoadFile "Zapotec.bmp"
        Set ImgP = New WIA.ImageProcess
        With ImgP
            .Filters.Add .FilterInfos!Convert.FilterID
            .Filters.Item(1).Properties!FormatID.Value = wiaFormatJPEG
            .Filters.Item(1).Properties!Quality.Value = 70
            Set ImgF = .Apply(ImgF)
        End With
        ImgF.SaveFile "Zapotec.jpg"
    There are several filters for scaling, cropping, stamping, and dealing with EXIF data and such in addition to simply doing format conversions.

    Unlike API calls this can be used from VBScript as well.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,560

    Re: BMP TO JPEG Convert Automatic

    @diletantte....what is the library that contains your "WIA"? Guessing I have to reference it.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,012

    Re: BMP TO JPEG Convert Automatic

    It is called Microsoft Windows Image Acquisition Library v2.0 (wiaaut.dll).

    The documentation is contained in the Windows SDK documentation. For some reason most VB programmers never bother to download and install SDKs though.

    You can find the "web installer" there or read the fine print for a link to the ISO image (note: I added that link here). You normally only want the x86 SDK for VB6 development even if you are using 64-bit Windows.

    You can also use the Vista SDK docs if you have those installed since Win7 didn't change much anyway, being a minor update.
    Last edited by dilettante; Oct 21st, 2012 at 08:08 PM.

  7. #7
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,499

    Re: BMP TO JPEG Convert Automatic

    it is nice to use a simpler method...but i also think learning GDI+ is a good idea
    Last edited by Max187Boucher; Oct 21st, 2012 at 08:10 PM.

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,560

    Re: BMP TO JPEG Convert Automatic

    I got a LOT to learn, and GDI+ as well as SDKs are just the tip of the iceberg....thanks to all for guidance/links. TIME TIME TIME....I just wish I had the TIME.....!

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    Hi all

    Thanks for more tips on diffent ways of doing it
    I would like to include *.bmp and subfolders search
    To convert all to JPEG with wildcard *.jpeg

    Regards
    Steve

  10. #10
    Fanatic Member
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    967

    Re: BMP TO JPEG Convert Automatic

    Use the Dir-Function recursively with the *.bmp-Wildcard (you have to check if there are subfolders), and for every BMP-Filename returned replace the bmp-extension with jpeg, do your conversion, save it with the new jpeg-name
    For health reasons i try to avoid reading unformatted Code

  11. #11
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,512

    Re: BMP TO JPEG Convert Automatic

    Quote Originally Posted by jmsrickland View Post
    GDI+ has the function you need to convert BMP to JPG. I include a zip file with a VB project to use GDI+ to convert any format to any format (well not all formats but some)
    Nice. Regardless of whether it's any practical use, can formats other than bmp be taken as input?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    @Zvoni

    Thing is I dont want to rename the jpeg file it needs to be the same name has the bmp name only the extension to change

    regards
    steve

  13. #13
    Fanatic Member
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    967

    Re: BMP TO JPEG Convert Automatic

    What did i say differently?
    For health reasons i try to avoid reading unformatted Code

  14. #14
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,560

    Re: BMP TO JPEG Convert Automatic

    Did you read post #2? Works GREAT....(and shows you that renaming the 'file' as xxxx.bmp to xxxx.jpg is what post #10 actually said....you can just change the xxxx's)

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    Sorry mis-understood this bit "save it with the new jpeg-name"

    My mistake sorry

    Regards
    Steve

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    @Zoni

    sorry bit confused on this could you please give me sample of code for Dir-Function recursively and where i would put the conversion bit of code thanks

    @SamOscarBrown I have tried post 2 it works great for changing xxx.bmp to xxx.jpg
    Regards

    Steve
    Last edited by sbarber007; Oct 22nd, 2012 at 01:57 PM.

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    159

    Re: BMP TO JPEG Convert Automatic

    Hi All
    can anyone help me with bit more info with post 10
    regards
    steve
    Last edited by sbarber007; Oct 23rd, 2012 at 11:29 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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.