Open piatkowski opened 1 year ago
Hi, I need to work with WebP and PDFs and I ended up with code, which adds conversion WebP to PNG. Please check is it correct?
I changed line around tcpdf.php#L7136
and I changed if statement to the code below. If the file type is WebP then open image in Imagick, convert to PNG32. In case of WebP the _toPNG method returns 'pngalpha' so I should return ImagePngAlpha from some temporary PNG32 file.
PNG32
_toPNG
'pngalpha'
ImagePngAlpha
if (($type == 'gif') OR ($type == 'png') or ($type == 'webp')) { $info = TCPDF_IMAGES::_toPNG($img, TCPDF_STATIC::getObjFilename('img', $this->file_id)); if($type == 'webp'/* && $info == 'pngalpha'*/) { $webp = new Imagick($file); $webp->setFormat('png32'); $tmpfile = TCPDF_STATIC::getObjFilename('img', $this->file_id); $webp->writeImageFile($tmpfile); $webppng = $this->ImagePngAlpha($file, $x, $y, $pixw, $pixh, $w, $h, 'PNG', $link, $align, $resize, $dpi, $palign, $filehash); unlink($tmpfile); return $webppng; } }
Hi, I need to work with WebP and PDFs and I ended up with code, which adds conversion WebP to PNG. Please check is it correct?
I changed line around tcpdf.php#L7136
and I changed if statement to the code below. If the file type is WebP then open image in Imagick, convert to
PNG32
. In case of WebP the_toPNG
method returns'pngalpha'
so I should returnImagePngAlpha
from some temporary PNG32 file.