SmiLe Posted February 2, 2007 Share Posted February 2, 2007 Hi all!I am looking for a way to manipulate Jpeg images with AutoIt scripts (at least drawing text, resizing and sharpening if possible).IMHO the cxImage and FreeImage libraries are not very well documented for someone who has no C/C++ skills, so I started Googleing and I found a free COM wrapper for GD library. Being able to do the same as PHP scripts would be great.I tried to write a small test script but I can't figure out how to save the created image to a .jpg file... CODE;; Copy bgd.dll and GDLibrary.dll in @SystemDir (see http://www.codeproject.com/asp/GDLibraryWrapper.asp); Register GDLibrary wrapper (regsvr32.exe GDLibrary.dll);$gdImage = ObjCreate("GDLibrary.gdImage")If IsObj($gdImage) Then $gdImage.Create(500, 500) $gdImage.ColorAllocate(255, 255, 255) $Blue = $gdImage.ColorAllocate(0, 0, 255) $gdImage.Rectangle(3, 15, 390, 440, $Blue) $TextColor = $gdImage.ColorAllocate(233, 114, 191); $gdImage.Chars($gdImage.FontGetLarge(), 5, 5, "Hello World!", $TextColor) ; ; Now how can I save this image to a JPEG file? ;Else MsgBox(0, "Error", "Failed to create object!")EndIfAny help would be greatly appreciated. Thank you! Link to comment Share on other sites More sharing options...
Will66 Posted February 2, 2007 Share Posted February 2, 2007 http://www.autoitscript.com/forum/index.ph...mp;#entry298211CXImageAlt.dll is activex wrapper, can do resize and sharpen, not sure about how to use the create functions. Link to comment Share on other sites More sharing options...
Will66 Posted February 2, 2007 Share Posted February 2, 2007 (edited) quick look in oleview.exe reveals: SaveToFile( [in, out] BSTR* FileName, [in, out, optional, defaultvalue(1)] SaveOptionsEnum* Options); $gdImage.SaveToFile("c:\somewhere\test.jpg") ; ?? not tried Edited February 2, 2007 by Will66 Link to comment Share on other sites More sharing options...
/dev/null Posted February 2, 2007 Share Posted February 2, 2007 $gdImage.Chars($gdImage.FontGetLarge(), 5, 5, "Hello World!", $TextColor) ; ; Now how can I save this image to a JPEG file? ;have you tried $gdImage.jpeg("C:\test.jpg") ?? __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
SmiLe Posted February 2, 2007 Author Share Posted February 2, 2007 http://www.autoitscript.com/forum/index.ph...mp;#entry298211CXImageAlt.dll is activex wrapper, can do resize and sharpen, not sure about how to use the create functions.Thank you for your reply Will66. I read your topic and tried your interesting example script before posting. But I didn't find how to call other cxImage functions, for instance cxImage.DrawString(). So I was looking for an easiest library...(Sorry for my bad English, it is not my native language) Link to comment Share on other sites More sharing options...
/dev/null Posted February 2, 2007 Share Posted February 2, 2007 have you tried $gdImage.jpeg("C:\test.jpg") ??a quick look at the sources, reveals it's SaveToFile (as Will66 said). You don't need any options. The file name extension specifies the image type. Known types: gif,png,jpg,jpeg,bmp,gd __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
SmiLe Posted February 2, 2007 Author Share Posted February 2, 2007 @ /dev/null:Yes I tried $gdImage.jpeg() but it doesn't work (error: The requested action with this object has failed).@ Will66:Well done! $gdImage.SaveToFile("c:\somewhere\test.jpg") is perfect. Thanks a lot!!! Link to comment Share on other sites More sharing options...
Will66 Posted February 2, 2007 Share Posted February 2, 2007 heres another one in the comments section:http://www.codeproject.com/asp/GDLibraryWrapper.asp?df=100&forumid=181887&select=1131470#xx1131470xx Link to comment Share on other sites More sharing options...
SmiLe Posted February 2, 2007 Author Share Posted February 2, 2007 I have been experimenting with the GDLibrary.dll wrapper. Unfortunately the usual GD lib functions doesn't seem to work.For example, $gdImage.CreateFromJpeg("C:\myfile.jpg") is supposed to open an existing Jpeg file... Wrong! The GDLibrary.dll syntax is: $gdImage.LoadFromFile("C:\myfile.jpg").More annoying, there is no way to specify Jpeg quality with $gdImage.SaveToFile("C:\myfile.jpg"). I opened a 200K image, draw "Hello World!" then save it as a new Jpeg image. The resulting file size is 700K! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now