Clone question

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Clone question

Post by Bonzo » 2018-04-01T03:11:12-07:00

With the code below I am expecting to get the coloured rose image resized with a monochrome version over it. I am more interested in getting the clone to work. My final image will have three different images with different effects layerd on each other. So I want to use the -resize 500x500 +repage image modified two more times.

Code: Select all

convert rose: ( -resize 500x500 +repage ) ( -clone 1 -resize 300x300 +repage  -monochrome ) -layers merge test.jpg
Error "No such image -clone" I would have thought the original image is -clone 0 and the resized version is -clone 1

Code: Select all

convert rose: ( -resize 500x500 +repage ) ( -clone 0 -resize 300x300 +repage  -monochrome ) -layers merge test.jpg
Just get the final 300px wide monochrome image

This is the result I am looking for using mpr although last night I could not get that to work either!

Code: Select all

convert rose: -write mpr:image +delete ( mpr:image  -resize 500x500 +repage ) ( mpr:image -resize 300x300 +repage  -monochrome ) -layers merge test.jpg

snibgo
Posts: 11817
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Clone question

Post by snibgo » 2018-04-01T04:07:22-07:00

Open parenthesis "(" starts a new empty image list. "-resize" will resize all the images in the current list, but at that point you have no images. IM v7 will reject that command. V6 will take a guess at what you really want. Perhaps you intended to "-clone 0" after the open parenthesis.

Then you "-clone 1", which only works if you have at least two images, because the first in numbered zero.

Code: Select all

convert rose: ( -clone 0 -resize 500x500 +repage ) ( -clone 1 -resize 300x300 +repage  -monochrome ) -layers merge test.jpg
This gives three images layered ogether: the original rose, hidden behind a larger version, with a monochrome version on top.
snibgo's IM pages: im.snibgo.com

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Clone question

Post by Bonzo » 2018-04-01T04:29:28-07:00

Thank you for the explanation snibgo; I was going around in circles last night trying to get it to work!

In actual use the original image will be larger and I only need the two modified images so I have added a -delete 0 before the -layers merge.

snibgo
Posts: 11817
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Clone question

Post by snibgo » 2018-04-01T04:52:23-07:00

A simple alternative is to remove the first parenthesis pair:

Code: Select all

convert rose: -resize 500x500 +repage ( -clone 0 -resize 300x300 +repage  -monochrome ) -layers merge test.jpg
We read the rose and resize it. Then we clone it, resize and make it monochrome. So we have two images, which we merge.
snibgo's IM pages: im.snibgo.com

Post Reply