Convert inside convert, want to use result of inner converts without writing to disk

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?".
chaoscarnage
Posts: 93
Joined: 2012-12-31T15:56:29-07:00
Authentication code: 6789

Re: Convert inside convert, want to use result of inner converts without writing to disk

Post by chaoscarnage »

snibgo wrote: At the end, you have "-composite" with no "-compose" setting, so this will also be "Dst_Out".

The default setting of "-compose" is "Over".
This looks to be why it wasn't working. A million thank yous!
chaoscarnage
Posts: 93
Joined: 2012-12-31T15:56:29-07:00
Authentication code: 6789

Re: Convert inside convert, want to use result of inner converts without writing to disk

Post by chaoscarnage »

Also can I just casually call -compose in between overall calls like so?

Code: Select all

convert \
   -compose Dst_Out \

   source2.png \
      subsource1.png -composite \
      subsource2.png -composite \
   +write mpr:convert_result_1 \
   +delete \
   
   source3.png \
      subsource1.png -composite \
   +write mpr:convert_result_2 \
   +delete \
   
   -compose Over \
   blank.png \
   ....\
   
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert inside convert, want to use result of inner converts without writing to disk

Post by snibgo »

chaoscarnage wrote:Also can I just casually call -compose in between overall calls like so?
Yes. You set compose to Dst_Out at the start. It remains at that setting until you change it with "-compose Over".
snibgo's IM pages: im.snibgo.com
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Convert inside convert, want to use result of inner converts without writing to disk

Post by 246246 »

chaoscarnage wrote: I am programmatically creating a string to call using PHP Exec() to combine a bunch of images together sometimes in a specific way.
OK. Then consider about your first simple case.

If you just want to compose n file to background,

Code: Select all

convert background src_1 -compose over -composite tmp_1
convert tmp_1      src_2 -compose over -composite tmp_2
...
convert tmp_n-1    src_n -compose over -composite target
will work of course.

To remove temporary file using correct syntax. If input is 2 file,

Code: Select all

convert
	\( background src_1 -compose over -composite \)
	src_2
	-compose over -composite
	target
In this case, you can omit parenthesis. So nth case

Code: Select all

convert
	background
	src_1
	-compose over -composite
	src_2
	-compose over -composite
	
	[...]
	
	src_n
	-compose over -composite
	target
chaoscarnage wrote: However, I need to go a step further and modify a couple of the images before they get added to the overall image.
If you want to do something special for src2, your code would be like the following.

Code: Select all

convert
	background
	src_1
	-compose over -composite
	\( [do something special to src_2] \)
	-compose over -composite
	
	[...]
	
	src_n
	-compose over -composite
	target
For example, If special operation is compose from sub2_1 and sub2_2 using dst_over

Code: Select all

convert
	background
	src_1
	-compose over -composite
	\( sub2_1 sub2_2 -compose dst_over -composite \)
	-compose over -composite
	
	[...]
	
	src_n
	-compose over -composite
	target
Post Reply