title: How to make tiled image frame without using exec function?
body: <p>Original image:
  <a href="https://i.stack.imgur.com/a1Wit.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a1Wit.jpg" alt="Original image"></a>
  Here what i need:
  <a href="https://i.stack.imgur.com/H3iq2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H3iq2.png" alt="Here what i need"></a>
  It should be created from this small tile:
  <a href="https://i.stack.imgur.com/Ujd1t.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ujd1t.gif" alt="It should be created from this small tile"></a></p>
  
  <p>A lot of people suggest to use ImageMagick solution (it using php exec function) - <a href="http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=21867" rel="nofollow noreferrer">http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=21867</a>:</p>
  
  <pre><code>convert frame_template.gif \
  -tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
  -tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
  -tile blackthin_top.gif -draw 'color 1,0 floodfill' -rotate 90 \
  -tile blackthin_btm.gif -draw 'color 1,0 floodfill' -rotate 90 \
  -gravity center thumbnail.gif -composite frame_filled.gif
  </code></pre>
  
  <p>or</p>
  
  <p>PICFrame solution (it using php exec function) - <a href="http://www.fmwconcepts.com/imagemagick/picframe/index.php" rel="nofollow noreferrer">http://www.fmwconcepts.com/imagemagick/picframe/index.php</a>:</p>
  
  <pre><code>picframe [-f frameid] [-m mattesize] [-c mattecolor] [-b bordersize] [-s shade] [-a adjust] [-o opacity ] [-d distance] infile outfile
  </code></pre>
  
  <p>PHP imagick has great ability to create color borders with:</p>
  
  <pre><code>$imagick = new \Imagick('image.jpg');
  $imagick-&gt;scaleImage(300, 300, false);
  
  // Create frame placeholder
  $imagick-&gt;frameimage( 'red','30','30', 30, 0);
  
  // Flood fill with color
  $imagick-&gt;floodFillPaintImage('green', 10, '#6e0000',0, 0,false
  );
  
  header("Content-Type: image/jpg");
  echo $imagick-&gt;getImageBlob();
  </code></pre>
  
  <p>But PHP imagick can't use your own image tile to create frame, only solid colors. Here is very related question - <a href="https://stackoverflow.com/questions/33490101/how-to-flood-fill-the-frame-with-a-pattern-image-using-imagick-php-class">How to flood fill the frame with a pattern image using imagick php class?</a></p>
  
  <p>Another good solution from - <a href="https://stackoverflow.com/a/28778953/2337706">https://stackoverflow.com/a/28778953/2337706</a> but it creates image from big PNG frames and you should know correct image size.</p>
  
  <p>I know that i can create it with php GD - <a href="http://php.net/manual/en/ref.image.php" rel="nofollow noreferrer">http://php.net/manual/en/ref.image.php</a> but i don't know correct way how implement it this way.</p>