method jpg2pdf documentation in bbn\File\Image
Converts one or more jpg image(s) to a pdf file. If the pdf file doesn't exist will be created.
Example
bbn\X::dump(bbn\File\Image::jpg2pdf(["/home/data/test/two.jpg","/home/data/test/one.jpeg"], "/home/data/test/doc.pdf"));
// (string) "/home/data/test/doc.pdf"
function($jpg, $pdf)
{
if (class_exists('\\Imagick')) {
if (\is_array($jpg)) {
$img = new \Imagick();
$img->setResolution(200, 200);
if (\count($jpg) === 1) {
$img->readImage($jpg[0]);
}
else {
$img->readImages($jpg);
}
$img->setImageFormat('pdf');
if (\count($jpg) === 1) {
$img->writeImage($pdf);
}
else {
$img->writeImages($pdf, 1);
}
return $pdf;
}
}
return false;
}
Converts one or more jpg image(s) to a pdf file. If the pdf file doesn't exist will be created. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions