Sign in to follow this  
Followers 0

ImageMagickObject Object

40 posts in this topic

Posted (edited)

ImageMagickObject Object

Description:

ImageMagickObject Object allows you to quickly and easily use ImageMagick in your AutoIt scripts. If you're used to using objects in your scripts/programs then you can easily pick up on using ImageMagickObject Object. For those of you new to objects then I will provide a small usage example here. A more comprehensive example is included in the zip folder. As of now a lot of functionality could be added to the UDF, however, that could take a while so I decided to release early and often. Please inform me of any bugs that you encounter.

Example:

#include "AutoItObject.au3"
#include "ImageMagickObject Object.au3"

; directories
Global Const $testImage = @ScriptDir & "\Test Images\Image4.jpg"
Global Const $DestinationDir = @ScriptDir & "\Pictures\"

_AutoItObject_Startup()

Global $ImageMagick = ImageMagickObject()

$ImageMagick.Startup()

$ImageMagick.Paint($testImage, $DestinationDir & "Paint.jpg", 1.5) ; Makes your image look like an oil painting.

$ImageMagick.Resize($testImage, $DestinationDir & "Resize400.jpg", 400)

$ImageMagick.Shutdown()

$ImageMagick = 0

_AutoItObject_Shutdown()

Current functions:

AdaptiveBlur

AdaptiveResize

AdaptiveSharpen

Annotate

Append

AutoGamma

AutoLevel

AutoOrient

BlackThreshold

BlueShift

Blur

Brightness

Charcoal

ClipBoard

CMYKColorize

Comment

Contrast

Crop

Decipher

Directory

Encipher

Extension

FileName

Filesize

Height

ImageInfo

Implode

ListTypes

Manual

Modulate

Monochrome

Name

Negate

Normalize

PageGeometry

Paint

Resize

Rotate

Spread

StartUp

Thumbnail

Width

Usage Instructions:

1) -- because I think AutoItObject is a great way to structure UDFs!

2) Download the latest ImageMagick binary from: (ImageMagick-#.#.#-#-Q16-windows-static). Install ImageMagick and be sure to choose: "Install ImageMagickObject OLE control for VBScript ..." Confirmed working on 6.6.6.9!

3) Zip Folder -- contains the proper directory structure, five test images, and other required files. After you have unzipped the zip folder to your desired directory then create two au3 files named "ImageMagickObject Object.au3" and "Example.au3" in that same directory. Copy the code from this page into "ImageMagickObject Object.au3". Next, copy the code from this page into the "example.au3".

Updates:

[stardate: 11-24-2010] -- Captain's Log -- works now, thank you trancexx and Werty!

[update: 10-05-2010]

[update: 09-27-2010] -- New functions and bug fixes all across the board.

[update: 09-01-2010] -- Bug fixes, particularly to the "Append" method.

[update: 08-21-2010] -- More functions added.

[update: 08-03-2010] -- More functions.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites



Posted

Cool.

You have my vote. ;)

Btw, I'm on x64 system and it always take half an hour for me to realize that's the reason this kind of stuff doesn't work for me for that half an hour. :blink:

You could start your script by adding the check of @AutoItX64 and notification of incompatibility when that is in fact the case.

Share this post


Link to post
Share on other sites

Posted

Cool.

You have my vote. ;)

Btw, I'm on x64 system and it always take half an hour for me to realize that's the reason this kind of stuff doesn't work for me for that half an hour. :blink:

You could start your script by adding the check of @AutoItX64 and notification of incompatibility when that is in fact the case.

Thank you TranceXX. I appreciate that. I apologize that you spent a half an hour on this. As for an x64 system. My system is 64 too but it works for me. How should this be so? I also have AutoIt set up to use the 32 bit version automatically.

Share this post


Link to post
Share on other sites

Posted

Many people (including me and probably trancexx) have their x64 systems set to run x64 AutoIt by default. It's much handier if most of your scripts work in x64 as you can easily change with #AutoIt3Wrapper_UseX64 what to use from SciTE.

Share this post


Link to post
Share on other sites

Posted (edited)

But can't 32 bit scripts run on x64 machines?

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Posted

Thank you.

Do you know that your scripts are working with ImageMagickObject.dll from

GraphicsMagick, too?

