title: Convert a pdf to png using mini_magick in Ruby on Rails
body: <p><strong>Background</strong></p>
  
  <p>I retrieved a pdf in binary form from an API call:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>base_64_binary_data = @response_label[:generate_label_response][:response_shipments][:response_shipment][:labels][:label][:content]
  
  @pdf_file = File.open('label.pdf', 'wb') do |file|
    content = Base64.decode64 base_64_binary_data
    file &lt;&lt; content
  end
  </code></pre>
  
  <p>The above code results in a file that I can look up and is the crystal clear image I need.</p>
  
  <p><strong>Issue</strong></p>
  
  <p>I need to place this image inside a view in order to function as a label on an invoice. </p>
  
  <p>The following seems to be leading to a fine solution:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>@pdf = MiniMagick::Image.new(@pdf_file.path)
  @pdf.pages.first.write("preview.png")
  </code></pre>
  
  <p>It fails on the second line. </p>
  
  <p><strong>MiniMagick::Error</strong><br>
  `identify label.pdf` failed with error:<br>
  ...2nd line...</p>
  
  <p>I'd like to work to something like this functioning: </p>