Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 1 Ответов
  • 1408 Просмотров
*

Elimelech

  • Захожу иногда
  • 261
  • 2 / 0
Скачал архив библиотеки от сюда. 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

Как это исправить?
Спасибо що помощь!

Строка где вылезает ошибка: 
Код
$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);
}
« Последнее редактирование: 14.05.2017, 15:04:37 от Elimelech »
*

effrit

  • Легенда
  • 10132
  • 1118 / 13
  • effrit.com
судя по всему при каком-то условии происходит ошибка в формировании $img вот тут
$img = imagecreatefrompng($file);
и возвращается false

так что можно попробовать вот так обернуть участок кода
Код
    if($img){
// 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);
}
}
}
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Joomla накешировала 200Mb в директорию cache/page при отключенном кешировании, что за ...?

Автор Marygold

Ответов: 12
Просмотров: 5460
Последний ответ 27.09.2023, 09:23:54
от XFQDesNik
Joomla и Amazon S3

Автор Ghost_370

Ответов: 14
Просмотров: 10334
Последний ответ 07.04.2019, 09:38:02
от powerful888
tcpdf: PHP Warning: imagecreatefromjpeg

Автор Elimelech

Ответов: 20
Просмотров: 25113
Последний ответ 21.03.2018, 23:49:54
от Elimelech
Соц.иконки добавить, Joomla 1.5.26

Автор nuon

Ответов: 1
Просмотров: 6070
Последний ответ 04.03.2018, 21:34:56
от nuon
Как сделать JSON-LD микроразметку для Joomla 1.5

Автор Amigo9876

Ответов: 1
Просмотров: 5174
Последний ответ 05.01.2018, 21:54:43
от krot