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
1 Attachment(s)
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)
Re: BMP TO JPEG Convert Automatic
@jmsrickland
Thats great thanks for your help!!
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.
Re: BMP TO JPEG Convert Automatic
@diletantte....what is the library that contains your "WIA"? Guessing I have to reference it.
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.
Re: BMP TO JPEG Convert Automatic
it is nice to use a simpler method...but i also think learning GDI+ is a good idea
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.....!
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
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
Re: BMP TO JPEG Convert Automatic
Quote:
Originally Posted by
jmsrickland
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?
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
Re: BMP TO JPEG Convert Automatic
What did i say differently? :confused:
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)
Re: BMP TO JPEG Convert Automatic
Sorry mis-understood this bit "save it with the new jpeg-name"
My mistake sorry
Regards
Steve
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
Re: BMP TO JPEG Convert Automatic
Hi All
can anyone help me with bit more info with post 10
regards
steve