<?
 
/*
  I'm using this together with a bash script I call mkpdf. which is as follows:
  #!/bin/bash
  WDIR=/home/kristianf/pdf/
  CDIR=$PWD;
  rm -f $WDIR/*.jpg
  rm -f $WDIR/output.pdf
  for i in $*;
  do
        cp $i $WDIR/;
  done;
  cd $WDIR;
  php -f convert.php
  mv $WDIR/output.pdf $CDIR/
  
  ##########
  The result is that I can run e.g. mkpdf default-015.jpg default-016.jpg default-017.jpg and end up with a file called output.pdf with them merged. 
 */
 
require('fpdf.php');
 
$pdf = new FPDF();
 
 
$d=dir('.');
 while((
$file=$d->read())!=false)
 {
  if(
substr($file,-4)!=".jpg") continue;
  
$pdf->AddPage();
  
$pdf->Image($file,0,0,220);
 }
 
$d->close();
 
$pdf->Output("output.pdf");
?>