Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

ImageMagickObject Object


  • Please log in to reply
39 replies to this topic

#1 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 01 August 2010 - 06:12 PM

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:

AutoIt         
#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:

Spoiler

Usage Instructions:
1)
AutoItObject.au3 -- 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:

Spoiler


Edited by LaCastiglione, 04 May 2011 - 10:01 AM.








#2 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 5,991 posts

Posted 02 August 2010 - 10:41 PM

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.

Maybe I'm in love (Sshh, it's a secret)

.

 

eMyvnE


#3 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 03 August 2010 - 12:41 AM

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.

#4 AdmiralAlkex

AdmiralAlkex

    Here be dragons

  • Active Members
  • PipPipPipPipPipPip
  • 4,607 posts

Posted 03 August 2010 - 01:28 AM

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.

#5 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 03 August 2010 - 07:54 AM

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

Edited by jaberwocky6669, 03 August 2010 - 07:55 AM.


#6 ValeryVal

ValeryVal

    Dig the way

  • Active Members
  • PipPipPipPipPipPip
  • 442 posts

Posted 03 August 2010 - 02:25 PM

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:
The point of world view

#7 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 03 August 2010 - 07:40 PM

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?

#8 ValeryVal

ValeryVal

    Dig the way

  • Active Members
  • PipPipPipPipPipPip
  • 442 posts

Posted 03 August 2010 - 08:13 PM

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:
The point of world view

#9 Djarlo

Djarlo

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 14 August 2010 - 03:23 PM

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, 15 August 2010 - 01:58 AM.


#10 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 14 August 2010 - 04:04 PM

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!

#11 Djarlo

Djarlo

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 14 August 2010 - 04:34 PM

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, 14 August 2010 - 05:32 PM.


#12 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 14 August 2010 - 07:51 PM

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.

#13 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 21 August 2010 - 09:28 AM

Latest update brings several new functions to the table.

#14 Djarlo

Djarlo

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 23 August 2010 - 08:23 PM

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, 23 August 2010 - 08:52 PM.


#15 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 24 August 2010 - 07:23 AM

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, 24 August 2010 - 07:24 AM.


#16 Djarlo

Djarlo

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 25 August 2010 - 02:06 AM

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, 25 August 2010 - 06:04 AM.


#17 Djarlo

Djarlo

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 25 August 2010 - 03:28 AM

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, 25 August 2010 - 03:34 AM.


#18 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 26 August 2010 - 01:43 AM

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, 26 August 2010 - 01:44 AM.


#19 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 2,945 posts

Posted 27 September 2010 - 09:52 PM

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

#20 Werty

Werty

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 303 posts

Posted 27 September 2010 - 10:02 PM

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)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users