BTW. Binary package of GraphicsMagick is just about 5 Mb.

:blink:

Share this post


Link to post
Share on other sites

Posted

Thank you.

Do you know that your scripts are working with ImageMagickObject.dll from

GraphicsMagick, too?

BTW. Binary package of GraphicsMagick is just about 5 Mb.

:blink:

Nice, I think I'll make the switch!

So you had no problems with my script?

Share this post


Link to post
Share on other sites

Posted

So you had no problems with my script?

I'm not Tony Hayward and your script isn't oil spill in gulf of Mexico, I think.

:blink:

Share this post


Link to post
Share on other sites

Posted (edited)

Funny how Google only showed me this just after i spend days on getting this to work ;)

I found all newer versions of imagemagick to have a whole lot of glitches in it, while the really old ones worked great.

Thank you Valery for your GraphicsMagick tip :P that makes quite a diffrence using 369KB dll from GraphicsMagick opposed to the 6,08MB dll from Imagemagick.

It does makes one wonder though, with such an extreme difference in filesize if there arent some more limitations in the GraphicsMagick's one. especially concidering its a derivation of Imagemagick.

I havent installed the GraphicsMagick nor the Imagemagick, ive only registered the dll included in GraphicsMagick and everything seems to work fine so far.

Anyways ill have a look at your scripts now ;) and see how that works :) thanks

Edited by Hellstrong

Share this post


Link to post
Share on other sites

Posted

I've been thinking about including the DLL for some time now but I never get around to it because I never finish anything I start. I did try the GraphicksMagick dll and though some things that didn't work in ImageMagick worked in GraphicksMagick there were things that didn't work that worked in ImageMagick. Go figure!

Share this post


Link to post
Share on other sites

Posted (edited)

I've been thinking about including the DLL for some time now but I never get around to it because I never finish anything I start. I did try the GraphicksMagick dll and though some things that didn't work in ImageMagick worked in GraphicksMagick there were things that didn't work that worked in ImageMagick. Go figure!

hmm intresting, give it a ry with this version of imagemagick, i have a feeling everything will work on that one :)

So far it did for me at least.

I hope i can use graphicmagick for the app im working on though. ;)

PS: anyone looked into the ffmpeg.dll or sharpFFMPEG.dll ? having a hard time finding info on that. and using the EXE's makes screenrecording go to slow

EDIT: i found out i cant register the dll outside the install dir, unless the other files are present too, so its dependent on some of the other stuff in there unlike the Imagemagick dll, that explains the extreme file size differences, im gonna have to figure out what files it uses, and see how big the total file size will be.

EDIT 2: you need all the DLL's of graphicmagic to include it into your program, witch adds a 7,99 MB filesize.. while using Imagemagic you just have a single file of 6 MB.

So i think its deffinatly worth it to stick with Imagemagick unless theres some things not working.

Edited by Hellstrong

Share this post


Link to post
Share on other sites

Posted

So i think its deffinatly worth it to stick with Imagemagick unless theres some things not working.

Dangit, just as I made some headway into converting this over to graphicsmagick, lulz, it's cool, I keep revisions on Google Code.

Share this post


Link to post
Share on other sites

Posted

Latest update brings several new functions to the table.

Share this post


Link to post
Share on other sites

Posted (edited)

Latest update brings several new functions to the table.

Thanks jaberwocky6669 your work has been extremely educating to me.

This might be a real stupid question... i know wat "Const" does. but what does it do in the function parameters?

Func IM_AdaptiveBlur($This, Const $Image, Const $Dest, Const $Radius, Const $Sigma = 1)
Edited by Hellstrong

Share this post


Link to post
Share on other sites

Posted (edited)

Thanks jaberwocky6669 your work has been extremely educating to me.

This might be a real stupid question... i know wat "Const" does. but what does it do in the function parameters?

Func IM_AdaptiveBlur($This, Const $Image, Const $Dest, Const $Radius, Const $Sigma = 1)

Declaring a function parameter Const tells whoever uses that function that whatever arguments they pass will not be changed. I think it has something to do with maintaining state. I'm trying to learn software development as well as scripting so I may be wrong. Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Posted (edited)

