jaberwacky Posted September 27, 2010 Author Share Posted September 27, 2010 (edited) ... What is the difference between those methods ... Oh, my terseness came across as condenscension. My apologies. The reason to use the second method is because of error checking and because the ImageMagickObject DLL is registered too. Also, if the user desires then he or she may also register a COM error handler just by passing a True statement as the $ErrorHandler argument and vice versa. expandcollapse popup; this function creates an instance of ImageMagick after it registers the DLL Func IM_StartUp($This, Const $ErrorHandler = True) Switch $This.Register() Case 0 $This.IMObj = ObjCreate("ImageMagickObject.MagickImage.1") Switch IsObj($This.IMObj) Case 1 If $ErrorHandler Then $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Return $This.IMObj Case 0 Return SetError(1, 0, -2) EndSwitch Case 1 Return SetError(1, 0, -1) EndSwitch EndFunc ;==>IM_StartUp ; this function does the registering. Func Im_RegisterImageMagickObjectDll($This) Local Const $IMDLL = @ScriptDir & "\ImageMagickObject.dll" Switch FileExists($IMDLL) Case 1 Local Const $CheckErr = RunWait(@ComSpec & " /c /s /i RegSvr32 " & $IMDLL, '', @SW_HIDE) ; I and many others have had much trouble with this particular line. Switch $CheckErr Case 0 Return SetError(-2, 0, 1) Case Else Return 0 EndSwitch Case 0 Return SetError(-1, 0, 1) Case "hungryhungryhippos" ; this is a testament to all of the *facepalms* endured whilst debugging this particular function. Return SetError(-3, 0, 1) EndSwitch EndFunc ;==>Im_RegisterImageMagickObjectDll Edited September 27, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Carlo84 Posted October 5, 2010 Share Posted October 5, 2010 You can get the DLL down to 1,53MB if you run UPX over it UPX --best --compress-exports=0 "ImageMagickObject.dll" -o "Outputfile.dll" I been using it for a while this way, and had no noticable performance/speed differences. Anyways, im having a problem with the List functions, they just get written to the Scite output frame, instead of being returned as a string. _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
jaberwacky Posted October 5, 2010 Author Share Posted October 5, 2010 (edited) You can get the DLL down to 1,53MB if you run UPX over it UPX --best --compress-exports=0 "ImageMagickObject.dll" -o "Outputfile.dll" I been using it for a while this way, and had no noticable performance/speed differences. Anyways, im having a problem with the List functions, they just get written to the Scite output frame, instead of being returned as a string. That's really awesome! I suspect that there are some problems getting the dll registered on other systems. Maybe I don't know what I'm doing -- could be, maybe? Nah, I know everything about everything. lulz I'll definately look into for my next update, coming shortly btw. List functions: you're referring to Height, Width, Extension, etc? Edited October 5, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Carlo84 Posted October 5, 2010 Share Posted October 5, 2010 (edited) That's really awesome! I suspect that there are some problems getting the dll registered on other systems. Maybe I don't know what I'm doing -- could be, maybe? Nah, I know everything about everything. lulz no, no troubles registering, works fine on XP, Vista and Win7. Here i uploaded a 1,53mb version ImageMagickObject.dll List functions: you're referring to Height, Width, Extension, etc? This: $test = $ImageMagick.List("Font") MsgBox(64, "Available fonts.", $test) The function doesnt actually return anything, its just being written in the output frame. Edited October 7, 2010 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
jaberwacky Posted October 5, 2010 Author Share Posted October 5, 2010 Here's what I'm thinking, I can't capture SciTE's console output. I have to find a way to capture the console output of ImageMagick's convert.exe. I'll look into doing that and I hope that it won't be a hack or anything. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Carlo84 Posted October 5, 2010 Share Posted October 5, 2010 (edited) Here's what I'm thinking, I can't capture SciTE's console output. I have to find a way to capture the console output of ImageMagick's convert.exe. I'll look into doing that and I hope that it won't be a hack or anything. If SciTE can capture it then our scripts should be able to capture it as well. After all its output coming from our script. Also i know there are some apps that you cannot capture its output from (Like UPX.exe) if you run them from a bat file. $test=$ImageMagick.List("Font") Exit running it compiled trough a batfile however does normally catches the output of the dll. MyScript.exe > test.txt In the ImageMagick Helpfile under the -metric option. Output to STDERR a measure of the differences between images according to the type given metric. So i guess either StderrRead() or ConsoleRead() should work somehow to read from your own process. Should work when @compiled anyways. [EDIT] http://www.autoitscript.com/forum/index.php?showtopic=52396 Edited October 6, 2010 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
trancexx Posted November 24, 2010 Share Posted November 24, 2010 (edited) jaberwocky6669, there is a function in AutoItObject (1.2.0.0 and above) that allows you not to have to register COM server and still be able to use objects within. Meaning even though there are some nice lines inside them (funny guy you are) you don't need IM_RegisterImageMagickObjectDll and IM_UnregisterImageMagickObjectDll functions nor any kind of process elevation for scripts to work as intended. IM_StartUp() could then be: Func IM_StartUp($This, Const $ErrorHandler = True) Local Const $CheckError = 0;$This.Register() ;<-!!! Local $Return Switch $CheckError Case 0 ;~ $This.IMObj = ObjCreate("ImageMagickObject.MagickImage.1") ;<-!!! $This.IMObj = _AutoItObject_ObjCreateEx("ImageMagickObject.dll", "{5630BE5A-3F5F-4BCA-A511-AD6A6386CAC1}") ;<-!!! Switch IsObj($This.IMObj) Case 1 If $ErrorHandler Then $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $Return = $This.IMObj Case 0 $Return = SetError(-1, 0, 1) EndSwitch Case 1 $Return = SetError(-2, 0, 1) EndSwitch Return $Return EndFunc ;==>IM_StartUp Edited November 24, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) jaberwocky6669, there is a function in AutoItObject (1.2.0.0 and above) that allows you not to have to register COM server and still be able to use objects within. Meaning even though there are some nice lines inside them (funny guy you are) you don't need IM_RegisterImageMagickObjectDll and IM_UnregisterImageMagickObjectDll functions nor any kind of process elevation for scripts to work as intended.YES! This might just mean that I can resume development! That's awesome, awesome gal you are. All hail!Edit:That is amazing! Will you marry me? Refer to original post for the latest update! Edited November 24, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
trancexx Posted November 24, 2010 Share Posted November 24, 2010 (edited) Depends how loaded you are.If I may add another suggestion or two regarding the code...It would be better to add another private property to $This (.DLL for example) and define ImageMagickObject function like this:Func ImageMagickObject($sImageMagickDLL = "ImageMagickObject.dll") ;... _AutoItObject_AddProperty($This, "DLL", $ELSCOPE_PRIVATE, FileGetShortName($sImageMagickDLL)) ;... EndFuncAnd in IM_StartUp have:$This.IMObj = _AutoItObject_ObjCreateEx($This.DLL, "{5630BE5A-3F5F-4BCA-A511-AD6A6386CAC1}")Then person using it can easily use dll in different location by specifying it when creating the object if necessary.Another thing is _AutoItObject_Class() function. Object creation is faster with it, and you can use With... EndWith to have aditionaly shorter/faster code.Local $oClass = _AutoItObject_Class() With $oClass .AddProperty("DLL", $ELSCOPE_PRIVATE, FileGetShortName($sImageMagickDLL)) .AddProperty("IMObj", $ELSCOPE_PRIVATE) .AddProperty("GravityList", $ELSCOPE_PRIVATE, $GravityList) ;... EndWith Return $oClass.ObjectThat's it. Edited November 24, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jaberwacky Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) I don't get your first suggestion. And I'll see about putting your second suggestion to practice. Edit: Ok, 2nd suggestion is in place. I have no way of measuring the speed but I'll take you at your word. Edited November 24, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Werty Posted November 24, 2010 Share Posted November 24, 2010 (edited) Here's what I'm thinking, I can't capture SciTE's console output. I have to find a way to capture the console output of ImageMagick's convert.exe. I'll look into doing that and I hope that it won't be a hack or anything. Dunno if this is what you mean, but outputting as info: does something like that... $img = ObjCreate("ImageMagickObject.MagickImage.1") $msgs = $img.Convert("image.jpg","info:") MsgBox (0, "info: ", $msgs) Here using the -format option... $img = ObjCreate("ImageMagickObject.MagickImage.1") ; filename, filesize, width, height $msgs = $img.Convert("image.jpg","-format","%f,%b,%w,%h","info:") MsgBox (0, "info: ", $msgs) Then stringsplit the result, or take them one at a time. List of -format operators... http://www.imagemagick.org/script/escape.php /edit Using -: instead of info: appears to only output to the variable, not to the scite console... $img = ObjCreate("ImageMagickObject.MagickImage.1") ; filename, filesize, width, height $msgs = $img.Convert("image.jpg","-format","%f,%b,%w,%h","-:") MsgBox (0, "info: ", $msgs) Edited November 24, 2010 by Werty Some guy's script +Â some other guy's script =Â my script! Link to comment Share on other sites More sharing options...
jaberwacky Posted November 24, 2010 Author Share Posted November 24, 2010 Using -: instead of info: appears to only output to the variable, not to the scite console... $img = ObjCreate("ImageMagickObject.MagickImage.1") ; filename, filesize, width, height $msgs = $img.Convert("image.jpg","-format","%f,%b,%w,%h","-:") MsgBox (0, "info: ", $msgs) FANTASTIC! That's exactly what meant. Thanks Werty! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Werty Posted November 28, 2010 Share Posted November 28, 2010 FANTASTIC! Would be more fantastic if we could get it to work with images also, as in Blobs :/ I found a workaround though... $img.Convert("image.jpg","clipboard:") LOOK MOM, NO FILEWRITES... #include <GDIPlus.au3> #include <ClipBoard.au3> $gui = GUICreate("blobtest", 640, 480) GUISetState() $img = ObjCreate("ImageMagickObject.MagickImage.1") $img.Convert("logo:","clipboard:") For $loop = 1 to 10 _ClipBoard_Open(WinGetHandle(AutoItWinGetTitle())) $image = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() _GDIPlus_Startup() $hbitmap = _GDIPlus_BitmapCreateFromHBITMAP($image) $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImage($hgraphic, $hbitmap, 0, 0) _GDIPlus_Shutdown() $img.Convert("clipboard:","-implode",$loop,"clipboard:") Sleep(100) Next But PLEASE let me know asap if you discover the "right way" to do it, I'll keep trying also. :/ Some guy's script +Â some other guy's script =Â my script! Link to comment Share on other sites More sharing options...
jaberwacky Posted November 28, 2010 Author Share Posted November 28, 2010 "right way"Ha. Well, it works so I guess that's "right" enough!So, what could we use this for? I guess, for quickly displaying the effects of a convert operation without saving it to disk? You seem to know a lot more about this stuff than me. I'm just stumbling around in the dark here. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Werty Posted November 30, 2010 Share Posted November 30, 2010 So, what could we use this for? I guess, for quickly displaying the effects of a convert operation without saving it to disk? Yes, for example, or for speech recognition. (I may get back to this later just an idea i have)Currently I need it for a project which requires between 50 and 1000 screenshots, average 600, and do stuff to them which require 5 file saves (1.5mb each) per screenshot, that's 3000 filewrites totalling 3.5GB, which I would really like to get done in-memory instead. As you know, IM is so much more than just converting from one format to another, you can draw, manipulate, animate, put text, cool graphics popping up, and alot more, f.eks, the FX options have some cool math functions you could use, like feeding the IM convert with some plain text only, have it do the maths, and return the result to your $var, hence using IM for something that has nothing to do with images.It's really cool if you take the time to read up on it.But again, having the images in a $var instead of using the clipboard would be easier, and better ofcourse, not having to pipe it through clipboard first. Some guy's script +Â some other guy's script =Â my script! Link to comment Share on other sites More sharing options...
jaberwacky Posted December 1, 2010 Author Share Posted December 1, 2010 (edited) "not having to pipe it through clipboard first."For that you could use the Display option I think. No, nevermind, won't work without cygwin or something.I think it's awesome that you can use IM for non image things. When you said speech recognition at first I thought you accidentally posted in the wrong forum! Well, has my UDF suited your purposes so far? If not then let's discuss what could be different. Edited December 4, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Thingy2nl Posted March 5, 2013 Share Posted March 5, 2013 I see that this a a somewhat older post, but I'm wondering, is the ImageMagickObject UDF still being used/maintained? I spend the last two days trying to get the dropshadow function added to the UDF... tried all sorts of combinations of commands like: $this.IMObj.Convert($image, _ ' " ', _ " ( ", _ "+clone", _ "-background", "yellow", _ "-shadow", "60x5+50+50", _ " ) ", _ "+swap", _ "-background", "white", _ "-layers", "merge", _ "+repage",' " ', $dest) All i want it to do is "convert _DSC0001rz.jpg ( +clone -background yellow -shadow 60x5+50+50 ) +swap -background white -layers merge +repage _DSC0001sh.jpg" but all al get is a large yellow shadow on a white background (yellow so i see what i'm doing...). The image is completely missing..... Started by copying the Func IM_Resize($This, Const $image, Const $dest, Const $resize) to Func IM_Shadow($This, Const $image, Const $dest) and takeing it from there.... but for th life of me i cant get it to work.... Or would it be possible to get this function correctly added to the udf by someone who knows what they are doing? Link to comment Share on other sites More sharing options...
jaberwacky Posted March 5, 2013 Author Share Posted March 5, 2013 Are you initializing the object? I will look into adding this back if I can. I stopped working on it because I couldn't get ImageMagick to work correctly with it for some reason that is beyond me. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Thingy2nl Posted March 5, 2013 Share Posted March 5, 2013 The UDF itself is working perfectly. I use the resize option with some regulairity. It's just that now I need to convert a Nikon NEF to JPG, resize, add a border and dropshadow and then add the resulting jpg to a pdf.... Allmost all is working apart from the dropshadow. Would be great to get this UDF updated. It's about the only way to get some stuff done.... Even tried to use a runwait to get the dropshadow but that's also a dead end street.... So +1 from me to add the dropshadow.... Link to comment Share on other sites More sharing options...
jaberwacky Posted March 5, 2013 Author Share Posted March 5, 2013 Unless you can get your command to work properly I don't think I'll be able to make a proper working set of functions. I really just started this project as a way to see if I could use AutoItObject in this manner to create UDFs. I don't really know much about image processing. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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