Lines Matching refs:file

142 	public function getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false, $interpolation = false)
150 if ($wrapperChecker->hasBlacklistedStreamWrapper($file)) {
151 return $this->imageError($file, $firsttime, 'File contains an invalid stream. Only ' . implode(', ', $wrapperChecker->getWhitelistedStreamWrappers()) . ' streams are allowed.');
164 if (preg_match('/var:\s*(.*)/', $file, $v)) {
166 return $this->imageError($file, $firsttime, 'Unknown image variable');
169 $file = md5($data);
172 if (preg_match('/data:image\/(gif|jpe?g|png|webp);base64,(.*)/', $file, $v)) {
175 $file = md5($data);
179 if ($firsttime && $file && strpos($file, 'data:') !== 0) {
180 $file = str_replace(' ', '%20', $file);
183 // If orig_srcpath is a relative file path (and not a URL), then it needs to be URL decoded
194 $file = $orig_srcpath;
198 if (isset($this->mpdf->images[$file])) {
199 return $this->mpdf->images[$file];
203 $file = $orig_srcpath;
204 return $this->mpdf->formobjects[$file];
207 if (isset($this->mpdf->formobjects[$file])) {
208 return $this->mpdf->formobjects[$file];
211 if ($firsttime && isset($this->failedImages[$file])) { // Save re-trying image URL's which have already failed
212 return $this->imageError($file, $firsttime, '');
221 $file = $orig_srcpath;
222 $this->logger->debug(sprintf('Fetching (file_get_contents) content of file "%s" with local basepath', $file), ['context' => LogContext::REMOTE_CONTENT]);
223 $data = file_get_contents($file);
227 if ($file && !$data && $check = @fopen($file, 'rb')) {
229 $this->logger->debug(sprintf('Fetching (file_get_contents) content of file "%s" with non-local basepath', $file), ['context' => LogContext::REMOTE_CONTENT]);
230 $data = file_get_contents($file);
235 $data = $this->remoteContentFetcher->getFileContentsByCurl($file); // needs full url?? even on local (never needed for local)
241 if ((!$data || !$type) && !ini_get('allow_url_fopen')) { // only worth trying if remote file and !ini_get('allow_url_fopen')
242 $data = $this->remoteContentFetcher->getFileContentsBySocket($file); // needs full url?? even on local (never needed for local)
250 return $this->imageError($file, $firsttime, 'Could not find image file');
258 return $this->imageError($file, $firsttime, 'WMF or SVG image file not supported in this context');
273 return $this->imageError($file, $firsttime, 'Error parsing SVG file');
277 $this->mpdf->formobjects[$file] = $info;
287 return $this->imageError($file, $firsttime, 'Missing GD support for WEBP images.');
290 $tempfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.jpg');
291 $checkfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.jpg');
295 return $this->imageError($file, $firsttime, 'Error creating temporary file (' . $tempfile . ') when using GD library to parse WEBP image');
312 return $this->imageError($file, $firsttime, 'Error parsing JPG header');
334 throw new \Mpdf\MpdfException(sprintf('JPG image may not use CMYK color space (%s).', $file));
338 $this->mpdf->PDFAXwarnings[] = sprintf('JPG image may not use CMYK color space - %s - (Image converted to RGB. NB This will alter the colour profile of the image.)', $file);
344 $tempfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.png');
348 return $this->imageError($file, $firsttime, 'Error creating temporary file (' . $tempfile . ') when using GD library to parse JPG(CMYK) image');
352 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile . ') created with GD library to parse JPG(CMYK) image');
360 $this->mpdf->images[$file] = $info;
365 return $this->imageError($file, $firsttime, 'Error creating GD image file from JPG(CMYK) image');
373 $this->mpdf->PDFAXwarnings[] = sprintf('JPG image may not use RGB color space - %s - (Image converted to CMYK. NB This will alter the colour profile of the image.)', $file);
421 return $this->imageError($file, $firsttime, 'Error parsing or converting JPG image');
427 $this->mpdf->images[$file] = $info;
438 return $this->imageError($file, $firsttime, 'Error parsing PNG identifier');
443 return $this->imageError($file, $firsttime, 'Incorrect PNG file (no IHDR block found)');
497 $errpng = 'interlaced file';
519 // "If the source file's gamma value is greater than 1.0, it is probably a display system exponent,..."
550 $this->mpdf->PDFAXwarnings[] = sprintf('PNG image may not use RGB color space - %s - (Image converted to CMYK. NB This will alter the colour profile of the image.)', $file);
571 $this->mpdf->PDFAXwarnings[] = sprintf('Transparency (alpha channel) not permitted in PDFA or PDFX files - %s - (Image converted to one without transparency.)', $file);
578 return $this->imageError($file, $firsttime, sprintf('GD library with PNG support required for image (%s)', $errpng));
583 return $this->imageError($file, $firsttime, sprintf('Error creating GD image from PNG file (%s)', $errpng));
589 $tempfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.png');
594 throw new \Mpdf\MpdfException(sprintf('PDFA1-b does not permit images with alpha channel transparency (%s).', $file));
680 $tempfile_alpha = $this->cache->tempFilename('_tempMskPNG' . md5($file) . random_int(1, 10000) . '.png');
685 return $this->imageError($file, $firsttime, 'Failed to create temporary image file (' . $tempfile_alpha . ') parsing PNG image with alpha channel (' . $errpng . ')');
694 // create temp image file
697 return $this->imageError($file, $firsttime, 'Failed to create temporary image file (' . $tempfile . ') parsing PNG image with alpha channel (' . $errpng . ')');
705 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile_alpha . ') created with GD library to parse PNG image');
717 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile . ') created with GD library to parse PNG image');
728 $this->mpdf->images[$file] = $info;
775 return $this->imageError($file, $firsttime, 'Failed to create temporary image file (' . $tempfile . ') parsing PNG image (' . $errpng . ')');
781 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile . ') created with GD library to parse PNG image');
795 $this->mpdf->images[$file] = $info;
863 return $this->imageError($file, $firsttime, 'Error parsing PNG image data');
869 return $this->imageError($file, $firsttime, 'Error parsing PNG image data - no IDAT data found');
873 return $this->imageError($file, $firsttime, 'Error parsing PNG image data - missing colour palette');
888 return $this->imageError($file, $firsttime, 'Error parsing or converting PNG image');
894 $this->mpdf->images[$file] = $info;
909 $tempfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.png');
917 return $this->imageError($file, $firsttime, 'Error creating temporary image object when using GD library to parse GIF image');
924 return $this->imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse GIF image');
930 return $this->imageError($file, $firsttime, 'Error creating temporary file (' . $tempfile . ') when using GD library to parse GIF image');
934 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile . ') created with GD library to parse GIF image');
943 $this->mpdf->images[$file] = $info;
948 return $this->imageError($file, $firsttime, 'Error creating GD image file from GIF image');
991 return $this->imageError($file, $firsttime, 'Error parsing GIF image - missing colour palette');
1005 $this->mpdf->images[$file] = $info;
1016 $info = $this->bmp->_getBMPimage($data, $file);
1018 return $this->imageError($file, $firsttime, $info['error']);
1024 $this->mpdf->images[$file] = $info;
1039 return $this->imageError($file, $firsttime, $wmfres[1]);
1041 return $this->imageError($file, $firsttime, 'Error parsing WMF image');
1047 $this->mpdf->formobjects[$file] = $info;
1062 return $this->imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate');
1065 $tempfile = $this->cache->tempFilename('_tempImgPNG' . md5($file) . random_int(1, 10000) . '.png');
1074 return $this->imageError($file, $firsttime, 'Error creating temporary file (' . $tempfile . ') when using GD library to parse unknown image type');
1083 return $this->imageError($file, $firsttime, 'Error parsing temporary file (' . $tempfile . ') created with GD library to parse unknown image type');
1090 $this->mpdf->images[$file] = $info;
1097 return $this->imageError($file, $firsttime, 'Error parsing image file - image type not recognised');
1103 return $this->imageError($file, $firsttime, 'GD library needed to parse image files');
1425 private function imageError($file, $firsttime, $msg)
1427 $this->failedImages[$file] = true;
1430 throw new \Mpdf\MpdfImageException(sprintf('%s (%s)', $msg, substr($file, 0, 256)));
1433 $this->logger->warning(sprintf('%s (%s)', $msg, $file), ['context' => LogContext::IMAGES]);
1443 $file = $url;
1447 $file = $bits[0];
1450 $file = rawurldecode($file);
1453 return $file . $query;