title: Crop an Image to the shape of a Vector or Overlay a Shape
body: <p>I imagine this is a shot in the dark, but is it possible to have a vector file of a shape (in this case a hexagon with rounded corners), and pass an image through some code and have it coming out cropped in the shape of that vector?</p>
  
  <p>I'm attempting to utilize hexagons in my design and have gone through every page I possibly can. I've seen the many HTML and CSS solutions, but none of them achieve what I'm looking for flawlessly. </p>
  
  <p>Another idea I have is maybe overlaying a transparent hexagon shape with white corners on top of the existing image with imagemagick, and then going through and making any white transparent. Thoughts? </p>
  
  <p>I don't have any code for cropping in the shape of a vector file, but here's what I have for overlaying an outline of the shape I want on top of the other picture:</p>
  
  <pre><code>imgfile = "public/" + SecureRandom.uuid + ".png"
  SmartCropper.from_file(art.url(:original)).smart_square.resize(225,225).write(imgfile)
  
  overlay = Magick::Image.read("app/assets/images/overlay.png")
  img = Magick::Image.read(imgfile)         
  img.composite(overlay,0,0, Magick::OverCompositeOp)
  </code></pre>
  
  <p>Right now it's giving me an undefined method error for composite, which is strange because I've followed some other stack overflow questions using the same thing in their models. </p>
  
  <p>Any help is appreciated!</p>