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?
[SOLVED] How to copy-paste an image region with MSL?
[SOLVED] How to copy-paste an image region with MSL?
Last edited by magmical on 2013-05-20T04:35:06-07:00, edited 2 times in total.
Add: How to copy-paste an image region with MSL?
After a few trials - this code does a copy-paste-like action:
It's works pretty good but it's not perfect:
it loads the "source.gif" 2 times.
Any other way to do this?
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 loads the "source.gif" 2 times.
Any other way to do this?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to copy-paste an image region with MSL?
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to copy-paste an image region with MSL?
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.
<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>
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: [SOLVED] How to copy-paste an image region with MSL?
You can combine part 1 and 2.
But other than that looks good.
But other than that looks good.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: [SOLVED] How to copy-paste an image region with MSL?
Well, thats another good aspect! Looks much clearer now!anthony wrote:You can combine part 1 and 2.
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>
Thanks again!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: [SOLVED] How to copy-paste an image region with MSL?
NP.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/