Declaring a function parameter Const tells whoever uses that function that whatever arguments they pass will not be changed. I think it has something to do with maintaining state. I'm trying to learn software development as well as scripting so I may be wrong.

thanks, that makes sense and very usefull ;)

Back on topic.

I was making a small app for personal use to have my textures colored using a CMYK color model.

So theres 2 things i looked at:

-colorize value

But it only uses CMY (cyan, magenta, yellow) and doesnt have a black key

Then theres

-modulate brightness[,saturation,hue]

Witch could be used to get a CMYK output, but it handles the image in a different way so you'll get a similar but different (undesirable) effect.

So the key to get the effect desired is using both of them, witch is also the power of imagemagick combining stuff.

We need the colorize value changed and use the brightness value as black-key.

Heres a simplyfied part of my script on how to clorize using CMYK values.

$Cyan=100
$Magenta=100
$Yellow=0
$brightness=60
$saturation=100
$ImageMagick.Convert( _
                "ImageIn.jpg", _
                "-colorize", $Cyan & "," & $Magenta & "," & $Yellow, _
                "-modulate", $brightness&","&$saturation, _
                "ImageOut.jpg")

Now the thing is, it has to be done in 1 conversion only like above.1st changing the saturation and then converting it again changing the colorize command, gives a total different effect.

How would we do this using your UDF?

[Edit]

I was kinda wrong

It just didn't work right cause of the order to convert in, although theres a small diffrence in color doing it in 2 exports so its still desirable.

$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
IM_CMYKcolorize("white.jpg", "white_converted.jpg", 0, 57, 57, 39)

Func IM_CMYKcolorize(Const $ImageIn, Const $ImageOut, Const $Cyan, Const $Magenta, Const $Yellow, Const $black = 0, Const $saturation = 100)
    $ImageMagick.Convert( _
            $ImageIn, _
            "-colorize", $Cyan & "," & $Magenta & "," & $Yellow, _
            $ImageOut)
    $ImageMagick.Convert( _
            $ImageOut, _
            "-modulate", 100 - $black & "," & $saturation, _ ;<== we invert the brightness as it will be used as black-key instead
            $ImageOut)
EndFunc   ;==>IM_CMYKcolorize
Edited by Hellstrong

Share this post


Link to post
Share on other sites

Posted (edited)

Heres a Visual:

CMYK color model in GIMP:

Posted Image

My Functions Input > Output

Posted Image > Posted Image

My Function:

$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
IM_CMYKcolorize("white.jpg", "white_converted.jpg", 0, 57, 57, 39)

Func IM_CMYKcolorize(Const $ImageIn, Const $ImageOut, Const $Cyan, Const $Magenta, Const $Yellow, Const $black = 0, Const $saturation = 100)
    $ImageMagick.Convert( _
            $ImageIn, _
            "-colorize", $Cyan & "," & $Magenta & "," & $Yellow, _
            "-modulate", 100 - $black & "," & $saturation, _ ;<== we invert the brightness as it will be used as black-key instead
            $ImageOut)
EndFunc   ;==>IM_CMYKcolorize
Edited by Hellstrong

Share this post


Link to post
Share on other sites

Posted (edited)

I guess I don't understand, did you find the solution? What exactly do you want to do? Give me a step by step of what you're doing. If possible gim'me some code.

Btw, you don't have to do this:

$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")

You simply do this:

Global $ImageMagick = ImageMagickObject()

; thsi is the same as: "$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")"
$ImageMagick.Startup(True)

; do your image processing here...

;don't forget to shut everything down:
$ImageMagick.ShutDown() ; nighty night

Also, consider making a thread for this in the helpsection so we don't flood this forum.

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Posted

Latest udate sees a couple of new functions brought aboard and the sailor's quarters have been fumigated.

Share this post


Link to post
Share on other sites

Posted

Btw, you don't have to do this:

$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")

You simply do this:

Global $ImageMagick = ImageMagickObject()

; thsi is the same as: "$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")"
$ImageMagick.Startup(True)

; do your image processing here...

;don't forget to shut everything down:
$ImageMagick.ShutDown() ; nighty night

What is the difference between those methods, you saying "you dont have to do this" sounds like it's bad.

(I'm using the first method myself currently, but if it's better to use the other)

Share this post


Link to post
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
Sign in to follow this  
Followers 0