I'm using TPDF 6.2.12
and I'm searching a way to convert PNG
images to JPEG
before using them in the Image()
function, which works quite well with PNGs but generates a large output file.
I have no clue how to use the _toJPEG()
function and have not found any working example yet.
Could somebody help me with a working example/code-snippet, or a better solution, please?
Edit:
$pngname = $path.$imagelist[$i].'.png';
$jpegname = $path.$imagelist[$i].'.jpg';
$image = imagecreatefrompng($pngname);
imagejpeg($image, $jpegname);
$pdf->Image($jpegname, $image_x[$i], $image_y[$i], $image_w[$i],
$image_h[$i], 'JPEG', '', '', true, 150, '', false, false, 0, false,
false, false);
imagedestroy($image);
unlink($jpegname);
This works perfectly fine but is rather clumsy: open png, write jpeg, open jpeg, delete jpeg