title: magick image library writing incorrect header to PDF files?
body: <p>I am using the very useful <code>magick</code> library to read and annotate PDF files, and overlay an image on the result. I can generate a PDF file that looks as I would expect it to look. However, when I open the file, the header, which I would expect to read something like <code>%PDF-1.7</code>, reads <code>‰PNG</code> like this.</p>
  
  <p><a href="https://i.stack.imgur.com/RhPjh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RhPjh.png" alt="PDF file not showing expected header"></a></p>
  
  <p>It looks to me as if <code>magick</code> is looking at the most recent operation, which is <code>image_composite</code> for a PNG file, and using this for the header. If so, is this a bug? The PDF file that is output appears otherwise well-formed, so it doesn't seem to be causing problems, but I am curious. The following code should enable the issue to be reproduced.</p>
  
  <pre><code>require(magick)
  require(pdftools)
  
  pdf_file &lt;- "https://web.archive.org/web/20140624182842/http://www.gnupdf.org/images/d/db/Hello.pdf"
  image_file &lt;- "https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/200px-PDF_file_icon.svg.png"
  
  my_image &lt;- image_read(image_file,density = 300)
  pdfimage &lt;- image_read_pdf(pdf_file,density = 300)
  
  pdfimage2 &lt;- image_annotate(pdfimage, "test",
                            location = "+400+700", style = "normal", weight = 400, 
                            size=42)
  
  pdfimage3 &lt;- image_composite(pdfimage2,my_image,operator="atop",
                               offset = "+100+100")
  
  image_write(pdfimage3, path = "C:/temp/test.pdf", density = 300, flatten = TRUE)
  </code></pre>