Page 1 of 1

Syntax Question

Posted: 2011-03-03T12:55:19-07:00
by smaines
So this solves my problem, albeit inelegantly,

$ montage card.png card.png card.png card.png card.png card.png -mode concatenate -tile 2x3 card-montage.png

...so does this,

$ montage card.png +clone +clone +clone +clone +clone -mode concatenate -tile 2x3 card-montage.png

...but (in my quest for syntactic concision, I ask), isn't there something like,

$ montage card.png -multi 5 +clone -mode concatenate -tile 2x3 card-montage.png # ?

Thanks in advance,

-SM

Re: Syntax Question

Posted: 2011-03-03T14:46:42-07:00
by fmw42
...but (in my quest for syntactic concision, I ask), isn't there something like,

$ montage card.png -multi 5 +clone -mode concatenate -tile 2x3 card-montage.png # ?
Not that I know about. But Anthony would be the best person to answer this or find a better work around.

The best alternative would be


montage card.png -clone 0,0,0,0,0 -mode concatenate -tile 2x3 card-montage.png # ?[/quote]

Re: Syntax Question

Posted: 2011-03-03T17:14:13-07:00
by anthony
Fred (fwm42) hit the nail perfectly.

Clone is first of all the best way to go, especially if you have already resized your image, and turn of montage resizing.
The cloned images will share teh image data, saving mega amounts of memory space, until the image is modified.

There is currently no -clone n:X-times type syntax (n is image index) but you can clone single images multiple times using -clone n,n,n,n,n as fred specified.

If some of the current problems with settings can be worked out, and they become much more useful, it may be that a X-times clone would become a very useful addition, but not not as yet.

Re: Syntax Question

Posted: 2011-03-13T01:27:06-07:00
by smaines
I've been away from my IM tinkering, and just remembered to check back to this thread. Thank you belatedly for your replies. It is good to learn that i was missing -clone n,n,n,n but not anything more fundamental.

Thanks for the reality check, =)

-SM

P.S. Speaking of evolving the syntax, did anyone ever consider implementing my other proposal?
What I expected to work was something like,

Code: Select all

   $ convert blue_type.png  -fx "out.g = in.b;out.b = in.g"  green_type.png
But there seem to be no such lvalue semantics in -fx.

Re: Syntax Question

Posted: 2011-03-13T19:03:19-07:00
by anthony
smaines wrote:IWhat I expected to work was something like,

Code: Select all

   $ convert blue_type.png  -fx "out.g = in.b;out.b = in.g"  green_type.png
But there seem to be no such lvalue semantics in -fx.
That is definably not possible.

You see the FX expression is not run one per pixel as the above implies, but once per pixel value.
that is for each pixel it is run once for red, green, and blue channels, which is where the result is then saved. What channels TX will execute on (and thus assigns results to) is controled by -channel

As such to save Blue to Green, and then Green to Blue, will require two FX expressions.
and you will thus need to save the original 'source' image between the expressions so you can
re-use it.
Here is the standard example...

Code: Select all

  convert rose: \( +clone -channel G -fx B \) \
          +swap -channel B -fx v.G     fx_rb_swap.gif
The first line makes a copy of the image and copies blue values into green channel
the second swaps the two images, so the G=B image is destination, and copies the green channel from the original image (now in image 'v') into the blue channel of the destination image.

NOW: if the -fx expression had a variable that held the current channel that is being processed, say as a number from 0 to 2 (or 4,5 for optional alpha and black channels) then FX could decide on the value to save basied on the channel being processed.

EG if 'channel' holds the current channel being processed then you could do this...

Code: Select all

    -channel GB -fx 'channel==1 ? b : g'
That is if channel is 1 (green) save the blue value, otherwise save the green value.


I would like to see FX re-written at some point to provide a compiled, rather than parsed expression execution, and to provide the ability to use stored values and other things, but really FX is meant as a way of doing unusual things. A development tool for future operators and methods.

For example channel copying is actually a lot easier done by quite a few other methods!
Including:
  • separate,swap,combine
  • recolor matrix
  • compose channel coping
  • HALD color lookup tables
just to name a few I and think of from the top of my head.

Re: Syntax Question

Posted: 2011-03-18T21:24:15-07:00
by anthony
anthony wrote:There is currently no -clone n:X-times type syntax (n is image index) but you can clone single images multiple times using -clone n,n,n,n,n as fred specified.
STOP THE PRESS -- well its a little late, but you get my meaning.

I just realised that you can generate N images from one image where N is some specific number.
Basically this is a weird miss-use of a operator, but it will work.

The Operator is... -morph
See http://www.imagemagick.org/Usage/anim_mods/#morph

What you do is clone the image twice, then use morph to make N-2 more images. Note these will be processed, as as such will not strictly be clones, but full copies of the images, but you will get N copies.


For example, get a rose image, make clones, and then morph N-2 more copies , append and delete the original.

Code: Select all

  convert rose: \( -clone 0,0 -morph 4 -append \) \
              -delete 0  rose_6_times.png
That is for 6 copies I used N-2 or 4 as a argument to morph.

TRICKY.

I have turned off the Idea of using -clone xN type syntax as it probably will overload the syntax too much.
Though that may still be possible. So I suggest a new operator...

PROPOSAL: Operator -dup N take the last image and duplicate it N more times (making N+1 copies).
With +dup equivalent to -dup 1.
Note +dup is NOT the same a +clone as it will get the last image from the CURRENT image sequence and not the piushed or previous image sequence.