Results 1 to 17 of 17

Thread: BMP TO JPEG Convert Automatic

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
    11,074

    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 only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    Re: BMP TO JPEG Convert Automatic

    @jmsrickland

    Thats great thanks for your help!!

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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
    9,145

    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
    24,482

    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,887

    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
    9,145

    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
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    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
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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

    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
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: BMP TO JPEG Convert Automatic

    What did i say differently?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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

    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
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
    Hyperactive Member
    Join Date
    Jul 2012
    Location
    Essex
    Posts
    273

    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
  •  



Click Here to Expand Forum to Full Width