Page 1 of 1
[SOLVED] How to copy-paste an image region with MSL?
Posted: 2013-05-17T04:54:25-07:00
by magmical
Hi folks
I want to copy-paste an image region with Magick Scripting Language.
With convert it must look like this:
convert old.png ( +clone -crop 20x20+10+10 +repage ) -geometry +110+110 -composite new.png
How can I do this with Magick Scripting Language?
My real problem ist how to do a clone?
Add: How to copy-paste an image region with MSL?
Posted: 2013-05-18T10:46:27-07:00
by magmical
After a few trials - this code does a copy-paste-like action:
Code: Select all
<group>
<image id="clone">
<read filename="source.gif"/>
<crop geometry="... />
<repage geometry="0x0+0+0" />
</image>
<image>
<read filename="source.gif"/>
<composite image="clone" geometry="..." />
<write filename="out.png"/>
</image>
</group>
It's works pretty good but it's not perfect:
it loads the "source.gif" 2 times.
Any other way to do this?
Re: How to copy-paste an image region with MSL?
Posted: 2013-05-20T00:28:34-07:00
by anthony
Nope that would be the way... crop to copy, compose to paste
Though you should be able to make a clone of the original image rather than read it in twice.
One way, if you can't find a 'clone', would be read in image, write to a 'MPR:' image store, then when needed again read from that store.
See IM examples MPR (though that is command line)
http://www.imagemagick.org/Usage/files/#mpr
Re: How to copy-paste an image region with MSL?
Posted: 2013-05-20T04:26:52-07:00
by magmical
Clone seems to be missing in MSL.
<clone /> throws an error:
conjure.exe: unrecognized element `clone' @ error/msl.c/MSLStartElement/2275.
But the idea with mpr (memory program register) is really good! Thanks.
This code reads the image only once.
Code: Select all
<group>
<image>
<read filename="source.gif"/>
<write filename="mpr:source" />
</image>
<image id="part">
<read filename="mpr:source"/>
<crop geometry="520x100+0+0" />
<repage geometry="0x0+0+0" />
</image>
<image>
<read filename="mpr:source"/>
<composite image="part" geometry="0x0+0+100" />
<write filename="out.png"/>
</image>
</group>
Re: [SOLVED] How to copy-paste an image region with MSL?
Posted: 2013-05-20T17:39:58-07:00
by anthony
You can combine part 1 and 2.
But other than that looks good.
Re: [SOLVED] How to copy-paste an image region with MSL?
Posted: 2013-05-21T06:44:57-07:00
by magmical
anthony wrote:You can combine part 1 and 2.
Well, thats another good aspect! Looks much clearer now!
Code: Select all
<group>
<image id="part">
<read filename="source.gif"/>
<write filename="mpr:source" />
<crop geometry="520x100+0+0" />
<repage geometry="0x0+0+0" />
</image>
<image>
<read filename="mpr:source"/>
<composite image="part" geometry="0x0+0+100" />
<write filename="out.png"/>
</image>
</group>
Perfect!
Thanks again!
Re: [SOLVED] How to copy-paste an image region with MSL?
Posted: 2013-05-21T22:25:15-07:00
by anthony
NP.