Lines Matching refs:this

274 		$this->phpThumb();
278 $this->DebugTimingMessage('phpThumb() constructor', __FILE__, __LINE__);
279 $this->DebugMessage('phpThumb() v'.$this->phpthumb_version, __FILE__, __LINE__);
288 $this->php_memory_limit = max($this->php_memory_limit, $php_config_memory_limit);
291 if ($this->php_memory_limit > 0) { // could be "-1" for "no limit"
292 $this->config_max_source_pixels = round($this->php_memory_limit * 0.20); // 20% of memory_limit
295 $this->iswindows = (bool) (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
296 $this->issafemode = (bool) preg_match('#(1|ON)#i', ini_get('safe_mode'));
297 …$this->config_document_root = (!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : $
298 …$this->config_cache_prefix = ( isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'].'_' : '…
300 $this->purgeTempFiles(); // purge existing temp files if re-initializing object
304 $this->config_allow_src_above_docroot = true;
307 if (!$this->config_disable_debug) {
309 $this->phpThumbDebug = (null === $this->phpThumbDebug ? 9 : max(1, (int) $this->phpThumbDebug));
314 $this->purgeTempFiles();
319 foreach ($this->tempFilesToDelete as $tempFileToDelete) {
321 $this->DebugMessage('Deleting temp file "'.$tempFileToDelete.'"', __FILE__, __LINE__);
325 $this->tempFilesToDelete = array();
333 $this->sourceFilename = $sourceFilename;
334 $this->src = $sourceFilename;
335 if (null === $this->config_output_format) {
338 $this->config_output_format = $sourceFileExtension;
339 …$this->DebugMessage('setSourceFilename('.$sourceFilename.') set $this->config_output_format to "'.…
341 …$this->DebugMessage('setSourceFilename('.$sourceFilename.') did NOT set $this->config_output_forma…
344 …$this->DebugMessage('setSourceFilename('.$sourceFilename.') set $this->sourceFilename to "'.$this-…
352 $this->rawImageData = $rawImageData;
353this->DebugMessage('setSourceData() setting $this->rawImageData ('.strlen($this->rawImageData).' b…
354 if ($this->config_cache_source_enabled) {
356 if (!is_dir($this->config_cache_source_directory)) {
357 …$this->ErrorImage('$this->config_cache_source_directory ('.$this->config_cache_source_directory.')…
358 } elseif (!@is_writable($this->config_cache_source_directory)) {
359 …$this->ErrorImage('$this->config_cache_source_directory ('.$this->config_cache_source_directory.')…
361 …$this->DebugMessage('setSourceData() attempting to save source image to "'.$this->config_cache_sou…
362 …if ($fp = @fopen($this->config_cache_source_directory.DIRECTORY_SEPARATOR.urlencode($sourceFilenam…
365 } elseif (!$this->phpThumbDebug) {
366 …$this->ErrorImage('setSourceData() failed to write to source cache ('.$this->config_cache_source_d…
375 $this->gdimg_source = $gdimg;
382 $this->setSourceFilename($this->ResolveFilenameToAbsolute($value));
383 } elseif (@is_array($this->$param)) {
386 array_push($this->$param, $arrayvalue);
389 array_push($this->$param, $value);
392 $this->$param = $value;
400 return $this->$param;
410 $this->setOutputFormat();
411 $this->phpThumbDebug('8a');
412 $this->ResolveSource();
413 $this->phpThumbDebug('8b');
414 $this->SetCacheFilename();
415 $this->phpThumbDebug('8c');
416 $this->ExtractEXIFgetImageSize();
417 $this->phpThumbDebug('8d');
418 if ($this->useRawIMoutput) {
419 …$this->DebugMessage('Skipping rest of GenerateThumbnail() because ($this->useRawIMoutput == true)'…
422 $this->phpThumbDebug('8e');
423 if (!$this->SourceImageToGD()) {
424 $this->DebugMessage('SourceImageToGD() failed', __FILE__, __LINE__);
427 $this->phpThumbDebug('8f');
428 $this->ImageCropAuto();
429 $this->phpThumbDebug('8h');
430 $this->Rotate();
431 $this->phpThumbDebug('8h');
432 $this->CreateGDoutput();
433 $this->phpThumbDebug('8i');
436 $destination_offset_x = round(($this->thumbnail_width - $this->thumbnail_image_width) / 2);
437 $destination_offset_y = round(($this->thumbnail_height - $this->thumbnail_image_height) / 2);
438 if (($this->far == 'L') || ($this->far == 'TL') || ($this->far == 'BL')) {
441 if (($this->far == 'R') || ($this->far == 'TR') || ($this->far == 'BR')) {
442 $destination_offset_x = round($this->thumbnail_width - $this->thumbnail_image_width);
444 if (($this->far == 'T') || ($this->far == 'TL') || ($this->far == 'TR')) {
447 if (($this->far == 'B') || ($this->far == 'BL') || ($this->far == 'BR')) {
448 $destination_offset_y = round($this->thumbnail_height - $this->thumbnail_image_height);
465 $this->ImageResizeFunction(
466 $this->gdimg_output,
467 $this->gdimg_source,
470 $this->thumbnailCropX,
471 $this->thumbnailCropY,
472 $this->thumbnail_image_width,
473 $this->thumbnail_image_height,
474 $this->thumbnailCropW,
475 $this->thumbnailCropH
478 …$this->DebugMessage('memory_get_usage() after copy-resize = '.(function_exists('memory_get_usage')…
479 imagedestroy($this->gdimg_source);
480 …$this->DebugMessage('memory_get_usage() after imagedestroy = '.(function_exists('memory_get_usage'…
482 $this->phpThumbDebug('8i');
483 $this->AntiOffsiteLinking();
484 $this->phpThumbDebug('8j');
485 $this->ApplyFilters();
486 $this->phpThumbDebug('8k');
487 $this->AlphaChannelFlatten();
488 $this->phpThumbDebug('8l');
489 $this->MaxFileSize();
490 $this->phpThumbDebug('8m');
492 $this->DebugMessage('GenerateThumbnail() completed successfully', __FILE__, __LINE__);
499 …if (!$this->useRawIMoutput && !(is_resource($this->gdimg_output) || (is_object($this->gdimg_source…
500 …$this->DebugMessage('RenderOutput() failed because !is_resource($this->gdimg_output)', __FILE__, _…
503 if (!$this->thumbnailFormat) {
504 …$this->DebugMessage('RenderOutput() failed because $this->thumbnailFormat is empty', __FILE__, __L…
507 if ($this->useRawIMoutput) {
508 …$this->DebugMessage('RenderOutput copying $this->IMresizedData ('.strlen($this->IMresizedData).' b…
509 $this->outputImageData = $this->IMresizedData;
525 …$this->DebugMessage('imageinterlace($this->gdimg_output, '. (int) $this->config_output_interlace .…
526 imageinterlace($this->gdimg_output, (int) $this->config_output_interlace);
528 …$this->DebugMessage('RenderOutput() attempting image'.strtolower(@$this->thumbnailFormat).'($this-…
530 switch ($this->thumbnailFormat) {
533 …$this->DebugMessage('GD does not have required built-in support for WBMP output', __FILE__, __LINE…
537 imagewbmp($this->gdimg_output, null, $this->thumbnailQuality);
538 $this->outputImageData = ob_get_contents();
544 …$this->DebugMessage('GD does not have required built-in support for JPEG output', __FILE__, __LINE…
548 imagejpeg($this->gdimg_output, null, $this->thumbnailQuality);
549 $this->outputImageData = ob_get_contents();
554 …$this->DebugMessage('GD does not have required built-in support for PNG output', __FILE__, __LINE_…
569 if (($this->thumbnailQuality >= -1) && ($this->thumbnailQuality <= 9)) {
570 $PNGquality = $this->thumbnailQuality;
572 …$this->DebugMessage('Specified thumbnailQuality "'.$this->thumbnailQuality.'" is outside the accep…
575 imagepng($this->gdimg_output, null, $PNGquality);
577 imagepng($this->gdimg_output);
579 $this->outputImageData = ob_get_contents();
584 …$this->DebugMessage('GD does not have required built-in support for GIF output', __FILE__, __LINE_…
588 imagegif($this->gdimg_output);
589 $this->outputImageData = ob_get_contents();
594 …$this->DebugMessage('GD does not have required built-in support for WebP output', __FILE__, __LINE…
598 imagewebp($this->gdimg_output, null, $this->thumbnailQuality);
599 $this->outputImageData = ob_get_contents();
604 …$this->DebugMessage('GD does not have required built-in support for AVIF output', __FILE__, __LINE…
608 imageavif($this->gdimg_output, null, $this->thumbnailQuality);
609 $this->outputImageData = ob_get_contents();
614 imagebmp($this->gdimg_output);
615 $this->outputImageData = ob_get_contents();
618 …$this->DebugMessage('GD does not have required built-in support for BMP output', __FILE__, __LINE_…
620 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.bmp.php" which is required for BMP fo…
625 $this->outputImageData = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
631 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.ico.php" which is required for ICO fo…
636 $arrayOfOutputImages = array($this->gdimg_output);
637 $this->outputImageData = $phpthumb_ico->GD2ICOstring($arrayOfOutputImages);
642 …$this->DebugMessage('RenderOutput failed because $this->thumbnailFormat "'.$this->thumbnailFormat.…
647 if (!$this->outputImageData) {
648 … $this->DebugMessage('RenderOutput() for "'.$this->thumbnailFormat.'" failed', __FILE__, __LINE__);
652 …$this->DebugMessage('RenderOutput() completing with $this->outputImageData = '.strlen($this->outpu…
660 …$this->DebugMessage('RenderToFile() failed because $filename ('.$filename.') is a URL', __FILE__, …
667 $renderfilename = $this->ResolveFilenameToAbsolute($renderfilename);
670 …$this->DebugMessage('RenderToFile() failed because "'.dirname($renderfilename).'/" is not writable…
674 …$this->DebugMessage('RenderToFile() failed because "'.$renderfilename.'" is not writable', __FILE_…
678 if ($this->RenderOutput()) {
679 if (file_put_contents($renderfilename, $this->outputImageData)) {
680 @chmod($renderfilename, $this->getParameter('config_file_create_mask'));
681 $this->DebugMessage('RenderToFile('.$renderfilename.') succeeded', __FILE__, __LINE__);
685 …$this->DebugMessage('RenderOutput ['.$this->thumbnailFormat.'('.$renderfilename.')] did not appear…
688 …$this->DebugMessage('RenderOutput ['.$this->thumbnailFormat.'('.$renderfilename.')] failed', __FIL…
696 $this->purgeTempFiles();
698 …if (!$this->useRawIMoutput && !(is_resource($this->gdimg_output) || (is_object($this->gdimg_source…
699 …$this->DebugMessage('OutputThumbnail() failed because !is_resource($this->gdimg_output)', __FILE__…
703 return $this->ErrorImage('OutputThumbnail() failed - headers already sent');
706 …:SanitizeFilename(is_string($this->sia) ? $this->sia : ($this->down ? $this->down : 'phpThumb_gene…
707 …$this->DebugMessage('Content-Disposition header filename set to "'.$downloadfilename.'"', __FILE__…
709 …header('Content-Disposition: '.($this->down ? 'attachment' : 'inline').'; filename="'.$downloadfil…
711 …$this->DebugMessage('failed to send Content-Disposition header because $downloadfilename is empty'…
714 if ($this->useRawIMoutput) {
716 header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
717 echo $this->IMresizedData;
721 …$this->DebugMessage('imageinterlace($this->gdimg_output, '. (int) $this->config_output_interlace .…
722 imageinterlace($this->gdimg_output, (int) $this->config_output_interlace);
723 switch ($this->thumbnailFormat) {
729 $ImageOutFunction = 'image'.$this->thumbnailFormat;
731 $this->DebugMessage($ImageOutFunction.' is not available', __FILE__, __LINE__);
734 header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
735 if ($this->thumbnailFormat == 'gif') {
736 @$ImageOutFunction($this->gdimg_output);
738 @$ImageOutFunction($this->gdimg_output, null, $this->thumbnailQuality);
744 header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
745 imagebmp($this->gdimg_output);
749 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.bmp.php" which is required for BMP fo…
754 $bmp_data = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
757 $this->DebugMessage('$phpthumb_bmp->GD2BMPstring() failed', __FILE__, __LINE__);
760 header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
763 $this->DebugMessage('new phpthumb_bmp() failed', __FILE__, __LINE__);
770 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.ico.php" which is required for ICO fo…
775 $arrayOfOutputImages = array($this->gdimg_output);
779 $this->DebugMessage('$phpthumb_ico->GD2ICOstring() failed', __FILE__, __LINE__);
782 header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat));
785 $this->DebugMessage('new phpthumb_ico() failed', __FILE__, __LINE__);
791 …$this->DebugMessage('OutputThumbnail failed because $this->thumbnailFormat "'.$this->thumbnailForm…
803this->DebugMessage('CleanUpCacheDirectory() set to purge ('.(null === $this->config_cache_maxage ?…
805 if (!is_writable($this->config_cache_directory)) {
806 …$this->DebugMessage('CleanUpCacheDirectory() skipped because "'.$this->config_cache_directory.'" i…
811 …$phpThumbCacheStats_filename = $this->config_cache_directory.DIRECTORY_SEPARATOR.'phpThumbCacheSta…
813 …$this->DebugMessage('CleanUpCacheDirectory() skipped because "'.$phpThumbCacheStats_filename.'" is…
817 $this->DebugMessage('touch('.$phpThumbCacheStats_filename.') failed', __FILE__, __LINE__);
822 …if (($this->config_cache_maxage > 0) || ($this->config_cache_maxsize > 0) || ($this->config_cache_…
825 …$AllFilesInCacheDirectory = phpthumb_functions::GetAllFilesInSubfolders($this->config_cache_direct…
827 …if (preg_match('#'.preg_quote($this->config_cache_prefix).'#i', $fullfilename) && file_exists($ful…
836 …$this->DebugMessage('CleanUpCacheDirectory() skipped because $CacheDirOldFilesSize is empty (phpth…
844 $this->DebugMessage('deleting "'.$fullfilename.'"', __FILE__, __LINE__);
852 …$this->DebugMessage('CleanUpCacheDirectory() purged '.count($DeletedKeys['zerobyte']).' zero-byte …
855 if ($this->config_cache_maxfiles > 0) {
859 if ($TotalCachedFiles > $this->config_cache_maxfiles) {
860 $this->DebugMessage('deleting "'.$fullfilename.'"', __FILE__, __LINE__);
870 …$this->DebugMessage('CleanUpCacheDirectory() purged '.count($DeletedKeys['maxfiles']).' files base…
877 if ($this->config_cache_maxage > 0) {
878 $mindate = time() - $this->config_cache_maxage;
883 $this->DebugMessage('deleting "'.$fullfilename.'"', __FILE__, __LINE__);
893 …$this->DebugMessage('CleanUpCacheDirectory() purged '.count($DeletedKeys['maxage']).' files based …
900 if ($this->config_cache_maxsize > 0) {
904 if ($TotalCachedFileSize > $this->config_cache_maxsize) {
905 $this->DebugMessage('deleting "'.$fullfilename.'"', __FILE__, __LINE__);
915 …$this->DebugMessage('CleanUpCacheDirectory() purged '.count($DeletedKeys['maxsize']).' files based…
923 …$this->DebugMessage('skipping CleanUpCacheDirectory() because config set to not use it', __FILE__,…
929 …$this->DebugMessage('CleanUpCacheDirectory() purged '.$totalpurged.' files (from '.count($AllFiles…
934 $empty_dirs[$this->realPathSafe($fullfilename)] = 1;
936 unset($empty_dirs[$this->realPathSafe(dirname($fullfilename))]);
942 if ($empty_dir == $this->config_cache_directory) {
948 $this->DebugMessage('failed to rmdir('.$empty_dir.')', __FILE__, __LINE__);
951 $this->DebugMessage('purged '.$totalpurgeddirs.' empty directories', __FILE__, __LINE__);
960 $class_vars = get_class_vars(get_class($this));
964 $this->$key = $value;
967 $this->phpThumb(); // re-initialize some class variables
974 …if (is_resource($this->gdimg_source) || (is_object($this->gdimg_source) && $this->gdimg_source ins…
975 …$this->DebugMessage('ResolveSource() exiting because is_resource($this->gdimg_source)', __FILE__, …
978 if ($this->rawImageData) {
979 $this->sourceFilename = null;
980 …$this->DebugMessage('ResolveSource() exiting because $this->rawImageData is set ('.number_format(s…
983 if ($this->sourceFilename) {
984 $this->sourceFilename = $this->ResolveFilenameToAbsolute($this->sourceFilename);
985 …$this->DebugMessage('$this->sourceFilename set to "'.$this->sourceFilename.'"', __FILE__, __LINE__…
986 } elseif ($this->src) {
987 $this->sourceFilename = $this->ResolveFilenameToAbsolute($this->src);
988 …$this->DebugMessage('$this->sourceFilename set to "'.$this->sourceFilename.'" from $this->src ('.$
990 return $this->ErrorImage('$this->sourceFilename and $this->src are both empty');
992 …if ($this->iswindows && ((substr($this->sourceFilename, 0, 2) == '//') || (substr($this->sourceFil…
994 } elseif (preg_match('#^[a-z0-9]+://#i', $this->sourceFilename, $protocol_matches)) {
995 if (preg_match('#^(f|ht)tps?\://#i', $this->sourceFilename)) {
997 if ($this->config_http_user_agent) {
998 ini_set('user_agent', $this->config_http_user_agent);
1001 …return $this->ErrorImage('only FTP and HTTP/HTTPS protocols are allowed, "'.$protocol_matches[1].'…
1003 } elseif (!@file_exists($this->sourceFilename)) {
1004 return $this->ErrorImage('"'.$this->sourceFilename.'" does not exist');
1005 } elseif (!@is_file($this->sourceFilename)) {
1006 return $this->ErrorImage('"'.$this->sourceFilename.'" is not a file');
1014 if ($this->thumbnailFormat && $alreadyCalled) {
1028 $this->thumbnailFormat = 'ico';
1034 $this->thumbnailFormat = 'wbmp';
1038 $this->thumbnailFormat = 'gif';
1042 $this->thumbnailFormat = 'avif';
1046 $this->thumbnailFormat = 'webp';
1050 $this->thumbnailFormat = 'png';
1054 $this->thumbnailFormat = 'jpeg';
1058 …$this->DebugMessage('imagetypes() does not exist - GD support might not be enabled?', __FILE__, _…
1060 if ($this->ImageMagickVersion()) {
1062 …$this->DebugMessage('Addding ImageMagick formats to $AvailableImageOutputFormats ('.implode(';', $…
1068 …$this->DebugMessage('$AvailableImageOutputFormats = array('.implode(';', $AvailableImageOutputForm…
1070 $this->f = (!empty($this->f) ? $this->f : '');
1071 $this->f = preg_replace('#[^a-z]#', '', strtolower($this->f));
1072 if (strtolower($this->config_output_format) == 'jpg') {
1073 $this->config_output_format = 'jpeg';
1075 if (strtolower($this->f) == 'jpg') {
1076 $this->f = 'jpeg';
1078 …if (phpthumb_functions::CaseInsensitiveInArray($this->config_output_format, $AvailableImageOutputF…
1080 …$this->DebugMessage('$this->thumbnailFormat set to $this->config_output_format "'.strtolower($this
1081 $this->thumbnailFormat = strtolower($this->config_output_format);
1082 } elseif ($this->config_output_format) {
1083 …$this->DebugMessage('$this->thumbnailFormat staying as "'.$this->thumbnailFormat.'" because $this-…
1085 …if ($this->f && phpthumb_functions::CaseInsensitiveInArray($this->f, $AvailableImageOutputFormats)…
1087 …$this->DebugMessage('$this->thumbnailFormat set to $this->f "'.strtolower($this->f).'"', __FILE__,…
1088 $this->thumbnailFormat = strtolower($this->f);
1089 } elseif ($this->f) {
1090 …$this->DebugMessage('$this->thumbnailFormat staying as "'.$this->thumbnailFormat.'" because $this-…
1096 $this->thumbnailQuality = max(1, min(99, ($this->q ? (int) $this->q : 75)));
1097 …$this->DebugMessage('$this->thumbnailQuality set to "'.$this->thumbnailQuality.'"', __FILE__, __LI…
1105 …$this->DebugMessage('setCacheDirectory() starting with config_cache_directory = "'.$this->config_c…
1106 if ($this->config_cache_directory && ($this->config_cache_directory[0] == '.')) {
1107 if (preg_match('#^(f|ht)tps?\://#i', $this->src)) {
1108 if (!$this->config_cache_disable_warning) {
1109 …$this->ErrorImage('$this->config_cache_directory ('.$this->config_cache_directory.') cannot be use…
1111 } elseif ($this->src) {
1113 …$this->config_cache_directory = dirname($this->ResolveFilenameToAbsolute($this->src)).DIRECTORY_SE…
1118 if (substr($this->config_cache_directory, -1) == '/') {
1119 $this->config_cache_directory = substr($this->config_cache_directory, 0, -1);
1121 if ($this->iswindows) {
1122 …$this->config_cache_directory = str_replace('/', DIRECTORY_SEPARATOR, $this->config_cache_director…
1124 if ($this->config_cache_directory) {
1125 $real_cache_path = $this->realPathSafe($this->config_cache_directory);
1127 …$this->DebugMessage('$this->realPathSafe($this->config_cache_directory) failed for "'.$this->confi…
1128 if (!is_dir($this->config_cache_directory)) {
1129 $this->DebugMessage('!is_dir('.$this->config_cache_directory.')', __FILE__, __LINE__);
1133 …$this->DebugMessage('setting config_cache_directory to $this->realPathSafe('.$this->config_cache_d…
1134 $this->config_cache_directory = $real_cache_path;
1137 if (!is_dir($this->config_cache_directory)) {
1138 if (!$this->config_cache_disable_warning) {
1139 …$this->ErrorImage('$this->config_cache_directory ('.$this->config_cache_directory.') does not exis…
1141 …$this->DebugMessage('$this->config_cache_directory ('.$this->config_cache_directory.') is not a di…
1142 $this->config_cache_directory = null;
1143 } elseif (!@is_writable($this->config_cache_directory)) {
1144 …$this->DebugMessage('$this->config_cache_directory is not writable ('.$this->config_cache_director…
1147 $this->InitializeTempDirSetting();
1148 …s_dir($this->config_temp_directory) && !@is_writable($this->config_temp_directory) && @is_dir($thi…
1149 …$this->DebugMessage('setting $this->config_temp_directory = $this->config_cache_directory ('.$this
1150 $this->config_temp_directory = $this->config_cache_directory;
1202 $this->applyPathSegment($parts, $segment);
1212 …if (preg_match('#^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $this->realPathSafe($one_dir)…
1226 $this->DebugMessage('open_basedir: "'.$ini_text.'"', __FILE__, __LINE__);
1230 $open_basedirs[$key] = $this->realPathSafe($value);
1234 return (empty($open_basedirs) || $this->matchPath($path, $open_basedirs));
1240 …$this->DebugMessage('resolvePath: '.$path.' (allowed_dirs: '.print_r($allowed_dirs, true).')', __F…
1243 if (!$this->config_allow_src_above_docroot) {
1244 array_unshift($allowed_dirs, $this->realPathSafe($this->config_document_root));
1246 if (!$this->config_allow_src_above_phpthumb) {
1247 array_unshift($allowed_dirs, $this->realPathSafe( __DIR__ ));
1250 …$this->DebugMessage('resolvePath: checks disabled, returning '.$this->realPathSafe($path), __FILE_…
1251 return $this->realPathSafe($path);
1259 …$this->DebugMessage('resolvePath: iteration, path='.$path.', base path = '.$allowed_dirs[0], __FIL…
1266 $this->applyPathSegment($parts, $segments[$i]);
1268 if ($this->isInOpenBasedir($thispart)) {
1275 $this->DebugMessage('resolvePath: stop at component '.$i, __FILE__, __LINE__);
1278 $this->DebugMessage('resolvePath: stop at path='.$path, __FILE__, __LINE__);
1279 if (!$this->matchPath($path, $allowed_dirs)) {
1280 $this->DebugMessage('resolvePath: no match, returning null', __FILE__, __LINE__);
1284 $this->DebugMessage('resolvePath: path parsed, over', __FILE__, __LINE__);
1289 $this->DebugMessage('resolvePath: symlink matched, target='.$path, __FILE__, __LINE__);
1301 if ($this->config_auto_allow_symlinks) {
1313 if (!$this->config_disable_realpath) {
1368 } elseif ($this->iswindows && isset($filename[1]) && ($filename[1] == ':')) {
1373 …} elseif ($this->iswindows && ((substr($filename, 0, 2) == '//') || (substr($filename, 0, 2) == '\…
1380 if (@is_readable($filename) && !@is_readable($this->config_document_root.$filename)) {
1391 $AbsoluteFilename = $this->realPathSafe($filename);
1393 …$this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.$filename.'", but th…
1395 …$this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname($filename).'…
1397 …return $this->ErrorImage('phpthumb_functions::ApacheLookupURIarray() failed for "'.$filename.'". T…
1404 if (preg_match('#^'.preg_quote($this->config_document_root).'#', $filename)) {
1406 …$this->DebugMessage('ResolveFilenameToAbsolute() NOT prepending $this->config_document_root ('.$th…
1408 $AbsoluteFilename = $this->config_document_root.$filename;
1409 …$this->DebugMessage('ResolveFilenameToAbsolute() prepending $this->config_document_root ('.$this->…
1423 $AbsoluteFilename = $this->realPathSafe('.').DIRECTORY_SEPARATOR.$filename;
1425 …$this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['P…
1427 …$this->DebugMessage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERVER['P…
1429 …return $this->ErrorImage('phpthumb_functions::ApacheLookupURIarray() failed for "'.dirname(@$_SERV…
1445 if ($this->iswindows) {
1446 …place('#^'.preg_quote($this->realPathSafe($this->config_document_root)).'#i', str_replace('\\', '\…
1449 …$resolvedAbsoluteFilename = $this->resolvePath($AbsoluteFilename, $this->config_additional_allowed…
1450 …if (!$this->config_allow_src_above_docroot && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_SE…
1451 …$this->DebugMessage('!$this->config_allow_src_above_docroot therefore setting "'.$AbsoluteFilename…
1454 …if (!$this->config_allow_src_above_phpthumb && !preg_match('#^'.preg_quote(str_replace(DIRECTORY_S…
1455 …$this->DebugMessage('!$this->config_allow_src_above_phpthumb therefore setting "'.$AbsoluteFilenam…
1473 } elseif ($this->iswindows) {
1488 if ($this->iswindows) {
1491 …$IMwhichConvertCacheFilename = $this->config_cache_directory.DIRECTORY_SEPARATOR.'phpThumbCacheIMw…
1497 @chmod($IMwhichConvertCacheFilename, $this->getParameter('config_file_create_mask'));
1508 if ($this->issafemode) {
1513 …$IMcommandlineBaseCacheFilename = $this->config_cache_directory.DIRECTORY_SEPARATOR.'phpThumbCache…
1518 $commandline = (null !== $this->config_imagemagick_path ? $this->config_imagemagick_path : '');
1520 …if ($this->config_imagemagick_path && ($this->config_imagemagick_path != $this->realPathSafe($this
1521 if (@is_executable($this->realPathSafe($this->config_imagemagick_path))) {
1522this->DebugMessage('Changing $this->config_imagemagick_path ('.$this->config_imagemagick_path.') t…
1523 $this->config_imagemagick_path = $this->realPathSafe($this->config_imagemagick_path);
1525this->DebugMessage('Leaving $this->config_imagemagick_path as ('.$this->config_imagemagick_path.')…
1528 if (!empty($this->config_imagemagick_path)) {
1529 …$this->DebugMessage(' file_exists('.$this->config_imagemagick_path.') = '. (int) …
1530 …$this->DebugMessage('file_exists_ignoreopenbasedir('.$this->config_imagemagick_path.') = '. (int) …
1531 …$this->DebugMessage(' is_file('.$this->config_imagemagick_path.') = '. (int) …
1532 …$this->DebugMessage(' is_executable('.$this->config_imagemagick_path.') = '. (int) …
1535 if ($this->file_exists_ignoreopenbasedir($this->config_imagemagick_path)) {
1537 …$this->DebugMessage('using ImageMagick path from $this->config_imagemagick_path ('.$this->config_i…
1538 if ($this->iswindows) {
1540 $commandline .= substr($this->config_imagemagick_path, 0, 2);
1541 …hellarg_replacement(str_replace('/', DIRECTORY_SEPARATOR, substr(dirname($this->config_imagemagick…
1542 …$commandline .= ' && '.phpthumb_functions::escapeshellarg_replacement(basename($this->config_image…
1544 $commandline = phpthumb_functions::escapeshellarg_replacement($this->config_imagemagick_path);
1549 $which_convert = $this->ImageMagickWhichConvert();
1550 $IMversion = $this->ImageMagickVersion();
1552 …if ($which_convert && ($which_convert[0] == '/') && $this->file_exists_ignoreopenbasedir($which_co…
1557 …$this->DebugMessage('using ImageMagick path from `which convert` ('.$which_convert.')', __FILE__, …
1562 …$this->DebugMessage('setting ImageMagick path to $this->config_imagemagick_path ('.$this->config_i…
1563 $commandline = $this->config_imagemagick_path;
1567 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting because cannot find convert in $this->con…
1575 @chmod($IMcommandlineBaseCacheFilename, $this->getParameter('config_file_create_mask'));
1586 …$IMversionCacheFilename = $this->config_cache_directory.DIRECTORY_SEPARATOR.'phpThumbCacheIMversio…
1595 $commandline = $this->ImageMagickCommandlineBase();
1599 $this->DebugMessage('ImageMagick version checked with "'.$commandline.'"', __FILE__, __LINE__);
1605 …$this->DebugMessage('ImageMagick did not return recognized version string ('.$versionstring[1].')'…
1607 … $this->DebugMessage('ImageMagick convert --version says "'.@$matches[0].'"', __FILE__, __LINE__);
1611 @chmod($IMversionCacheFilename, $this->getParameter('config_file_create_mask'));
1623 $commandline = $this->ImageMagickCommandlineBase();
1642 …$this->DebugMessage('ImageMagickSwitchAvailable('.implode(';', $switchname).') = '. (int) $allOK .…
1645 …$this->DebugMessage('ImageMagickSwitchAvailable('.$switchname.') = '. (int) $allOK .'', __FILE__, …
1655 $commandline = $this->ImageMagickCommandlineBase();
1667 if ($IMtempSourceFilename = $this->phpThumb_tempnam()) {
1668 $IMtempSourceFilename = $this->realPathSafe($IMtempSourceFilename);
1674 fwrite($fp_tempfile, $this->rawImageData);
1676 @chmod($IMtempSourceFilename, $this->getParameter('config_file_create_mask'));
1677 $this->sourceFilename = $IMtempSourceFilename;
1678 …$this->DebugMessage('ImageMagickThumbnailToGD() setting $this->sourceFilename to "'.$IMtempSourceF…
1680 …$this->DebugMessage('ImageMagickThumbnailToGD() FAILED setting $this->sourceFilename to "'.$IMtemp…
1685 …$this->DebugMessage('SourceDataToTempFile() FAILED because $this->phpThumb_tempnam() failed', __FI…
1693 $this->useRawIMoutput = true;
1700 if (isset($this->$parameter)) {
1701 …$this->DebugMessage('cannot process with ImageMagick because "'.$parameter.'" is set', __FILE__, _…
1702 $this->useRawIMoutput = false;
1712 if (isset($this->$parameter)) {
1713 …$this->DebugMessage('$this->useRawIMoutput=false because "'.$parameter.'" is set', __FILE__, __LIN…
1714 $this->useRawIMoutput = false;
1719 …$this->DebugMessage('$this->useRawIMoutput='.($this->useRawIMoutput ? 'true' : 'false').' after ch…
1721 $outputFormat = $this->thumbnailFormat;
1723 if ($this->useRawIMoutput) {
1724 switch ($this->thumbnailFormat) {
1727 $this->is_alpha = true;
1731 $this->is_alpha = true;
1739 $this->is_alpha = true;
1743 $this->is_alpha = true;
1746 …$this->DebugMessage('Forcing output to PNG because $this->thumbnailFormat ('.$this->thumbnailForma…
1749 $this->is_alpha = true;
1750 $this->useRawIMoutput = false;
1756 $this->useRawIMoutput = true;
1762 $this->is_alpha = true;
1763 $this->useRawIMoutput = false;
1768 if (!$this->sourceFilename && $this->rawImageData) {
1769 $this->SourceDataToTempFile();
1771 if (!$this->sourceFilename) {
1772 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting because $this->sourceFilename is empty', …
1773 $this->useRawIMoutput = false;
1776 if ($this->issafemode) {
1777 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting because safe_mode is enabled', __FILE__, …
1778 $this->useRawIMoutput = false;
1788 $commandline = $this->ImageMagickCommandlineBase();
1790 …place('#[/\\\\]#', DIRECTORY_SEPARATOR, $this->sourceFilename).(($outputFormat == 'gif') ? '' : '[…
1791 if ($IMtempfilename = $this->phpThumb_tempnam()) {
1792 $IMtempfilename = $this->realPathSafe($IMtempfilename);
1795 if ($this->ImageMagickSwitchAvailable('thumbnail') && $this->config_imagemagick_use_thumbnail) {
1801 …$commandline_test = $this->ImageMagickCommandlineBase().' logo: -resize 1x '.phpthumb_functions::e…
1804 …$this->DebugMessage('IMuseExplicitImageOutputDimensions = '. (int) $IMuseExplicitImageOutputDimens…
1808 @chmod($IMtempfilename, $this->getParameter('config_file_create_mask'));
1814 $getimagesize = getimagesize($this->sourceFilename);
1818 …$this->DebugMessage('getimagesize('.$this->sourceFilename.') SUCCEEDED: '.print_r($getimagesize, t…
1820 …$this->DebugMessage('getimagesize('.$this->sourceFilename.') FAILED with error "'.$GetImageSizeErr…
1822 if (null !== $this->dpi && $this->ImageMagickSwitchAvailable('density')) {
1829 $commandline .= ' -density '.phpthumb_functions::escapeshellarg_replacement($this->dpi);
1833 …$this->DebugMessage('getimagesize('.$this->sourceFilename.') returned [w='.$getimagesize[0].';h='.…
1834 $this->source_width = $getimagesize[0];
1835 $this->source_height = $getimagesize[1];
1836 …$this->DebugMessage('source dimensions set to '.$this->source_width.'x'.$this->source_height, __FI…
1837 $this->SetOrientationDependantWidthHeight();
1839 if (!preg_match('#('.implode('|', $this->AlphaCapableFormats).')#i', $outputFormat)) {
1841 … -background '.phpthumb_functions::escapeshellarg_replacement('#'.($this->bg ? $this->bg : 'FFFFFF…
1846 if ($getimagesize[2] == IMAGETYPE_PNG && !$this->bg) {
1853 if ($this->source_width || $this->source_height) {
1854 if ($this->zc) {
1857 if (!empty($this->fltr)) {
1858 foreach ($this->fltr as $key => $value) {
1865 $wAll = (int) max($this->w, $this->wp, $this->wl, $this->ws) - (2 * $borderThickness);
1866 $hAll = (int) max($this->h, $this->hp, $this->hl, $this->hs) - (2 * $borderThickness);
1867 $imAR = $this->source_width / $this->source_height;
1869 …$side = phpthumb_functions::nonempty_min($this->source_width, $this->source_height, max($wAll, $h…
1870 …$sideX = phpthumb_functions::nonempty_min($this->source_width, $wAll, round(…
1871 …$sideY = phpthumb_functions::nonempty_min( $this->source_height, $hAll, round(…
1874 if ($this->aoe == 1) {
1880 switch (strtoupper($this->zc)) {
1917 if ($this->ImageMagickSwitchAvailable('repage')) {
1920 …$this->DebugMessage('Skipping "+repage" because ImageMagick (v'.$this->ImageMagickVersion().') doe…
1923 } elseif ($this->sw || $this->sh || $this->sx || $this->sy) {
1926 …$crop_param .= ($this->sw ? (($this->sw < 2) ? round($this->sw * $this->source_width) : $thi…
1927 …$crop_param .= 'x'.($this->sh ? (($this->sh < 2) ? round($this->sh * $this->source_height) : $thi…
1928 $crop_param .= '+'.(($this->sx < 2) ? round($this->sx * $this->source_width) : $this->sx);
1929 $crop_param .= '+'.(($this->sy < 2) ? round($this->sy * $this->source_height) : $this->sy);
1937 if ($this->w || $this->h) {
1944 …$this->DebugMessage('Skipping "-repage" because ImageMagick (v'.$this->ImageMagickVersion().') doe…
1947 if ($this->w && !$this->h) {
1948 $this->h = ceil($this->w / ($this->source_width / $this->source_height));
1949 } elseif ($this->h && !$this->w) {
1950 $this->w = ceil($this->h * ($this->source_width / $this->source_height));
1953 … ' -'.$IMresizeParameter.' '.phpthumb_functions::escapeshellarg_replacement($this->w.'x'.$this->h);
1958 if ($this->iar && ((int) $this->w > 0) && ((int) $this->h > 0)) {
1960 list($nw, $nh) = phpthumb_functions::TranslateWHbyAngle($this->w, $this->h, $this->ra);
1965 } elseif ($this->far && ((int) $this->w > 0) && ((int) $this->h > 0)) {
1967 …acement(phpthumb_functions::nonempty_min($this->w, $getimagesize[0]).'x'.phpthumb_functions::nonem…
1969 if ($this->bg) {
1970 … $commandline .= ' -background ' . phpthumb_functions::escapeshellarg_replacement('#' . $this->bg);
1974 … $commandline .= ' -extent '.phpthumb_functions::escapeshellarg_replacement($this->w.'x'.$this->h);
1978 …$this->w = (($this->aoe && $this->w) ? $this->w : ($this->w ? phpthumb_functions::nonempty_min($th…
1979 …$this->h = (($this->aoe && $this->h) ? $this->h : ($this->h ? phpthumb_functions::nonempty_min($th…
1980 if ($this->w || $this->h) {
1982 if ($this->w && !$this->h) {
1983 $this->h = ceil($this->w / ($this->source_width / $this->source_height));
1984 } elseif ($this->h && !$this->w) {
1985 $this->w = ceil($this->h * ($this->source_width / $this->source_height));
1988 list($nw, $nh) = phpthumb_functions::TranslateWHbyAngle($this->w, $this->h, $this->ra);
2000 $this->DebugMessage('getimagesize('.$this->sourceFilename.') failed', __FILE__, __LINE__);
2001 if ($this->w || $this->h) {
2002 … $exactDimensionsBang = (($this->iar && ((int) $this->w > 0) && ((int) $this->h > 0)) ? '!' : '');
2005 …'.phpthumb_functions::escapeshellarg_replacement(($this->w ? $this->w : '9999').'x'.($this->h ? $t…
2007 …resizeParameter.' '.phpthumb_functions::escapeshellarg_replacement($this->w.'x'.$this->h.$exactDim…
2013 if ($this->ra) {
2014 $this->ra = (int) $this->ra;
2015 if ($this->ImageMagickSwitchAvailable('rotate')) {
2016 …atch('#('.implode('|', $this->AlphaCapableFormats).')#i', $outputFormat) || phpthumb_functions::ve…
2017 $this->DebugMessage('Using ImageMagick rotate', __FILE__, __LINE__);
2018 $commandline .= ' -rotate '.phpthumb_functions::escapeshellarg_replacement($this->ra);
2019 if (($this->ra % 90) != 0) {
2020 if (preg_match('#('.implode('|', $this->AlphaCapableFormats).')#i', $outputFormat)) {
2024 … -background '.phpthumb_functions::escapeshellarg_replacement('#'.($this->bg ? $this->bg : 'FFFFFF…
2027 $this->ra = 0;
2029 …$this->DebugMessage('Not using ImageMagick rotate because alpha background buggy before v6.3.7', _…
2032 $this->DebugMessage('Not using ImageMagick rotate because not supported', __FILE__, __LINE__);
2037 foreach ($this->fltr as $filterkey => $filtercommand) {
2041 if ($this->ImageMagickSwitchAvailable('modulate')) {
2048 if ($this->ImageMagickSwitchAvailable('contrast')) {
2068 if ($this->ImageMagickSwitchAvailable(array('colorspace', 'modulate'))) {
2080 if ($this->ImageMagickSwitchAvailable(array('colorspace', 'modulate'))) {
2092 if ($this->ImageMagickSwitchAvailable(array('colorspace', 'modulate'))) {
2100 if ($this->ImageMagickSwitchAvailable(array('fill', 'colorize'))) {
2109 if ($this->ImageMagickSwitchAvailable('sepia-tone')) {
2123 if ($this->ImageMagickSwitchAvailable('gamma')) {
2131 if ($this->ImageMagickSwitchAvailable('negate')) {
2139 if ($this->ImageMagickSwitchAvailable(array('threshold', 'dither', 'monochrome'))) {
2148 if ($this->ImageMagickSwitchAvailable(array('colors', 'dither'))) {
2159 if ($this->ImageMagickSwitchAvailable(array('flip', 'flop'))) {
2171 if ($this->ImageMagickSwitchAvailable('edge')) {
2179 if ($this->ImageMagickSwitchAvailable(array('emboss', 'negate'))) {
2197 … if (($method > 1) && !$this->ImageMagickSwitchAvailable(array('channel', 'contrast-stretch'))) {
2202 foreach ($this->fltr as $fltr_key => $fltr_value) {
2205 …$this->DebugMessage('Setting "lvl" filter method to "0" (from "'.$method.'") because white-balance…
2216 if ($this->ImageMagickSwitchAvailable('contrast-stretch')) {
2230 if ($this->ImageMagickSwitchAvailable('normalize')) {
2242 … $this->DebugMessage('unsupported method ('.$method.') for "lvl" filter', __FILE__, __LINE__);
2245 if (isset($this->fltr[$filterkey]) && ($method > 1)) {
2246 $this->fltr[$filterkey] = $command.'|'.$band.'|0|'.$threshold;
2247 …$this->DebugMessage('filter "lvl" remapped from method "'.$method.'" to method "0" because ImageMa…
2252 if ($this->ImageMagickSwitchAvailable(array('channel', 'contrast-stretch'))) {
2268 if ($this->ImageMagickSwitchAvailable('blur')) {
2280 if ($this->ImageMagickSwitchAvailable('gaussian-blur')) {
2283 } elseif ($this->ImageMagickSwitchAvailable('gaussian')) {
2290 if ($this->ImageMagickSwitchAvailable('unsharp')) {
2301 if ($this->ImageMagickSwitchAvailable(array('border', 'bordercolor', 'thumbnail', 'crop'))) {
2302 if (!$this->zc) {
2309 …$color = ((!empty($this->bc) && phpthumb_functions::IsHexColor($this->bc)) ? $this->bc : '000000');
2374 …$this->DebugMessage('Unknown $this->fltr['.$filterkey.'] ('.$filtercommand.') -- deleting filter c…
2378 if (!isset($this->fltr[$filterkey])) {
2379 …$this->DebugMessage('Processed $this->fltr['.$filterkey.'] ('.$filtercommand.') with ImageMagick',…
2381 …$this->DebugMessage('Skipping $this->fltr['.$filterkey.'] ('.$filtercommand.') with ImageMagick', …
2384 …$this->DebugMessage('Remaining $this->fltr after ImageMagick: ('.$this->phpThumbDebugVarDump($this
2385 if (count($this->fltr) > 0) {
2386 $this->useRawIMoutput = false;
2389 if (preg_match('#jpe?g#i', $outputFormat) && $this->q) {
2390 if ($this->ImageMagickSwitchAvailable(array('quality', 'interlace'))) {
2391 …$commandline .= ' -quality '.phpthumb_functions::escapeshellarg_replacement($this->thumbnailQualit…
2392 if ($this->config_output_interlace) {
2399 if (!$this->iswindows) {
2402 $this->DebugMessage('ImageMagick called as ('.$commandline.')', __FILE__, __LINE__);
2406 $this->FatalError('ImageMagick failed with message ('.trim($IMresult).')');
2407 … $this->DebugMessage('ImageMagick failed with message ('.trim($IMresult).')', __FILE__, __LINE__);
2408 if ($this->iswindows && !$IMresult) {
2409 …$this->DebugMessage('Check to make sure that PHP has read+write permissions to "'.dirname($IMtempf…
2415 unset($this->fltr[$filterkey]);
2417 $this->IMresizedData = file_get_contents($IMtempfilename);
2419 …$this->DebugMessage('getimagesize('.$IMtempfilename.') returned [w='.$getimagesize_imresized[0].';…
2420 …if (($this->config_max_source_pixels > 0) && (($getimagesize_imresized[0] * $getimagesize_imresize…
2421this->DebugMessage('skipping ImageMagickThumbnailToGD::'.$ImageCreateFunction.'() because IM outpu…
2422 …} elseif (function_exists(@$ImageCreateFunction) && ($this->gdimg_source = @$ImageCreateFunction($…
2423 $this->source_width = imagesx($this->gdimg_source);
2424 $this->source_height = imagesy($this->gdimg_source);
2425 …$this->DebugMessage('ImageMagickThumbnailToGD::'.$ImageCreateFunction.'() succeeded, $this->gdimg_…
2426 …$this->DebugMessage('ImageMagickThumbnailToGD() returning $this->IMresizedData ('.strlen($this->IM…
2428 $this->useRawIMoutput = true;
2429 …$this->DebugMessage('$this->useRawIMoutput set to TRUE because '.@$ImageCreateFunction.'('.$IMtemp…
2432 $this->DebugMessage('deleting "'.$IMtempfilename.'"', __FILE__, __LINE__);
2439 $this->DebugMessage('deleting "'.$IMtempfilename.'"', __FILE__, __LINE__);
2443 } elseif ($this->issafemode) {
2444 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting because PHP safe_mode is enabled and phpT…
2445 $this->useRawIMoutput = false;
2448 $this->DebugMessage('deleting "'.$IMtempfilename.'"', __FILE__, __LINE__);
2451 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting, phpThumb_tempnam() failed', __FILE__, __…
2454 …$this->DebugMessage('ImageMagickThumbnailToGD() aborting because ImageMagickCommandlineBase() fail…
2456 $this->useRawIMoutput = false;
2462 if ($this->ra || $this->ar) {
2464 $this->DebugMessage('!function_exists(imagerotate)', __FILE__, __LINE__);
2468 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for ap…
2472 $this->config_background_hexcolor = ($this->bg ? $this->bg : $this->config_background_hexcolor);
2473 if (!phpthumb_functions::IsHexColor($this->config_background_hexcolor)) {
2474 …return $this->ErrorImage('Invalid hex color string "'.$this->config_background_hexcolor.'" for par…
2478 if ($this->ra) {
2480 $rotate_angle = (float) $this->ra;
2484 if ($this->ar == 'x') {
2486 if ($this->sourceFilename) {
2488 if ($exif_data = @exif_read_data($this->sourceFilename, 'IFD0')) {
2505 …$this->DebugMessage('EXIF auto-rotate failed because unknown $exif_data[Orientation] "'.@$exif_dat…
2509 …$this->DebugMessage('EXIF auto-rotate set to '.$rotate_angle.' degrees ($exif_data[Orientation] = …
2511 … $this->DebugMessage('failed: exif_read_data('.$this->sourceFilename.')', __FILE__, __LINE__);
2515 $this->DebugMessage('!function_exists(exif_read_data)', __FILE__, __LINE__);
2519 …$this->DebugMessage('Cannot auto-rotate from EXIF data because $this->sourceFilename is empty', __…
2523 …$this->DebugMessage('Cannot auto-rotate from EXIF data because PHP is less than v4.2.0 ('. PHP_VER…
2526 } elseif (($this->ar == 'l') && ($this->source_height > $this->source_width)) {
2528 } elseif (($this->ar == 'L') && ($this->source_height > $this->source_width)) {
2530 } elseif (($this->ar == 'p') && ($this->source_width > $this->source_height)) {
2532 } elseif (($this->ar == 'P') && ($this->source_width > $this->source_height)) {
2538 $this->is_alpha = true;
2540 …mb_filters::ImprovedImageRotate($this->gdimg_source, $rotate_angle, $this->config_background_hexco…
2541 $this->source_width = imagesx($this->gdimg_source);
2542 $this->source_height = imagesy($this->gdimg_source);
2551 if (!$this->far) {
2556 if (!$this->w || !$this->h) {
2559 $this->thumbnail_width = $this->w;
2560 $this->thumbnail_height = $this->h;
2561 $this->is_alpha = true;
2562 if ($this->thumbnail_image_width >= $this->thumbnail_width) {
2564 $aspectratio = $this->thumbnail_image_height / $this->thumbnail_image_width;
2565 if ($this->w) {
2566 $this->thumbnail_image_height = round($this->thumbnail_image_width * $aspectratio);
2567 $this->thumbnail_height = ($this->h ? $this->h : $this->thumbnail_image_height);
2568 } elseif ($this->thumbnail_image_height < $this->thumbnail_height) {
2569 $this->thumbnail_image_height = $this->thumbnail_height;
2570 $this->thumbnail_image_width = round($this->thumbnail_image_height / $aspectratio);
2575 $aspectratio = $this->thumbnail_image_width / $this->thumbnail_image_height;
2576 if ($this->h) {
2577 $this->thumbnail_image_width = round($this->thumbnail_image_height * $aspectratio);
2578 } elseif ($this->thumbnail_image_width < $this->thumbnail_width) {
2579 $this->thumbnail_image_width = $this->thumbnail_width;
2580 $this->thumbnail_image_height = round($this->thumbnail_image_width / $aspectratio);
2616 …if ($allow && $this->config_nooffsitelink_enabled && (@$_SERVER['HTTP_REFERER'] || $this->config_n…
2617 …$this->DebugMessage('AntiOffsiteLinking() checking $_SERVER[HTTP_REFERER] "'.@$_SERVER['HTTP_REFER…
2618 foreach ($this->config_nooffsitelink_valid_domains as $key => $valid_domain) {
2621 $this->config_nooffsitelink_valid_domains[$key] = $clean_domain;
2624 …if (!$this->OffsiteDomainIsAllowed(@$parsed_url['host'], $this->config_nooffsitelink_valid_domains…
2627 …$this->ErrorImage('AntiOffsiteLinking() - "'.@$parsed_url['host'].'" is NOT in $this->config_nooff…
2629 …$this->DebugMessage('AntiOffsiteLinking() - "'.@$parsed_url['host'].'" is in $this->config_nooffsi…
2633 if ($allow && $this->config_nohotlink_enabled && preg_match('#^(f|ht)tps?\://#i', $this->src)) {
2634 $parsed_url = phpthumb_functions::ParseURLbetter($this->src);
2636 … if (!$this->OffsiteDomainIsAllowed(@$parsed_url['host'], $this->config_nohotlink_valid_domains)) {
2639 …$this->DebugMessage('AntiOffsiteLinking() - "'.$parsed_url['host'].'" is NOT in $this->config_noho…
2641 …$this->DebugMessage('AntiOffsiteLinking() - "'.$parsed_url['host'].'" is in $this->config_nohotlin…
2646 $this->DebugMessage('AntiOffsiteLinking() says this is allowed', __FILE__, __LINE__);
2650 if (!phpthumb_functions::IsHexColor($this->config_error_bgcolor)) {
2651 …return $this->ErrorImage('Invalid hex color string "'.$this->config_error_bgcolor.'" for $this->co…
2653 if (!phpthumb_functions::IsHexColor($this->config_error_textcolor)) {
2654 …return $this->ErrorImage('Invalid hex color string "'.$this->config_error_textcolor.'" for $this->…
2656 if ($this->config_nooffsitelink_erase_image) {
2658 …return $this->ErrorImage($this->config_nooffsitelink_text_message, $this->thumbnail_width, $this->…
2662 …$this->config_nooffsitelink_watermark_src = $this->ResolveFilenameToAbsolute($this->config_nooffsi…
2663 if (is_file($this->config_nooffsitelink_watermark_src)) {
2666 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for ap…
2669 …$watermark_img = $this->ImageCreateFromStringReplacement(file_get_contents($this->config_nooffsite…
2671 $phpthumbFilters->phpThumbObject = &$this;
2674 $phpthumbFilters->WatermarkOverlay($this->gdimg_output, $watermark_img, '*', $opacity, $margin);
2680 …ray = explode("\n", wordwrap($this->config_nooffsitelink_text_message, floor($this->thumbnail_widt…
2681 …$nohotlink_text_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->conf…
2683 …$topoffset = round(($this->thumbnail_height - (count($nohotlink_text_array) * imagefontheight($thi…
2686this->DebugMessage('AntiOffsiteLinking() writing '.count($nohotlink_text_array).' lines of text "'…
2688 …$leftoffset = max(0, round(($this->thumbnail_width - (strlen($textline) * imagefontwidth($this->co…
2689 …imagestring($this->gdimg_output, $this->config_error_fontsize, $leftoffset, $topoffset + ($rowcoun…
2700 if (!$this->is_alpha) {
2702 …$this->DebugMessage('skipping AlphaChannelFlatten() because !$this->is_alpha', __FILE__, __LINE__);
2705 switch ($this->thumbnailFormat) {
2711 …$this->DebugMessage('skipping AlphaChannelFlatten() because ($this->thumbnailFormat == "'.$this->t…
2717 $CurrentImageColorTransparent = imagecolortransparent($this->gdimg_output);
2722 …$this->DebugMessage('AlphaChannelFlatten() failed because GD version is "'.phpthumb_functions::gd_…
2726 …$img_alpha_mixdown_dither = @imagecreatetruecolor(imagesx($this->gdimg_output), imagesy($this->gdi…
2734 for ($x = 0; $x < $this->thumbnail_width; $x++) {
2735 for ($y = 0; $y < $this->thumbnail_height; $y++) {
2736 $PixelColor = phpthumb_functions::GetPixelColor($this->gdimg_output, $x, $y);
2745 imagetruecolortopalette($this->gdimg_output, true, 255);
2748 $TransparentColor = imagecolorallocate($this->gdimg_output, 1, 254, 253);
2749 imagecolortransparent($this->gdimg_output, $TransparentColor);
2752 for ($x = 0; $x < $this->thumbnail_width; $x++) {
2753 for ($y = 0; $y < $this->thumbnail_height; $y++) {
2756 imagesetpixel($this->gdimg_output, $x, $y, $TransparentColor);
2762 …$this->DebugMessage('AlphaChannelFlatten() set image to 255+1 colors with transparency for GIF out…
2766 …$this->DebugMessage('AlphaChannelFlatten() failed imagecreate('.imagesx($this->gdimg_output).', '.…
2772 …$this->DebugMessage('skipping AlphaChannelFlatten() because ($this->thumbnailFormat == "'.$this->t…
2777 …$this->DebugMessage('continuing AlphaChannelFlatten() for output format "'.$this->thumbnailFormat.…
2779 …if ($gdimg_flatten_temp = phpthumb_functions::ImageCreateFunction($this->thumbnail_width, $this->t…
2781 $this->config_background_hexcolor = ($this->bg ? $this->bg : $this->config_background_hexcolor);
2782 if (!phpthumb_functions::IsHexColor($this->config_background_hexcolor)) {
2783 …return $this->ErrorImage('Invalid hex color string "'.$this->config_background_hexcolor.'" for par…
2785 …$background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->config_b…
2786 …imagefilledrectangle($gdimg_flatten_temp, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $…
2787 …imagecopy($gdimg_flatten_temp, $this->gdimg_output, 0, 0, 0, 0, $this->thumbnail_width, $this->thu…
2789 imagealphablending($this->gdimg_output, true);
2790 imagesavealpha($this->gdimg_output, false);
2791 imagecolortransparent($this->gdimg_output, -1);
2792 …imagecopy($this->gdimg_output, $gdimg_flatten_temp, 0, 0, 0, 0, $this->thumbnail_width, $this->thu…
2798 $this->DebugMessage('ImageCreateFunction() failed', __FILE__, __LINE__);
2805 if ($this->fltr && is_array($this->fltr)) {
2807 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.filters.php" which is required for ap…
2811 $phpthumbFilters->phpThumbObject = &$this;
2812 foreach ($this->fltr as $filtercommand) {
2814 …$this->DebugMessage('Attempting to process filter command "'.$command.'('.$parameter.')"', __FILE_…
2817 $phpthumbFilters->Brightness($this->gdimg_output, $parameter);
2821 $phpthumbFilters->Contrast($this->gdimg_output, $parameter);
2825 $phpthumbFilters->Desaturate($this->gdimg_output, $parameter, '');
2829 $phpthumbFilters->Saturation($this->gdimg_output, $parameter, '');
2833 $phpthumbFilters->Grayscale($this->gdimg_output);
2838 …$this->DebugMessage('Skipping Colorize() because gd_version is "'.phpthumb_functions::gd_version()…
2842 $phpthumbFilters->Colorize($this->gdimg_output, $amount, $color);
2847 …$this->DebugMessage('Skipping Sepia() because gd_version is "'.phpthumb_functions::gd_version().'"…
2851 $phpthumbFilters->Sepia($this->gdimg_output, $amount, $color);
2855 $phpthumbFilters->Gamma($this->gdimg_output, $parameter);
2859 $phpthumbFilters->Negative($this->gdimg_output);
2863 $phpthumbFilters->Threshold($this->gdimg_output, $parameter);
2868 …$this->DebugMessage('Skipping ReduceColorDepth() because gd_version is "'.phpthumb_functions::gd_v…
2874 $phpthumbFilters->ReduceColorDepth($this->gdimg_output, $colors, $dither);
2878 …$phpthumbFilters->Flip($this->gdimg_output, strpos(strtolower($parameter), 'x') !== false, strpos(…
2882 $phpthumbFilters->EdgeDetect($this->gdimg_output);
2886 $phpthumbFilters->Emboss($this->gdimg_output);
2891 $phpthumbFilters->Bevel($this->gdimg_output, $width, $color1, $color2);
2900 $phpthumbFilters->HistogramStretch($this->gdimg_output, $band, $method, $threshold);
2904 $phpthumbFilters->WhiteBalance($this->gdimg_output, $parameter);
2909 …$this->DebugMessage('Skipping HistogramOverlay() because gd_version is "'.phpthumb_functions::gd_v…
2921 …$phpthumbFilters->HistogramOverlay($this->gdimg_output, $bands, $colors, $width, $height, $alignme…
2926 …$phpthumbFilters->Frame($this->gdimg_output, $frame_width, $edge_width, $color_frame, $color1, $co…
2931 …$this->DebugMessage('Skipping DropShadow() because gd_version is "'.phpthumb_functions::gd_version…
2934 $this->is_alpha = true;
2936 $phpthumbFilters->DropShadow($this->gdimg_output, $distance, $width, $color, $angle, $fade);
2941 …$this->DebugMessage('Skipping Mask() because gd_version is "'.phpthumb_functions::gd_version().'"'…
2945 $mask_filename = $this->ResolveFilenameToAbsolute($mask_filename);
2953 if ($gdimg_mask = $this->ImageCreateFromStringReplacement($MaskImageData)) {
2957 $this->is_alpha = true;
2958 $phpthumbFilters->ApplyMask($gdimg_mask, $this->gdimg_output);
2961 …$this->DebugMessage('ImageCreateFromStringReplacement() failed for "'.$mask_filename.'"', __FILE__…
2964 $this->DebugMessage('Cannot open mask file "'.$mask_filename.'"', __FILE__, __LINE__);
2970 …$this->DebugMessage('Skipping Ellipse() because gd_version is "'.phpthumb_functions::gd_version().…
2973 $this->is_alpha = true;
2974 $phpthumbFilters->Ellipse($this->gdimg_output);
2979 …$this->DebugMessage('Skipping RoundedImageCorners() because gd_version is "'.phpthumb_functions::g…
2984 …$this->DebugMessage('Skipping RoundedImageCorners('.$radius_x.', '.$radius_y.') because x/y radius…
2987 $this->is_alpha = true;
2988 $phpthumbFilters->RoundedImageCorners($this->gdimg_output, $radius_x, $radius_y);
2993 $phpthumbFilters->Crop($this->gdimg_output, $left, $right, $top, $bottom);
2998 $this->is_alpha = true;
2999 …$phpthumbFilters->ImageBorder($this->gdimg_output, $border_width, $radius_x, $radius_y, $hexcolor_…
3013 $filename = $this->ResolveFilenameToAbsolute($filename);
3021 if ($img_watermark = $this->ImageCreateFromStringReplacement($WatermarkImageData)) {
3023 …$resized_x = max(1, imagesx($this->gdimg_output) - round(2 * (imagesx($this->gdimg_output) * $marg…
3024 …$resized_y = max(1, imagesy($this->gdimg_output) - round(2 * (imagesy($this->gdimg_output) * $marg…
3026 $resized_x = max(1, imagesx($this->gdimg_output) - round(2 * $margin));
3027 $resized_y = max(1, imagesy($this->gdimg_output) - round(2 * $margin));
3032 …resized = phpthumb_functions::ImageCreateFunction(imagesx($this->gdimg_output), imagesy($this->gdi…
3035 …$this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, imagesx($img_waterm…
3039this->ImageResizeFunction($img_source_resized, $this->gdimg_output, 0, 0, 0, 0, imagesx($img_sourc…
3041 …imagecopy($this->gdimg_output, $img_watermark_resized, 0, 0, 0, 0, imagesx($this->gdimg_output), i…
3043 …$this->DebugMessage('phpthumb_functions::ImageCreateFunction('.$resized_x.', '.$resized_y.')', __F…
3047 …$this->DebugMessage('phpthumb_functions::ImageCreateFunction('.imagesx($this->gdimg_output).', '.i…
3055 …$this->ImageResizeFunction($img_watermark_resized, $img_watermark, 0, 0, 0, 0, imagesx($img_waterm…
3056 …$phpthumbFilters->WatermarkOverlay($this->gdimg_output, $img_watermark_resized, 'C', $opacity, $ma…
3059 …$this->DebugMessage('phpthumb_functions::ImageCreateFunction('.$resized_x.', '.$resized_y.')', __F…
3066 …$this->DebugMessage('ImageCreateFromStringReplacement() failed for "'.$filename.'"', __FILE__, __L…
3069 $this->DebugMessage('Cannot open overlay file "'.$filename.'"', __FILE__, __LINE__);
3091 $filename = $this->ResolveFilenameToAbsolute($filename);
3093 if ($img_watermark = $this->ImageCreateFromFilename($filename)) {
3095 … $phpthumbFilters->ImprovedImageRotate($img_watermark, $rotate_angle, 'FFFFFF', null, $this);
3101 …$this->DebugMessage('Scaling watermark by a factor of '.number_format($scale, 4), __FILE__, __LINE…
3106 …$this->ImageResizeFunction($img_watermark2, $img_watermark, 0, 0, 0, 0, imagesx($img_watermark2), …
3109 …$this->DebugMessage('ImageCreateFunction('.($scale * imagesx($img_watermark)).', '.($scale * image…
3116 …$phpthumbFilters->WatermarkOverlay($this->gdimg_output, $img_watermark, $alignment, $opacity, $mar…
3122 … $this->DebugMessage('ImageCreateFromFilename() failed for "'.$filename.'"', __FILE__, __LINE__);
3125 $this->DebugMessage('!is_readable('.$filename.')', __FILE__, __LINE__);
3145 $ttffont = $this->realPathSafe($this->config_ttf_directory.DIRECTORY_SEPARATOR.$ttffont);
3147 $ttffont = $this->ResolveFilenameToAbsolute($ttffont);
3149 …$phpthumbFilters->WatermarkText($this->gdimg_output, $text, $size, $alignment, $hex_color, $ttffon…
3156 $phpthumbFilters->Blur($this->gdimg_output, $radius);
3158 …$this->DebugMessage('Skipping Blur() because gd_version is "'.phpthumb_functions::gd_version().'"'…
3163 $phpthumbFilters->BlurGaussian($this->gdimg_output);
3167 $phpthumbFilters->BlurSelective($this->gdimg_output);
3171 $phpthumbFilters->MeanRemoval($this->gdimg_output);
3175 $phpthumbFilters->Smooth($this->gdimg_output, $parameter);
3188 …$this->DebugMessage('include_once("'. __DIR__ .'/phpthumb.unsharp.php") generated message: "'.$inc…
3190 …$this->DebugMessage('Error including "'. __DIR__ .'/phpthumb.unsharp.php" which is required for un…
3195 phpUnsharpMask::applyUnsharpMask($this->gdimg_output, $amount, $radius, $threshold);
3197 …$this->DebugMessage('Skipping unsharp mask because gd_version is "'.phpthumb_functions::gd_version…
3204 … = (!$newwidth ? imagesx($this->gdimg_output) : ((($newwidth > 0) && ($newwidth < 1)) ? round(…
3205 …t = (!$newheight ? imagesy($this->gdimg_output) : ((($newheight > 0) && ($newheight < 1)) ? round(…
3208 …$scale_x = phpthumb_functions::ScaleToFitInBox(imagesx($this->gdimg_output), imagesx($this->gdimg_…
3209 …$scale_y = phpthumb_functions::ScaleToFitInBox(imagesy($this->gdimg_output), imagesy($this->gdimg_…
3211 …$scale_x = phpthumb_functions::ScaleToFitInBox(imagesx($this->gdimg_output), imagesy($this->gdimg_…
3214 …$this->DebugMessage('Scaling watermark ('.($stretch ? 'with' : 'without').' stretch) by a factor o…
3216 …mg_temp = phpthumb_functions::ImageCreateFunction(imagesx($this->gdimg_output), imagesy($this->gdi…
3217 …imagecopy($img_temp, $this->gdimg_output, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this-…
3218 …if ($this->gdimg_output = phpthumb_functions::ImageCreateFunction($scale_x * imagesx($img_temp), $…
3219 imagealphablending($this->gdimg_output, false);
3220 imagesavealpha($this->gdimg_output, true);
3221 …$this->ImageResizeFunction($this->gdimg_output, $img_temp, 0, 0, 0, 0, imagesx($this->gdimg_output…
3223 …$this->DebugMessage('ImageCreateFunction('.($scale_x * imagesx($img_temp)).', '.($scale_y * images…
3227 …$this->DebugMessage('ImageCreateFunction('.imagesx($this->gdimg_output).', '.imagesy($this->gdimg_…
3234 $phpthumbFilters->ImprovedImageRotate($this->gdimg_output, $angle, $bgcolor, null, $this);
3240 …$this->DebugMessage('Skipping SourceTransparentColor hex color is invalid ('.$hexcolor.')', __FILE…
3245 …if ($gdimg_mask = $phpthumbFilters->SourceTransparentColorMask($this->gdimg_output, $hexcolor, $mi…
3246 $this->is_alpha = true;
3247 $phpthumbFilters->ApplyMask($gdimg_mask, $this->gdimg_output);
3250 …$this->DebugMessage('SourceTransparentColorMask() failed for "'.$hexcolor.','.$min_limit.','.$max_…
3254 …$this->DebugMessage('Finished processing filter command "'.$command.'('.$parameter.')"', __FILE__,…
3263 …$this->DebugMessage('Skipping MaxFileSize() because gd_version is "'.phpthumb_functions::gd_versio…
3266 if ($this->maxb > 0) {
3267 switch ($this->thumbnailFormat) {
3270 $imgRenderFunction = 'image'.$this->thumbnailFormat;
3273 $imgRenderFunction($this->gdimg_output);
3277 if (strlen($imgdata) > $this->maxb) {
3279 $tempIMG = imagecreatetruecolor(imagesx($this->gdimg_output), imagesy($this->gdimg_output));
3280 …imagecopy($tempIMG, $this->gdimg_output, 0, 0, 0, 0, imagesx($this->gdimg_output), imagesy($this->…
3287 if (strlen($imgdata) <= $this->maxb) {
3288 imagetruecolortopalette($this->gdimg_output, true, pow(2, $i));
3297 imagejpeg($this->gdimg_output);
3301 if (strlen($imgdata) > $this->maxb) {
3305 imagejpeg($this->gdimg_output, null, $q);
3309 $this->thumbnailQuality = $q;
3310 if (strlen($imgdata) <= $this->maxb) {
3315 if (strlen($imgdata) > $this->maxb) {
3329this->DebugMessage('CalculateThumbnailDimensions() starting with [W,H,sx,sy,sw,sh] initially set t…
3331 …$this->thumbnailCropX = ($this->sx ? (($this->sx >= 2) ? $this->sx : round($this->sx * $this->sour…
3333 …$this->thumbnailCropY = ($this->sy ? (($this->sy >= 2) ? $this->sy : round($this->sy * $this->sour…
3335 …$this->thumbnailCropW = ($this->sw ? (($this->sw >= 2) ? $this->sw : round($this->sw * $this->sour…
3337 …$this->thumbnailCropH = ($this->sh ? (($this->sh >= 2) ? $this->sh : round($this->sh * $this->sour…
3341 …$this->thumbnailCropW = max(1, min($this->thumbnailCropW, $this->source_width - $this->thumbnailC…
3342 …$this->thumbnailCropH = max(1, min($this->thumbnailCropH, $this->source_height - $this->thumbnailC…
3344this->DebugMessage('CalculateThumbnailDimensions() starting with [x,y,w,h] initially set to ['.$th…
3347 if ($this->zc && $this->w && $this->h) {
3352 $scaling_X = $this->source_width / $this->w;
3353 $scaling_Y = $this->source_height / $this->h;
3356 $allowable_width = $this->source_width / $scaling_X * $scaling_Y;
3357 $this->thumbnailCropW = round($allowable_width);
3358 $this->thumbnailCropX = round(($this->source_width - $allowable_width) / 2);
3362 $allowable_height = $this->source_height / $scaling_Y * $scaling_X;
3363 $this->thumbnailCropH = round($allowable_height);
3364 $this->thumbnailCropY = round(($this->source_height - $allowable_height) / 2);
3369 $this->thumbnail_width = $this->w;
3370 $this->thumbnail_height = $this->h;
3371 $this->thumbnail_image_width = $this->thumbnail_width;
3372 $this->thumbnail_image_height = $this->thumbnail_height;
3374 } elseif ($this->iar && $this->w && $this->h) {
3378 $this->thumbnail_width = $this->w;
3379 $this->thumbnail_height = $this->h;
3380 $this->thumbnail_image_width = $this->thumbnail_width;
3381 $this->thumbnail_image_height = $this->thumbnail_height;
3385 $original_aspect_ratio = $this->thumbnailCropW / $this->thumbnailCropH;
3386 if ($this->aoe) {
3387 if ($this->w && $this->h) {
3388 $maxwidth = min($this->w, $this->h * $original_aspect_ratio);
3389 $maxheight = min($this->h, $this->w / $original_aspect_ratio);
3390 } elseif ($this->w) {
3391 $maxwidth = $this->w;
3392 $maxheight = $this->w / $original_aspect_ratio;
3393 } elseif ($this->h) {
3394 $maxwidth = $this->h * $original_aspect_ratio;
3395 $maxheight = $this->h;
3397 $maxwidth = $this->thumbnailCropW;
3398 $maxheight = $this->thumbnailCropH;
3401 …$maxwidth = phpthumb_functions::nonempty_min($this->w, $this->thumbnailCropW, $this->config_outpu…
3402 …$maxheight = phpthumb_functions::nonempty_min($this->h, $this->thumbnailCropH, $this->config_outpu…
3409 $this->thumbnail_image_width = $maxwidth;
3410 $this->thumbnail_image_height = $maxheight;
3411 $this->thumbnail_width = $maxwidth;
3412 $this->thumbnail_height = $maxheight;
3414 $this->FixedAspectRatio();
3417 $this->thumbnail_width = max(1, floor($this->thumbnail_width));
3418 $this->thumbnail_height = max(1, floor($this->thumbnail_height));
3424 $this->CalculateThumbnailDimensions();
3427 …$this->gdimg_output = phpthumb_functions::ImageCreateFunction($this->thumbnail_width, $this->thumb…
3430 imagesavealpha($this->gdimg_output, true);
3431 if ($this->is_alpha && phpthumb_functions::gd_version() >= 2) {
3433 imagealphablending($this->gdimg_output, false);
3434 …$output_full_alpha = phpthumb_functions::ImageColorAllocateAlphaSafe($this->gdimg_output, 255, 255…
3435 …imagefilledrectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $…
3439 $current_transparent_color = imagecolortransparent($this->gdimg_source);
3440 if ($this->bg || (@$current_transparent_color >= 0)) {
3442 $this->config_background_hexcolor = ($this->bg ? $this->bg : $this->config_background_hexcolor);
3443 if (!phpthumb_functions::IsHexColor($this->config_background_hexcolor)) {
3444 …return $this->ErrorImage('Invalid hex color string "'.$this->config_background_hexcolor.'" for par…
3446 …$background_color = phpthumb_functions::ImageHexColorAllocate($this->gdimg_output, $this->config_b…
3447 …imagefilledrectangle($this->gdimg_output, 0, 0, $this->thumbnail_width, $this->thumbnail_height, $…
3452 …$this->DebugMessage('CreateGDoutput() returning canvas "'.$this->thumbnail_width.'x'.$this->thumbn…
3457 …$this->DebugMessage('SetOrientationDependantWidthHeight() starting with "'.$this->source_width.'"x…
3458 if ($this->source_height > $this->source_width) {
3460 $this->w = phpthumb_functions::OneOfThese($this->wp, $this->w, $this->ws, $this->wl);
3461 $this->h = phpthumb_functions::OneOfThese($this->hp, $this->h, $this->hs, $this->hl);
3462 } elseif ($this->source_height < $this->source_width) {
3464 $this->w = phpthumb_functions::OneOfThese($this->wl, $this->w, $this->ws, $this->wp);
3465 $this->h = phpthumb_functions::OneOfThese($this->hl, $this->h, $this->hs, $this->hp);
3468 $this->w = phpthumb_functions::OneOfThese($this->ws, $this->w, $this->wl, $this->wp);
3469 $this->h = phpthumb_functions::OneOfThese($this->hs, $this->h, $this->hl, $this->hp);
3473 …$this->DebugMessage('SetOrientationDependantWidthHeight() setting w="'. (int) $this->w .'", h="'. …
3478 $this->DebugMessage('starting ExtractEXIFgetImageSize()', __FILE__, __LINE__);
3480 if (preg_match('#^http:#i', $this->src) && !$this->sourceFilename && $this->rawImageData) {
3481 $this->SourceDataToTempFile();
3483 if (null === $this->getimagesizeinfo) {
3484 if ($this->sourceFilename) {
3485 if ($this->getimagesizeinfo = @getimagesize($this->sourceFilename)) {
3486 $this->source_width = $this->getimagesizeinfo[0];
3487 $this->source_height = $this->getimagesizeinfo[1];
3488 …$this->DebugMessage('getimagesize('.$this->sourceFilename.') says image is '.$this->source_width.'…
3490 $this->DebugMessage('getimagesize('.$this->sourceFilename.') failed', __FILE__, __LINE__);
3493 …$this->DebugMessage('skipping getimagesize() because $this->sourceFilename is empty', __FILE__, __…
3496 …$this->DebugMessage('skipping getimagesize() because !is_null($this->getimagesizeinfo)', __FILE__,…
3499 …if (is_resource($this->gdimg_source) || (is_object($this->gdimg_source) && $this->gdimg_source ins…
3501 $this->source_width = imagesx($this->gdimg_source);
3502 $this->source_height = imagesy($this->gdimg_source);
3504 $this->SetOrientationDependantWidthHeight();
3506 } elseif ($this->rawImageData && !$this->sourceFilename) {
3508 if ($this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
3509this->DebugMessage('NOT bypassing EXIF and getimagesize sections because source image is too large…
3511this->DebugMessage('bypassing EXIF and getimagesize sections because $this->rawImageData is set, a…
3516 if (!empty($this->getimagesizeinfo)) {
3518 $this->getimagesizeinfo['filesize'] = @filesize($this->sourceFilename);
3519 } elseif (!$this->rawImageData) {
3520 $this->DebugMessage('getimagesize("'.$this->sourceFilename.'") failed', __FILE__, __LINE__);
3523 if ($this->config_prefer_imagemagick) {
3524 if ($this->ImageMagickThumbnailToGD()) {
3527 $this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
3530 if (isset($this->getimagesizeinfo[1])) {
3531 $this->source_width = $this->getimagesizeinfo[0];
3532 $this->source_height = $this->getimagesizeinfo[1];
3535 $this->SetOrientationDependantWidthHeight();
3538 switch (@$this->getimagesizeinfo[2]) {
3542 $this->exif_raw_data = @exif_read_data($this->sourceFilename, 0, true);
3546 if (function_exists('exif_thumbnail') && (@$this->getimagesizeinfo[2] == IMAGETYPE_JPEG)) {
3549 $this->exif_thumbnail_width = '';
3550 $this->exif_thumbnail_height = '';
3551 $this->exif_thumbnail_type = '';
3556 …$this->exif_thumbnail_data = @exif_thumbnail($this->sourceFilename, $this->exif_thumbnail_width, $
3562 $this->exif_thumbnail_data = exif_thumbnail($this->sourceFilename);
3565 if (!$exit_thumbnail_error && $this->exif_thumbnail_data) {
3567 …if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false))…
3568 $this->exif_thumbnail_width = imagesx($gdimg_exif_temp);
3569 $this->exif_thumbnail_height = imagesy($gdimg_exif_temp);
3570 …$this->exif_thumbnail_type = 2; // (2 == JPEG) before PHP v4.3.0 only JPEG format EXIF thumbnail…
3573 …return $this->ErrorImage('Failed - $this->ImageCreateFromStringReplacement($this->exif_thumbnail_d…
3582 …$this->DebugMessage('exif_thumbnail() does not exist, cannot extract EXIF thumbnail', __FILE__, __…
3586this->DebugMessage('EXIF thumbnail extraction: (size='.(!empty($this->exif_thumbnail_data) ? strle…
3589 if ($this->config_use_exif_thumbnail_for_speed && $this->exif_thumbnail_data) {
3591 if (!$this->xto) {
3592 $source_ar = $this->source_width / $this->source_height;
3593 $exif_ar = $this->exif_thumbnail_width / $this->exif_thumbnail_height;
3595 …$this->DebugMessage('not using EXIF thumbnail because $source_ar != $exif_ar ('.$source_ar.' != '.…
3598 if ($this->w && ($this->w != $this->exif_thumbnail_width)) {
3599 …$this->DebugMessage('not using EXIF thumbnail because $this->w != $this->exif_thumbnail_width ('.$
3602 if ($this->h && ($this->h != $this->exif_thumbnail_height)) {
3603 …$this->DebugMessage('not using EXIF thumbnail because $this->h != $this->exif_thumbnail_height ('.…
3608 if ($this->$parameter) {
3614 …$this->DebugMessage('setting $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->…
3615 $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data);
3616 $this->source_width = imagesx($this->gdimg_source);
3617 $this->source_height = imagesy($this->gdimg_source);
3622 …if (($this->config_max_source_pixels > 0) && (($this->source_width * $this->source_height) > $this
3628this->DebugMessage('image is '.$this->source_width.'x'.$this->source_height.' and therefore contai…
3629 if (!$this->config_prefer_imagemagick && $this->ImageMagickThumbnailToGD()) {
3640 if (null !== $this->cache_filename) {
3641 …$this->DebugMessage('$this->cache_filename already set, skipping SetCacheFilename()', __FILE__, __…
3644 if (null === $this->config_cache_directory) {
3645 $this->setCacheDirectory();
3646 if (!$this->config_cache_directory) {
3647 …$this->DebugMessage('SetCacheFilename() failed because $this->config_cache_directory is empty', __…
3651 $this->setOutputFormat();
3653 if (!$this->sourceFilename && !$this->rawImageData && $this->src) {
3654 $this->sourceFilename = $this->ResolveFilenameToAbsolute($this->src);
3657 if ($this->config_cache_default_only_suffix && $this->sourceFilename) {
3662 if (strpos($this->config_cache_default_only_suffix, '*') === false) {
3663 …$this->DebugMessage('aborting simplified caching filename because no * in "'.$this->config_cache_d…
3665 preg_match('#(.+)(\\.[a-z0-9]+)?$#i', basename($this->sourceFilename), $matches);
3666this->cache_filename = $this->config_cache_directory.DIRECTORY_SEPARATOR.rawurlencode(str_replace(…
3671 $this->cache_filename = '';
3672 if ($this->new) {
3673 $broad_directory_name = strtolower(md5($this->new));
3674 $this->cache_filename .= '_new'.$broad_directory_name;
3675 } elseif ($this->md5s) {
3677 …$this->DebugMessage('SetCacheFilename() _raw set from $this->md5s = "'.$this->md5s.'"', __FILE__, …
3678 $broad_directory_name = $this->md5s;
3679 $this->cache_filename .= '_raw'.$this->md5s;
3680 } elseif (!$this->src && $this->rawImageData) {
3681 …$this->DebugMessage('SetCacheFilename() _raw set from md5($this->rawImageData) = "'.md5($this->raw…
3682 $broad_directory_name = strtolower(md5($this->rawImageData));
3683 $this->cache_filename .= '_raw'.$broad_directory_name;
3685 …$this->DebugMessage('SetCacheFilename() _src set from md5($this->sourceFilename) "'.$this->sourceF…
3686 $broad_directory_name = strtolower(md5($this->sourceFilename));
3687 $this->cache_filename .= '_src'.$broad_directory_name;
3689 if (!empty($_SERVER['HTTP_REFERER']) && $this->config_nooffsitelink_enabled) {
3694 $this->cache_filename .= '_offsite';
3699 if ($this->fltr && is_array($this->fltr)) {
3700 $ParametersString .= '_fltr'.implode('_fltr', $this->fltr);
3704 if ($this->$key) {
3705 $ParametersString .= '_'.$key.$this->$key;
3710 if ($this->$key) {
3711 $ParametersString .= '_'.$key. (int) $this->$key;
3716 if ($this->$key) {
3717 $ParametersString .= '_'.$key.substr(md5($this->$key), 0, 4);
3720 if ($this->thumbnailFormat == 'jpeg') {
3722 $ParametersString .= '_q'. (int) $this->thumbnailQuality;
3724 …$this->DebugMessage('SetCacheFilename() _par set from md5('.$ParametersString.')', __FILE__, __LIN…
3725 $this->cache_filename .= '_par'.strtolower(md5($ParametersString));
3727 if ($this->md5s) {
3731 …} elseif (!$this->config_cache_source_filemtime_ignore_remote && preg_match('#^(f|ht)tps?\://#i', …
3732 $this->cache_filename .= '_dat'. (int) phpthumb_functions::filedate_remote($this->src);
3733 …} elseif (!$this->config_cache_source_filemtime_ignore_local && $this->src && !$this->rawImageData…
3734 $this->cache_filename .= '_dat'. (int) (@filemtime($this->sourceFilename));
3737 $this->cache_filename .= '.'.strtolower($this->thumbnailFormat);
3739 for ($i = 0; $i < $this->config_cache_directory_depth; $i++) {
3743 …$this->cache_filename = $this->config_cache_directory.$broad_directories.DIRECTORY_SEPARATOR.$this
3749 if (!$this->config_max_source_pixels) {
3752 if ($this->php_memory_limit && function_exists('memory_get_usage')) {
3753 $available_memory = $this->php_memory_limit - memory_get_usage();
3756 return (bool) (($width * $height) > $this->config_max_source_pixels);
3765 $this->DebugMessage('starting ImageCreateFromFilename('.$filename.')', __FILE__, __LINE__);
3767 if (!$this->SourceImageIsTooLarge($getimagesizeinfo[0], $getimagesizeinfo[1])) {
3776 …$this->DebugMessage('ImageCreateFromFilename found ($getimagesizeinfo[2]=='.@$getimagesizeinfo[2].…
3786 …$this->DebugMessage('Calling '.$ImageCreateFromFunctionName.'('.$filename.')', __FILE__, __LINE__);
3790 …$this->DebugMessage('NOT calling '.$ImageCreateFromFunctionName.'('.$filename.') because !function…
3807 …$this->DebugMessage('No built-in image creation function for image type "'.@$getimagesizeinfo[2].'…
3811 …$this->DebugMessage('Unknown value for $getimagesizeinfo[2]: "'.@$getimagesizeinfo[2].'"', __FILE_…
3815this->DebugMessage('image is '.$getimagesizeinfo[0].'x'.$getimagesizeinfo[1].' and therefore conta…
3819 $this->DebugMessage('empty $filename or getimagesize('.$filename.') failed', __FILE__, __LINE__);
3825 …$this->DebugMessage($ImageCreateFromFunctionName.'() was attempted but FAILED', __FILE__, __LINE__…
3827 $this->DebugMessage('Populating $rawimagedata', __FILE__, __LINE__);
3838 $this->DebugMessage('cannot fopen('.$filename.')', __FILE__, __LINE__);
3841 …$this->DebugMessage('attempting ImageCreateFromStringReplacement($rawimagedata ('.strlen($rawimage…
3842 $gd_image = $this->ImageCreateFromStringReplacement($rawimagedata, true);
3849 …if (is_resource($this->gdimg_source) || (is_object($this->gdimg_source) && $this->gdimg_source ins…
3850 $this->source_width = imagesx($this->gdimg_source);
3851 $this->source_height = imagesy($this->gdimg_source);
3852 …$this->DebugMessage('skipping SourceImageToGD() because $this->gdimg_source is already a resource …
3855 $this->DebugMessage('starting SourceImageToGD()', __FILE__, __LINE__);
3857 if ($this->config_prefer_imagemagick) {
3858 if (empty($this->sourceFilename) && !empty($this->rawImageData)) {
3859 …$this->DebugMessage('Copying raw image data to temp file and trying again with ImageMagick', __FIL…
3860 if ($tempnam = $this->phpThumb_tempnam()) {
3861 if (file_put_contents($tempnam, $this->rawImageData)) {
3862 $this->sourceFilename = $tempnam;
3863 if ($this->ImageMagickThumbnailToGD()) {
3865 $this->DebugMessage('ImageMagickThumbnailToGD() succeeded', __FILE__, __LINE__);
3867 $this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
3869 @chmod($tempnam, $this->getParameter('config_file_create_mask'));
3871 …$this->DebugMessage('failed to put $this->rawImageData into temp file "'.$tempnam.'"', __FILE__, _…
3874 $this->DebugMessage('failed to generate temp file name', __FILE__, __LINE__);
3878 if (!$this->gdimg_source && $this->rawImageData) {
3880 if ($this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
3882this->ErrorImage('Source image is too large ('.$this->source_width.'x'.$this->source_height.' = '.…
3884 if ($this->md5s && ($this->md5s != md5($this->rawImageData))) {
3885 …return $this->ErrorImage('$this->md5s != md5($this->rawImageData)'."\n".'"'.$this->md5s.'" != '."\…
3890 $this->gdimg_source = $this->ImageCreateFromStringReplacement($this->rawImageData);
3891 if (!$this->gdimg_source) {
3892 if (substr($this->rawImageData, 0, 2) === 'BM') {
3893 $this->getimagesizeinfo[2] = 6; // BMP
3894 } elseif (substr($this->rawImageData, 0, 4) === 'II'."\x2A\x00") {
3895 $this->getimagesizeinfo[2] = 7; // TIFF (littlendian)
3896 } elseif (substr($this->rawImageData, 0, 4) === 'MM'."\x00\x2A") {
3897 $this->getimagesizeinfo[2] = 8; // TIFF (bigendian)
3899this->DebugMessage('SourceImageToGD.ImageCreateFromStringReplacement() failed with unknown image t…
3903 } elseif (!$this->gdimg_source && $this->sourceFilename) {
3905 if ($this->md5s && ($this->md5s != phpthumb_functions::md5_file_safe($this->sourceFilename))) {
3906 …return $this->ErrorImage('$this->md5s != md5(sourceFilename)'."\n".'"'.$this->md5s.'" != '."\n".'"…
3908 switch (@$this->getimagesizeinfo[2]) {
3912 $this->is_alpha = true;
3915 if (!$this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
3916 $this->gdimg_source = $this->ImageCreateFromFilename($this->sourceFilename);
3922 if ($this->gdimg_source) {
3923 …$this->DebugMessage('Not using EXIF thumbnail data because $this->gdimg_source is already set', __…
3926 if (!$this->exif_thumbnail_data) {
3927 …$this->DebugMessage('Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty', _…
3931 if (!$this->SourceImageIsTooLarge($this->source_width, $this->source_height)) {
3932 …$this->DebugMessage('Using EXIF thumbnail data because source image too large and safe_mode enable…
3933 $this->aoe = true;
3938 if (!$this->config_use_exif_thumbnail_for_speed) {
3939 …$this->DebugMessage('Not using EXIF thumbnail data because $this->config_use_exif_thumbnail_for_sp…
3942 if (($this->thumbnailCropX != 0) || ($this->thumbnailCropY != 0)) {
3943 …$this->DebugMessage('Not using EXIF thumbnail data because source cropping is enabled ('.$this->th…
3946 if (($this->w > $this->exif_thumbnail_width) || ($this->h > $this->exif_thumbnail_height)) {
3947this->DebugMessage('Not using EXIF thumbnail data because EXIF thumbnail is too small ('.$this->ex…
3950 $source_ar = $this->source_width / $this->source_height;
3951 $exif_ar = $this->exif_thumbnail_width / $this->exif_thumbnail_height;
3953 …$this->DebugMessage('not using EXIF thumbnail because $source_ar != $exif_ar ('.$source_ar.' != '.…
3959 $this->DebugMessage('Trying to use EXIF thumbnail as source image', __FILE__, __LINE__);
3961 …if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false))…
3963 $this->DebugMessage('Successfully using EXIF thumbnail as source image', __FILE__, __LINE__);
3964 $this->gdimg_source = $gdimg_exif_temp;
3965 $this->source_width = $this->exif_thumbnail_width;
3966 $this->source_height = $this->exif_thumbnail_height;
3967 $this->thumbnailCropW = $this->source_width;
3968 $this->thumbnailCropH = $this->source_height;
3972 …$this->DebugMessage('$this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false) fa…
3978 if (!$this->gdimg_source) {
3979 $this->DebugMessage('$this->gdimg_source is still empty', __FILE__, __LINE__);
3981 $this->DebugMessage('ImageMagickThumbnailToGD() failed', __FILE__, __LINE__);
3986 switch (@$this->getimagesizeinfo[2]) {
4003 if ($this->config_error_die_on_source_failure) {
4006 if ($this->fatalerror) {
4007 $errormessages[] = $this->fatalerror;
4009 if ($this->issafemode) {
4011 } elseif (!$this->ImageMagickVersion()) {
4014 if ($this->SourceImageIsTooLarge($this->getimagesizeinfo[0], $this->getimagesizeinfo[1])) {
4016this->getimagesizeinfo[0].'x'.$this->getimagesizeinfo[1].' = '.number_format($this->getimagesizein…
4022 $this->ErrorImage(implode("\n", $errormessages));
4025 …$this->DebugMessage('All attempts to create GD image source failed ('.(ini_get('safe_mode') ? 'Saf…
4038 switch (@$this->getimagesizeinfo[2]) {
4043 return $this->ErrorImage('include_once('. __DIR__ .'/phpthumb.bmp.php) failed');
4046 if ($fp = @fopen($this->sourceFilename, 'rb')) {
4047 $this->rawImageData = '';
4049 $this->rawImageData .= fread($fp, 32768);
4054 …$this->gdimg_source = $phpthumb_bmp->phpthumb_bmp2gd($this->rawImageData, phpthumb_functions::gd_v…
4056 if ($this->gdimg_source) {
4057 $this->DebugMessage('$phpthumb_bmp->phpthumb_bmp2gd() succeeded', __FILE__, __LINE__);
4059 …return $this->ErrorImage($this->ImageMagickVersion() ? 'ImageMagick failed on BMP source conversio…
4068 …return $this->ErrorImage($this->ImageMagickVersion() ? 'ImageMagick failed on TIFF source conversi…
4076 if (!$this->gdimg_source) {
4077 if ($this->rawImageData) {
4078 $HeaderFourBytes = substr($this->rawImageData, 0, 4);
4079 } elseif ($this->sourceFilename) {
4080 if ($fp = @fopen($this->sourceFilename, 'rb')) {
4084 …return $this->ErrorImage('failed to open "'.$this->sourceFilename.'" SourceImageToGD() ['.__LINE__…
4087 …return $this->ErrorImage('Unable to create image, neither filename nor image data suppplied in Sou…
4089 if (!$this->ImageMagickVersion() && !phpthumb_functions::gd_version()) {
4090 …return $this->ErrorImage('Neither GD nor ImageMagick seem to be installed on this server. At least…
4092 …return $this->ErrorImage($this->ImageMagickVersion() ? 'ImageMagick failed on WMF source conversio…
4094 …return $this->ErrorImage($this->ImageMagickVersion() ? 'ImageMagick and GhostScript are both requi…
4096 …return $this->ErrorImage('Image (JPEG) is too large for PHP-GD memory_limit, please install ImageM…
4098 …return $this->ErrorImage('Image (PNG) is too large for PHP-GD memory_limit, please install ImageMa…
4100 …return $this->ErrorImage('Image (GIF) is too large for PHP-GD memory_limit, please install ImageMa…
4102 …return $this->ErrorImage('Unknown image type identified by "'.$HeaderFourBytes.'" ('.phpthumb_func…
4106 if (!$this->gdimg_source) {
4107 …if ($gdimg_exif_temp = $this->ImageCreateFromStringReplacement($this->exif_thumbnail_data, false))…
4108 …$this->DebugMessage('All other attempts failed, but successfully using EXIF thumbnail as source im…
4109 $this->gdimg_source = $gdimg_exif_temp;
4112 $this->aoe = true;
4118 $this->source_width = imagesx($this->gdimg_source);
4119 $this->source_height = imagesy($this->gdimg_source);
4125 if (!is_null($this->ica)) {
4126 $this->DebugMessage('ImageCropAuto('.$this->ica.') starting', __FILE__, __LINE__);
4135 if (preg_match('#^(([0-4])|(5)\\|(0?\\.?[0-9]+)\\|([0-9A-F]{6}))$#i', $this->ica, $matches)) {
4139 if (!imageistruecolor($this->gdimg_source)) {
4140 …$param_color = imagecolorclosest($this->gdimg_source, hexdec(substr($ica_color, 0, 2)), hexdec(sub…
4142 …$cropped = imagecropauto($this->gdimg_source, intval($ica_mode2), floatval($ica_threshold), $param…
4144 $cropped = imagecropauto($this->gdimg_source, intval($ica_mode1));
4147 …$this->DebugMessage('ImageCropAuto changing source image size from '.imagesx($this->gdimg_source).…
4148 imagedestroy($this->gdimg_source); // we destroy the original image
4149 $this->gdimg_source = $cropped; // and assign the cropped image to $im
4150 $this->source_width = imagesx($this->gdimg_source);
4151 $this->source_height = imagesy($this->gdimg_source);
4153 $this->DebugMessage('imagecropauto failed', __FILE__, __LINE__);
4156 $this->DebugMessage('invalid "ica" parameter syntax, ignoring', __FILE__, __LINE__);
4159 …$this->DebugMessage('!function_exists(imagecropauto), ignoring "ica" parameter', __FILE__, __LINE_…
4187 if ($level && ($this->phpThumbDebug !== $level)) {
4190 if ($this->config_disable_debug) {
4191 return $this->ErrorImage('phpThumbDebug disabled');
4200 $DebugOutput[] = 'phpThumb() version = '.$this->phpthumb_version;
4215 …_quotes_gpc() = '.(function_exists('get_magic_quotes_gpc') ? $this->phpThumbDebugVarDu…
4216 …_quotes_runtime() = '.(function_exists('get_magic_quotes_runtime') ? $this->phpThumbDebugVarDu…
4217 …$DebugOutput[] = 'error_reporting() = '.$this->phpThumbDebugVarDump(error_reporting()…
4218 …$DebugOutput[] = 'ini_get(error_reporting) = '.$this->phpThumbDebugVarDump(@ini_get('error_r…
4219 …$DebugOutput[] = 'ini_get(display_errors) = '.$this->phpThumbDebugVarDump(@ini_get('display…
4220 …$DebugOutput[] = 'ini_get(allow_url_fopen) = '.$this->phpThumbDebugVarDump(@ini_get('allow_u…
4221 …$DebugOutput[] = 'ini_get(disable_functions) = '.$this->phpThumbDebugVarDump(@ini_get('disable…
4222 …$DebugOutput[] = 'get_cfg_var(disable_functions) = '.$this->phpThumbDebugVarDump(@get_cfg_var('dis…
4223 …$DebugOutput[] = 'ini_get(safe_mode) = '.$this->phpThumbDebugVarDump(@ini_get('safe_mo…
4224 …$DebugOutput[] = 'ini_get(open_basedir) = '.$this->phpThumbDebugVarDump(@ini_get('open_ba…
4225 …$DebugOutput[] = 'ini_get(max_execution_time) = '.$this->phpThumbDebugVarDump(@ini_get('max_exe…
4226 …$DebugOutput[] = 'ini_get(memory_limit) = '.$this->phpThumbDebugVarDump(@ini_get('memory_…
4227 …$DebugOutput[] = 'get_cfg_var(memory_limit) = '.$this->phpThumbDebugVarDump(@get_cfg_var('mem…
4228 …$DebugOutput[] = 'memory_get_usage() = '.(function_exists('memory_get_usage') ? $this-…
4231 …utput[] = '$this->config_prefer_imagemagick = '.$this->phpThumbDebugVarDump($this->conf…
4232 …utput[] = '$this->config_imagemagick_path = '.$this->phpThumbDebugVarDump($this->conf…
4233 …$DebugOutput[] = '$this->ImageMagickWhichConvert() = '.$this->ImageMagickWhichConvert();
4234 …$IMpathUsed = ($this->config_imagemagick_path ? $this->config_imagemagick_path : $this->ImageMagic…
4235 …$DebugOutput[] = '[actual ImageMagick path used] = '.$this->phpThumbDebugVarDump($IMp…
4236 …$DebugOutput[] = 'file_exists([actual ImageMagick path used]) = '.$this->phpThumbDebugVarDump(@fil…
4237 …$DebugOutput[] = 'ImageMagickVersion(false) = '.$this->ImageMagickVersion(false);
4238 $DebugOutput[] = 'ImageMagickVersion(true) = '.$this->ImageMagickVersion(true);
4241 …utput[] = '$this->config_cache_directory = '.$this->phpThumbDebugVarDump($this->conf…
4242 …utput[] = '$this->config_cache_directory_depth = '.$this->phpThumbDebugVarDump($this->conf…
4243 …utput[] = '$this->config_cache_disable_warning = '.$this->phpThumbDebugVarDump($this->conf…
4244 …utput[] = '$this->config_cache_maxage = '.$this->phpThumbDebugVarDump($this->conf…
4245 …utput[] = '$this->config_cache_maxsize = '.$this->phpThumbDebugVarDump($this->conf…
4246 …utput[] = '$this->config_cache_maxfiles = '.$this->phpThumbDebugVarDump($this->conf…
4247 …utput[] = '$this->config_cache_force_passthru = '.$this->phpThumbDebugVarDump($this->conf…
4248 …utput[] = '$this->cache_filename = '.$this->phpThumbDebugVarDump($this->cach…
4249 …] = 'is_readable($this->config_cache_directory) = '.$this->phpThumbDebugVarDump(@is_readable($thi…
4250 …] = 'is_writable($this->config_cache_directory) = '.$this->phpThumbDebugVarDump(@is_writable($thi…
4251 …] = 'is_readable($this->cache_filename) = '.$this->phpThumbDebugVarDump(@is_readable($thi…
4252 …he_filename) = '.(@file_exists($this->cache_filename) ? $this->phpThumbDebugVarDump(@is_w…
4257 $value = $this->$varname;
4258 …$DebugOutput[] = '$this->'.str_pad($varname, 37, ' ', STR_PAD_RIGHT).' = '.$this->phpThumbDebugVar…
4262 $value = $this->$varname;
4263 …$DebugOutput[] = '$this->'.str_pad($varname, 27, ' ', STR_PAD_RIGHT).' = '.$this->phpThumbDebugVar…
4265 …ut[] = 'strlen($this->rawImageData) = '.(!empty($this->rawImageData) ? strlen($this-…
4266 …ut[] = 'strlen($this->exif_thumbnail_data) = '.(!empty($this->exif_thumbnail_data) ? strlen($this-…
4270 $value = $this->$varname;
4271 …$DebugOutput[] = '$this->'.str_pad($varname, 4, ' ', STR_PAD_RIGHT).' = '.$this->phpThumbDebugVarD…
4276 …ts('.$functionname.')'.str_repeat(' ', 23 - strlen($functionname)).' = '.$this->phpThumbDebugVarDu…
4282 …$DebugOutput[] = 'gd_info.'.str_pad($key, 34, ' ', STR_PAD_RIGHT).' = '.$this->phpThumbDebugVarDum…
4288 …$DebugOutput[] = 'exif_info.'.str_pad($key, 26, ' ', STR_PAD_RIGHT).' = '.$this->phpThumbDebugVarD…
4294 …$DebugOutput[] = 'ApacheLookupURIarray.'.str_pad($key, 15, ' ', STR_PAD_RIGHT).' = '.$this->phpThu…
4303 …$DebugOutput[] = '$_GET['.$key.']'.str_repeat(' ', 30 - strlen($key)).'= '.$this->phpThumbDebugVar…
4308 …$DebugOutput[] = '$_POST['.$key.']'.str_repeat(' ', 29 - strlen($key)).'= '.$this->phpThumbDebugVa…
4314 foreach ($this->debugmessages as $errorstring) {
4320 foreach ($this->debugtiming as $timestamp => $timingstring) {
4323 …Total processing time: '.number_format(max(array_keys($this->debugtiming)) - min(array_keys($this-…
4325 …$this->f = (isset($_GET['f']) ? $_GET['f'] : $this->f); // debug modes 0-2 don't recognize text mo…
4326 return $this->ErrorImage(implode("\n", $DebugOutput), 700, 500, true);
4330 if (null === $this->fatalerror) {
4331 $this->fatalerror = $text;
4337 $width = ($width ? $width : $this->config_error_image_width);
4338 $height = ($height ? $height : $this->config_error_image_height);
4340 …$text = 'phpThumb() v'.$this->phpthumb_version."\n".'http://phpthumb.sourceforge.net'."\n\n".($thi…
4342 $this->FatalError($text);
4343 $this->DebugMessage($text, __FILE__, __LINE__);
4344 $this->purgeTempFiles();
4345 if ($this->config_error_silent_die_on_error) {
4348 if ($this->phpThumbDebug && !$forcedisplay) {
4351 if (!$this->config_error_die_on_error && !$forcedisplay) {
4354 if ($this->err || $this->config_error_message_image_default) {
4357 if (($this->err == 'showerror') || $this->phpThumbDebug) {
4360 header('Location: '.($this->err ? $this->err : $this->config_error_message_image_default));
4364 $this->setOutputFormat();
4365 …if (!$this->thumbnailFormat || !$this->config_disable_debug || (phpthumb_functions::gd_version() <…
4366 $this->thumbnailFormat = 'text';
4368 if (@$this->thumbnailFormat == 'text') {
4379 $FontWidth = imagefontwidth($this->config_error_fontsize);
4380 $FontHeight = imagefontheight($this->config_error_fontsize);
4397 …$background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bg…
4398 …$text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_te…
4402 imagestring($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color);
4446 …$this->DebugMessage('ImageCreateFromStringReplacement() failed: gd_version says "'.phpthumb_functi…
4451 …$this->DebugMessage('ImageCreateFromStringReplacement() calling built-in imagecreatefromstring()',…
4454 if ($this->issafemode) {
4455 …$this->DebugMessage('ImageCreateFromStringReplacement() failed: cannot create temp file in SAFE_MO…
4470 …$this->DebugMessage('ImageCreateFromStringReplacement() failed: unknown fileformat signature "'.ph…
4475 if ($tempnam = $this->phpThumb_tempnam()) {
4479 @chmod($tempnam, $this->getParameter('config_file_create_mask'));
4486 $this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
4490 if ($tempfilename = $this->phpThumb_tempnam()) {
4495 …$this->DebugMessage('gif_loadFileToGDimageResource('.$tempfilename.') completed', __FILE__, __LINE…
4496 $this->DebugMessage('deleting "'.$tempfilename.'"', __FILE__, __LINE__);
4501 $this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
4505 $this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
4511 … $this->DebugMessage($ICFSreplacementFunctionName.'('.$tempnam.') succeeded', __FILE__, __LINE__);
4512 $this->DebugMessage('deleting "'.$tempnam.'"', __FILE__, __LINE__);
4519 …$this->DebugMessage($ICFSreplacementFunctionName.'('.$tempnam.') '.(function_exists($ICFSreplaceme…
4521 $this->phpThumbDebug();
4527 if ($this->issafemode) {
4530 $this->DebugMessage($ErrorMessage, __FILE__, __LINE__);
4532 $this->DebugMessage('deleting "'.$tempnam.'"', __FILE__, __LINE__);
4536 if ($this->issafemode) {
4541 return $this->ErrorImage($ErrorMessage);
4556 …$this->DebugMessage('ImageResizeFunction($o, $s, '.$dstX.', '.$dstY.', '.$srcX.', '.$srcY.', '.$ds…
4561 if ($this->config_disable_imagecopyresampled) {
4570 …$this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : $thi…
4571 …$this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : $thi…
4572 …$this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : $thi…
4573 …$this->config_temp_directory = ($this->config_temp_directory ? $this->config_temp_directory : $thi…
4578 $this->InitializeTempDirSetting();
4579 $tempnam = $this->realPathSafe(tempnam($this->config_temp_directory, 'pThumb'));
4580 $this->tempFilesToDelete[$tempnam] = $tempnam;
4581 $this->DebugMessage('phpThumb_tempnam() returning "'.$tempnam.'"', __FILE__, __LINE__);
4586 …$this->debugmessages[] = $message.($file ? ' in file "'.(basename($file) ? basename($file) : $file…
4594 …$this->debugtiming[number_format($timestamp, 6, '.', '')] = ': '.$message.($file ? ' in file "'.(b…