title: ImageMagick : Compose with results of multiple convert
body: <p>I want to create an image from to others, which are results of <code>convert</code> operations their self, without saving intermediate results to file system.</p>
  
  <p><strong>Long explanation:</strong></p>
  
  <p>I have two images, the two needs specific transformations :</p>
  
  <ul>
  <li><em>avatar.jpg</em> needs to be transformed to a rounded image -> <em>rounded-avatar.jpg</em></li>
  <li><em>background.jpg</em> needs to have a color layer applied -> <em>colored-background.jpg</em></li>
  </ul>
  
  <p>Then I want to <code>dissolve</code> <em>rounded-avatar.png</em> in <em>colored-background.jpg</em>, so that I get something looking like this:</p>
  
  <pre>
    +-----------+
    |     O     |
    +-----------+
  </pre>
  
  <p><strong>What I have so far:</strong></p>
  
  <p>I know how to make those operations sequentially (maybe not the best way but that is not the subject of this question), I even made a working bash script :</p>
  
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  
  convert $1 -alpha set -background none -vignette 0x0 rounded-avatar.png
  
  convert $2 -auto-orient -thumbnail 600x313^ -gravity center -extent 600x313 -region 100%x100% -fill "#256997" -colorize 72% colored-background.jpg
  
  composite -dissolve 100 -gravity Center rounded-avatar.png colored-background.jpg -alpha Set $3
  </code></pre>
  
  <p>That I can call it with </p>
  
  <pre class="lang-bash prettyprint-override"><code>$ ./myScript.sh avatar.jpg background.jpg output.jpg
  </code></pre>
  
  <p><strong>What I want:</strong></p>
  
  <p>I want to avoid the saving of the two temporary images (<em>rounded-avatar.jpg</em> and <em>colored-background.jpg</em>) on the file system.</p>
  
  <p><strong>Why ?</strong></p>
  
  <ul>
  <li>This procedure has to be ran automatically on a web platform, I don't want to have to handle concurrency on those temp files with naming tricks.</li>
  <li>The current script makes IM load the images two times in memory, it would probably be more efficient to reuse the computed images instead of writing them to disk and then load them in a new process.</li>
  <li>Disk I/O are scarcity these days, let's save some.</li>
  </ul>
  
  <hr>
  
  <p>I hope I am just missing the right keywords to find the answer in the documentation.</p>
  
  <p>I am aware that this might seems over optimisation and I am not struggling with C10k issues here, but I just want to do this right (and understand IM syntax).</p>