I absolutely love imageMagic, I’ve been using it in some of my programs for almost 10 years now. Problem is: I only write one line of code for it every 3 to 5 years, up so I’ve never actually *learned* how to use it. I stumble through it, with a lot of cutting and pasting, and a little help from you guys.
Here’s my current problem: I have a data table with a list of file paths, and xy coordinates. (actually just X coordinates, the Y coordinate will always be 0) is my goal is to create a long strip of an image with each of these images spaced these distances apart.
The data looks like this:
Filepath, XY
c:\bmp\A.jpg 10,0
c:\bmp\B.jpg 350,0
c:\bmp\C.jpg 752,0
…
And I would loop through it with VB code to something like this:
With objImageList
.movefirst
Do while not .eof
ImgMagCmdTxt = ImgMagCmdTxt & ", " & .Filepath & ", [" & .XY & "]"
.movenext
loop
which would create the string *
"c:\bmp\A.jpg, [10,25], c:\bmp\B.jpg [10,350], c:\bmp\C.jpg, [10,752]"
which we would then use in a IM COM object command something like this:
strConvertResult = objImgMag.convert(ImgMagCmdTxt, destfilepath)
*Now I absolutely realize that is the wrong syntax for this string! But it is (I think) the data we need and it is in *a* string.
My question is: what would be the correct syntax for that string? Specifically, what about the quote marks?
The ImageMagick command line utility, and the ImageMagick COM object seem to have different requirements when it comes to quote marks, all the parameters in VB need to be in closed quote marks, but some need quote marks the inside of a quote marks, (I usually use & Chr(34) & for that). This is why the examples web page have never work for me.
To repeat: my goal is to create a long strip of an image with each of these images spaced these distances apart.
AHA, TIA ,
Roger
Help w/ syntax of VB command
-
- Posts: 21
- Joined: 2013-09-01T05:52:51-07:00
- Authentication code: 6789
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Help w/ syntax of VB command
There are many variations of command that will do this. One is to "+append" many images together, where every other image is "xc:" at the width of the required gap and only 1 pixel high. So the command could be:
Sorry, I can't help much with VB. Like most languages, string constants need to be quoted. If there are no quotes, VB assumes they are variables.
Command lines (such as bash and Windows CMD) work differently. There, variables have special markings such as $(...) or %...%, and quotes are needed to prevent a space character denoting the end of a token, and similar purposes to prevent the shell from interpreting special characters.
Code: Select all
convert A.jpg xc:none[10x1+0+0] B.jpg xc:none[350x1+0+0] C.jpg +append out.png
Command lines (such as bash and Windows CMD) work differently. There, variables have special markings such as $(...) or %...%, and quotes are needed to prevent a space character denoting the end of a token, and similar purposes to prevent the shell from interpreting special characters.
snibgo's IM pages: im.snibgo.com
-
- Posts: 21
- Joined: 2013-09-01T05:52:51-07:00
- Authentication code: 6789
Re: Help w/ syntax of VB command
This may be all the help I need.
But pls explain the 10x1+0+0 bit.
I'm sure I wasn't clear:
Pic A is 80px tall and 250 px wide, ans should start 10 px away from the left edge. (i.e. starts at XY 10,0)
Pic B is 80px tall and 300 px wide and needs to be 90 px away from pic A. (i.e. starts at XY 350,0)
thanks!
But pls explain the 10x1+0+0 bit.
I'm sure I wasn't clear:
Pic A is 80px tall and 250 px wide, ans should start 10 px away from the left edge. (i.e. starts at XY 10,0)
Pic B is 80px tall and 300 px wide and needs to be 90 px away from pic A. (i.e. starts at XY 350,0)
thanks!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Help w/ syntax of VB command
In that case, the command would be:
"xc:none[10x1+0+0]" is an image that is 10 pixels wide and 1 high. It is colour "none", which means it is transparent. So the command will place this 10x1 image, then A.jpg, then a 90x1 image, then B.jpg.
EDIT: corrected.
Code: Select all
convert xc:none[10x1+0+0] A.jpg xc:none[90x1+0+0] B.jpg +append out.png
EDIT: corrected.
snibgo's IM pages: im.snibgo.com
-
- Posts: 21
- Joined: 2013-09-01T05:52:51-07:00
- Authentication code: 6789
Re: Help w/ syntax of VB command
OH! xc:none is THE GAP!
(did you mean to but the 2nd "convert" in there?)
(did you mean to but the 2nd "convert" in there?)
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Help w/ syntax of VB command
Sorry, that was a copy-paste error, now corrected. Thanks.
If you want to use absolute coordinates instead of gaps, this should do it:
If you want to use absolute coordinates instead of gaps, this should do it:
Code: Select all
convert ( A.jpg -repage +10+0 ) ( B.jpg -repage +350+0 ) -layers mosaic out.png
snibgo's IM pages: im.snibgo.com