Не выводит скрины к картинкам по всему сайту, тока формат gif выводит. =( На хосте всё работает, на сервере не хочет. Может я что забыл включить? Посоветуйте что делать?
ОБСУЖДЕНИЕ
Не выводит скрин к фото. =(
warsis, тоесть если на хостинге точно работало, а на серваке нет, то вариантов несколько. Доступы есть везде? например root доступ на сервер?
Не понял. А всё в ехал, да есть. Фото сливается на прямую, а через img.php не хочет работать. =(
warsis, img.php это файл на вывод? покажи его содержимое
<?php
class img {
public $width;
public $height;
public $newwidth = 0;
public $newheight = 0;
public $mime;
public $file;
public $img;
public $newimg;
public $error;
function __construct($file)
{
$this->file = $file;
}
/* * * * * * * * * * * * * * * *
* Функция загрузки изображеня
* $img - путь к файлу
* * * * * * * * * * * * * * * */
public function img_down()
{
$info = getimagesize($this->file);
switch ($info['mime']) {
case 'image/wbmp': $this->img = imagecreatefromWBMP($this->file); break;
case 'image/xbm': $this->img = imagecreatefromXBM($this->file); break;
case 'image/xpm': $this->img = imagecreatefromXPM($this->file); break;
case 'image/jpeg': $this->img = imagecreatefromJPEG($this->file); break;
case 'image/gif': $this->img = imagecreatefromGIF($this->file); break;
case 'image/png': $this->img = imagecreatefromPNG($this->file); break;
default: $this->error = 'Формат не поддерживается'; break;
}
$this->width = $info[0];
$this->height = $info[1];
$this->mime = $info['mime'];
return $this;
}
/* * * * * * * * * * * * * * * *
* Функция коректной смены размера изображения
* $width - ширина изображения
* $height - высота если не указывать изображение будет менять размер с пропорциями
* * * * * * * * * * * * * * * */
public function resize($width, $height = 0, $degrees)
{
/* * * * * * * * * * *
* Переворот картинки *
* * * * * * * * * * */
$color = imagecolorallocate($this->img, 255, 255, 255);
$this->img = imagerotate($this->img, $degrees, $color);
if ($this->error) return $this;
if ($height) {
$this->newWidth = $width;
$this->newHeight = $height;
} else {
$x_ratio = $width / $this->width;
$y_ratio = $width / $this->height;
if (($this->width <= $width) && ($this->height <= $width)) {
$this->newWidth = $this->width;
$this->newHeight = $this->height;
} elseif (($x_ratio * $this->height) < $width) {
$this->newHeight = ceil($x_ratio * $this->height);
$this->newWidth = $width;
} else {
$this->newWidth = ceil($y_ratio * $this->width);
$this->newHeight = $width;
}
}
if ($this->width == $this->newWidth && $this->height == $this->newHeight) {
$this->newimg = $this->img;
return $this;
}
$this->newimg = imagecreatetruecolor($this->newWidth, $this->newHeight);
$background_color = imagecolorallocate($this->newimg, 0, 0, 0);
imagecolortransparent($this->newimg, $background_color);
imagecopyresampled($this->newimg, $this->img, 0, 0, 0, 0, $this->newWidth, $this->newHeight, $this->width, $this->height);
return $this;
}
/* * * * * * * * * * * * * * * *
* Сохранение изображения
* $img - Загруженая картинка
* $patch - Имя я путь куда сохранить изображение
* $type - В каком формате сохранить
* $compres - Сжатие, от 0 до 100 (для jpeg)
* * * * * * * * * * * * * * * */
public function save($patch, $type = 'jpg', $compres = 75)
{
if ($this->error) return $this;
if (!$this->newimg) $this->newimg = $this->img;
if ($type == 'gif') imagegif($this->newimg, $patch);
if ($type == 'jpg' || $type == 'jpeg') imagejpeg($this->newimg, $patch, $compres);
if ($type == 'png') imagepng($this->newimg, $patch);
@chmod($patch, 0666);
return $this;
}
/* * * * * * * * * * * * * * * *
* Вывод изображения
* $type - В каком формате выводить gif, jpg или png (по умолчанию jpg)
* $compres - Сжатие, от 0 до 100 (для jpeg)
* * * * * * * * * * * * * * * */
public function print_img($type = 'jpg', $compres = 75)
{
if ($this->error) return $this;
if ($type == 'gif') {
header("content-type: image/gif");
imagegif($this->newimg);
} elseif ($type == 'jpg' || $type == 'jpeg') {
header("content-type: image/jpeg");
imagejpeg($this->newimg, '', $compres);
} elseif ($type == 'png') {
header("content-type: image/png");
imagepng($this->newimg);
} else {
header("content-type: image/jpeg");
imagejpeg($this->newimg, '', $compres);
}
return $this;
}
function __destruct()
{
if (!$this->error) {
ImageDestroy($this->img);
ImageDestroy($this->newimg);
}
}
}
?>
warsis, в папке куда загружаются расширение разные или может что-то меняет расширения на гиф? если разные то
nginx
подобное есть ? если исп панель то www-домены/выбираем домен* конфиг и листаем
nginx
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
подобное есть ? если исп панель то www-домены/выбираем домен* конфиг и листаем
Не меняет, а тока формат гиф выводит скрины, а png, jpg, jpeg не выводит. Тоесть если я залью гифку то привьюшка будет, а если другой формат то пустое место. =(
Может я какую библиотеку не включил?
warsis, ffmpeg попробуй включить. Что-то припоминаю о подобном, но точно не помню причину. ffmpeg хотя для аудио и видео
Включено.