[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: PHP Warning: imagecolorat() expects parameter 1 t
Elimelech
Обновляю TCPDF библиотеку в Joomla 1.5.26
Скачал архив библиотеки от сюда. tcpdf_6_2_13.zip (17.0 MB)
Заменил папки и файлы:libraries/tcpdf, перезалил шрифты в папку: /language/pdf_fonts

pdf страницу генерирует на отлично, всё работает без проблем.
Но вот посмотрел логи и вижу ошибку:
[Sun May 14 02:57:57.224940 2017] [:error] [pid 18644] [client 95.108.179.7:34474] 
PHP Warning: imagecolorat() expects parameter 1 to be resource,
boolean given in /мой сайт/public_html/libraries/tcpdf/tcpdf.php on line 7293


Как это исправить?
Спасибо що помощь!
sergeiss
Цитата (Elimelech @ 14.05.2017 - 14:21)
Как это исправить?

"Телепатов нету" (с)

Смотри, что за параметр приходит в эту функцию в этой строке, почему он boolean вместо resource. Или ты предлагаешь всем скачать эту либу, найти строку 7293 и проанализировать? wink.gif

Хотя бы скопируй сюда часть кода (часть кода! - а не все тысячи строк), содержащую эту строку. Ну строчек 50 в сумме, не больше.

_____________
* Хэлп по PHP
* Описалово по JavaScript
* Хэлп и СУБД для PostgreSQL

* Обучаю PHP, JS, вёрстке. Интерактивно и качественно. За разумные деньги.

* "накапливаю умение телепатии" (С) и "гуглю за ваш счет" (С)

user posted image
Elimelech
Строка где вылезает ошибка:
$color = imagecolorat($img, $xpx, $ypx);


А вот часть кода где эта строка:

/**
* Extract info from a PNG image with alpha channel using the Imagick or GD library.
* @param $file (string) Name of the file containing the image.
* @param $x (float) Abscissa of the upper-left corner.
* @param $y (float) Ordinate of the upper-left corner.
* @param $wpx (float) Original width of the image in pixels.
* @param $hpx (float) original height of the image in pixels.
* @param $w (float) Width of the image in the page. If not specified or equal to zero, it is automatically calculated.
* @param $h (float) Height of the image in the page. If not specified or equal to zero, it is automatically calculated.
* @param $type (string) Image format. Possible values are (case insensitive): JPEG and PNG (whitout GD library) and all images supported by GD: GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM;. If not specified, the type is inferred from the file extension.
* @param $link (mixed) URL or identifier returned by AddLink().
* @param $align (string) Indicates the alignment of the pointer next to image insertion relative to image height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
* @param $resize (boolean) If true resize (reduce) the image to fit $w and $h (requires GD library).
* @param $dpi (int) dot-per-inch resolution used on resize
* @param $palign (string) Allows to center or align the image on the current line. Possible values are:<ul><li>L : left align</li><li>C : center</li><li>R : right align</li><li>'' : empty string : left for LTR or right for RTL</li></ul>
* @param $filehash (string) File hash used to build unique file names.
* @author Nicola Asuni
* @protected
* @since 4.3.007 (2008-12-04)
* @see Image()
*/
protected function ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $filehash='') {
// create temp images
if (empty($filehash)) {
$filehash = md5($file);
}
// create temp image file (without alpha channel)
$tempfile_plain = K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_imgmask_plain_'.$filehash;
// create temp alpha file
$tempfile_alpha = K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_imgmask_alpha_'.$filehash;
$parsed = false;
$parse_error = '';
// ImageMagick extension
if (($parsed === false) AND extension_loaded('imagick')) {
try {
// ImageMagick library
$img = new Imagick();
$img->readImage($file);
// clone image object
$imga = TCPDF_STATIC::objclone($img);
// extract alpha channel
if (method_exists($img, 'setImageAlphaChannel') AND defined('Imagick::ALPHACHANNEL_EXTRACT')) {
$img->setImageAlphaChannel(Imagick::ALPHACHANNEL_EXTRACT);
} else {
$img->separateImageChannel(8); // 8 = (imagick::CHANNEL_ALPHA | imagick::CHANNEL_OPACITY | imagick::CHANNEL_MATTE);
$img->negateImage(true);
}
$img->setImageFormat('png');
$img->writeImage($tempfile_alpha);
// remove alpha channel
if (method_exists($imga, 'setImageMatte')) {
$imga->setImageMatte(false);
} else {
$imga->separateImageChannel(39); // 39 = (imagick::CHANNEL_ALL & ~(imagick::CHANNEL_ALPHA | imagick::CHANNEL_OPACITY | imagick::CHANNEL_MATTE));
}
$imga->setImageFormat('png');
$imga->writeImage($tempfile_plain);
$parsed = true;
} catch (Exception $e) {
// Imagemagick fails, try with GD
$parse_error = 'Imagick library error: '.$e->getMessage();
}
}
// GD extension
if (($parsed === false) AND function_exists('imagecreatefrompng')) {
try {
// generate images
$img = imagecreatefrompng($file);
$imgalpha = imagecreate($wpx, $hpx);
// generate gray scale palette (0 -> 255)
for ($c = 0; $c < 256; ++$c) {
ImageColorAllocate($imgalpha, $c, $c, $c);
}
// extract alpha channel
for ($xpx = 0; $xpx < $wpx; ++$xpx) {
for ($ypx = 0; $ypx < $hpx; ++$ypx) {
$color = imagecolorat($img, $xpx, $ypx);
// get and correct gamma color
$alpha = $this->getGDgamma($img, $color);
imagesetpixel($imgalpha, $xpx, $ypx, $alpha);
}
}
imagepng($imgalpha, $tempfile_alpha);
imagedestroy($imgalpha);
// extract image without alpha channel
$imgplain = imagecreatetruecolor($wpx, $hpx);
imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
imagepng($imgplain, $tempfile_plain);
imagedestroy($imgplain);
$parsed = true;
} catch (Exception $e) {
// GD fails
$parse_error = 'GD library error: '.$e->getMessage();
}
}
if ($parsed === false) {
if (empty($parse_error)) {
$this->Error('TCPDF requires the Imagick or GD extension to handle PNG images with alpha channel.');
} else {
$this->Error($parse_error);
}
}
// embed mask image
$imgmask = $this->Image($tempfile_alpha, $x, $y, $w, $h, 'PNG', '', '', $resize, $dpi, '', true, false);
// embed image, masked with previously embedded mask
$this->Image($tempfile_plain, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, false, $imgmask);
}
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.