Page 1 of 1

Convert CLI arguments to IMObject

Posted: 2011-02-21T10:51:37-07:00
by marshdamp68
I have a simple VB program that I can make work for simple image conversions and -draw line commands. I really need to use a more complicated list of arguments but I can not get it to work. I'm not sure how to parse it out correctly to make it work with IMobject. This is the command line I need to make work using IMObject:

Code: Select all

convert test.tif -gravity center -draw "translate 500,209 rotate -35.058 scale 4.215,4.215 image over -500,-209,0,0 'label2.gif'" output.tif
I think the quotes in the -draw section are causing me the problem. I have tried:

Code: Select all

"test.tif", "-gravity", "center", "-draw", """translate", "500,209", "rotate", "-35.058", "scale" ,"4.215,4.215, "image", "over", "-500,-209,0,0", "'label2.gif'""","output.tif"
but it doesn't work.

Re: Convert CLI arguments to IMObject

Posted: 2011-02-21T12:21:23-07:00
by el_supremo
I haven't used VB but I think the argument to -draw should be one long string in VB. Try it like this:

Code: Select all

"test.tif", "-gravity", "center", "-draw", "translate 500,209 rotate -35.058 scale 4.215,4.215, image over -500,-209,0,0 label2.gif","output.tif"
In this particular case the single quotes around label2.gif aren't needed. They are required when the filename has a space in it.


Re: Convert CLI arguments to IMObject

Posted: 2011-02-21T14:49:10-07:00
by marshdamp68
Thanks! That was a combination I hadn't tried yet. Unfortunately it did not work either.

Here's my whole program...most of which I found in the archives...

Code: Select all

    Sub Main()
        Dim objImage As New ImageMagickObject.MagickImage()
        Dim fnm(1) As Object
        Dim retval As Object
        Dim original As String = "C:\AgileDir\work\Cancel\test.tif"
        Dim final As String = "C:\AgileDir\work\Cancel\output.tif"
        Dim label As String = "C:\AgileDir\work\Cancel\label2.gif"

        ReDim fnm(5)
        fnm(0) = original
        fnm(1) = "-gravity"
        fnm(2) = "center"
        fnm(3) = "-draw"

        fnm(4) = "line 0,0,2000,2000"
        'fnm(4) = "image over " + label
        'fnm(4) = "translate 500,209 rotate -35.058 scale 4.215,4.215 image over " + label

        fnm(5) = final
        retval = objImage.Convert(fnm)
End Sub
I show 3 different variations of the line that start fnm(4). The first one, which draws a line, works great. If I try the 2nd one which should simply place an image on top of my original image doesn't work. I'm wondering if the image part of draw is not implimented in the IMObject or if there is a special way to input the name of my label image.

Re: Convert CLI arguments to IMObject

Posted: 2011-03-17T01:02:54-07:00
by MvGulik

I think I have a very similar, or same, problem. But in my case with the -fx parameter part.
Even tried using a expression file (@) as input for the -fx command, but the -fx expression always seems to evaluates to a zero result.
(while the same commands used directly with convert.exe do the job as expected)

Hoping any solution for the OP also will work for me.
(6.6.8-4-Q16-windows-dll, XpPro32, AutoIt)

Re: Convert CLI arguments to IMObject

Posted: 2012-03-18T21:50:02-07:00
by anthony
Perhaps an example of the code you are typing.

My understanding is the vb code is broken up in exactly the same way that the command line is.
As such "-fx" takes just one argument after it.

Re: Convert CLI arguments to IMObject

Posted: 2012-03-19T11:11:31-07:00
by MvGulik
A one year anniversary topics checkup? :wink:

I don't mind trying to dig up some code, if I can find the project again. Although giving it a second though ... I'm kinda wondering what I was actually doing back than. :? (probably just need some time to remember it ...)

(Also kinda switch to using nip2(frontend for VIPS) as general image processing tool over ImageMagick.)


Re: Convert CLI arguments to IMObject

Posted: 2012-03-19T22:01:29-07:00
by anthony
Sorry, I saw 'March 17' and thought it wasn't too old.

I was lurking in this sub-forum for the first time, having had some recent exposure to the internal code used for VB processing, even though I myself have never used VB, let alone programmed under windows.

As a moderator I could delete the last few posts, and return this topic to 1-year old obscurity status :-)

Re: Convert CLI arguments to IMObject

Posted: 2012-03-26T16:11:49-07:00
by MvGulik
If you like. I don't mind. (If the problem crops up again I can ask again. Probably in new topic.)

(late replay: overlooked notification mail.)