title: How can I convert several jpgs into single multi-page pdf file?
body: <p>I have several <code>.jpg</code> files, named sequentially from <code>a.jpg</code> to <code>j.jpg</code>. I tried simply concatenating them into single <code>pdf</code> file:</p>
  
  <pre><code>convert *.jpg output.pdf
  </code></pre>
  
  <p>but then I saw that two of the images were a little higher than the others:</p>
  
  <pre><code>$ echo *.jpg | xargs -n1 identify
  a.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 15.8KB 0.000u 0:00.000
  b.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 18.7KB 0.000u 0:00.000
  c.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 33.5KB 0.000u 0:00.000
  d.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 24.2KB 0.000u 0:00.000
  e.jpg JPEG 400x751 400x751+0+0 8-bit DirectClass 39.4KB 0.000u 0:00.000
  f.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 31.6KB 0.000u 0:00.000
  g.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 37.1KB 0.000u 0:00.000
  h.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 32KB 0.000u 0:00.000
  i.jpg JPEG 400x720 400x720+0+0 8-bit DirectClass 27.6KB 0.000u 0:00.000
  j.jpg JPEG 400x567 400x567+0+0 8-bit DirectClass 5.65KB 0.000u 0:00.000
  </code></pre>
  
  <p>As you see, <code>e.jpg</code> and <code>i.jpg</code> have a bigger height. I batch converted all the files to the same size:</p>
  
  <pre><code>for x in {a..j}; do convert $x.jpg -gravity center -background white -extent 400x751 $x.png; done;
  </code></pre>
  
  <p>Now all the resulting <code>.png</code> files have the same size:</p>
  
  <pre><code>$ echo *.png | xargs -n1 identify
  a.png PNG 400x751 400x751+0+0 8-bit DirectClass 62.3KB 0.000u 0:00.000
  b.png PNG 400x751 400x751+0+0 8-bit DirectClass 74.9KB 0.000u 0:00.000
  c.png PNG 400x751 400x751+0+0 8-bit DirectClass 148KB 0.000u 0:00.000
  d.png PNG 400x751 400x751+0+0 8-bit DirectClass 85.5KB 0.000u 0:00.000
  e.png PNG 400x751 400x751+0+0 8-bit DirectClass 175KB 0.000u 0:00.000
  f.png PNG 400x751 400x751+0+0 8-bit DirectClass 124KB 0.000u 0:00.000
  g.png PNG 400x751 400x751+0+0 8-bit DirectClass 162KB 0.000u 0:00.000
  h.png PNG 400x751 400x751+0+0 8-bit DirectClass 118KB 0.000u 0:00.000
  i.png PNG 400x751 400x751+0+0 8-bit DirectClass 113KB 0.000u 0:00.000
  j.png PNG 400x751 400x751+0+0 8-bit DirectClass 15.7KB 0.000u 0:00.000
  </code></pre>
  
  <p>But, batching them into the <code>pdf</code> file (<code>convert *.png output.pdf</code>) still results in those two pages being much bigger than others. What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Seems I found the solution - I needed to specify <code>-density</code> option, when assembling pdf:</p>
  
  <pre><code>convert *.png -density 600 output.pdf
  </code></pre>
  
  <p>But still, I don't understand why it didn't work in the original attempt.</p>