title: Convert all .jpg images in directory to .pdf | Debugging ImageMagick
body: <p>I have found multiple posts regarding this issue and everyone is recommending <a href="https://imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick</a> but for me, it doesn't seem to work as intended and I don't see too many docs on their site regarding .jpg-&gt;.pdf conversion.</p>
  <p>Is there some alternative, preferably CLI tool?</p>
  <p>Or can I somehow debug why ImageMagick doesn't work for me? I don't get any errors I just get corrupted files as a result.</p>
  <p><strong>My usecase</strong></p>
  <hr/>
  My os is Windows and
  I have 64 .jpg files called 0.jpg, 2.jpg, ... 63.jpg and I would like to merge all those images into one .pdf file.
  <p>I have tried these commands:</p>
  <pre><code>magick *.jpg out.pdf
  
  convert *.jpg out.pdf
  </code></pre>
  <p>but in both cases, I am unable to open the out.pdf file because it is corrupted. I have noticed that I can only convert 0.jpg file to pdf correctly but when I try to convert any other of my 64 jpg files then as a result I am getting a corrupted .pdf file<br/>
  For example:<br/>
  This gives me the correct .pdf:</p>
  <pre><code>magick 0.jpg 0.pdf
  </code></pre>
  <p>but this gives me corrupted .pdf:</p>
  <pre><code>magick 2.jpg 2.pdf
  </code></pre>
  <p>I assume that this a reason why I can't merge all of the files into one not corrupted .pdf file and my assumption is that there is something wrong with the rest of my .jpg files but I have no idea how to debug this issue. Every other .jpg file looks exactly the same as the one .jpg I can convert and all of them open without issues.</p>
  <p><strong><em>magick identify -verbose foobar.jpg</em> results:</strong></p>
  <hr/>
  <p>I can convert 0.jpg file to .pdf correctly but 2.jpg results in corrupted .pdf.
  There are some apparent differences but I am not sure what those properties mean in the context of .jpg -&gt; .pdf conversion</p>
  <p><a href="https://i.stack.imgur.com/fSUWZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fSUWZ.png" alt="magic identify -verbose" /></a></p>