Jump to content

Creating and manipulating images...


SmiLe
 Share

Recommended Posts

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!")

EndIf

Any help would be greatly appreciated. Thank you!

Link to comment
Share on other sites

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 by Will66
Link to comment
Share on other sites

$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

http://www.autoitscript.com/forum/index.ph...mp;#entry298211

CXImageAlt.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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...