Loading...
Обучение/Помощь новичкам | Помогите с кодом за деньги
Привет всем. Нужен помощь по коду, кто поможет отблагодарю денюшкой.

Так, есть вот такой вот класс:

<?php
class SimpleImage {

var $image;
var $image_type;

function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image,$filename,$compression);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image,$filename);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width,$height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale) {
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
?>



&




<?
$res1 = '332'; //ширина
$res2 = '184'; //высота
$moment_s = (15 * $x);
$movie = new ffmpeg_movie(H . "video/video/" . $file['id'] . "" . $file['ext'] . "");
$frames_count = $movie->getFrameCount();
$frames_rate = $movie->getFrameRate();
$seconds = ceil($frames_count/$frames_rate);

for($k=1; $k<=$seconds-15; $k=$k+$moment_s){
$frame = ceil($k*$frames_rate);
echo $frame."<br>";
$image = $movie->getFrame($frame);
$show_img = $image->toGDImage();
#imagejpeg($show_img, H . "video/foto/mini/" . $file['id'] . "_" . $x . ".png");
$image = new SimpleImage();
$image->load($show_img);
$image->resize($res1, $res2);
$image->save(H . "video/foto/mini/" . $file['id'] . "_" . $x . ".png");
}
?>





1 код это класс для сжатия картинки + для изменения до нужного размера. Выполняет свою роль без проблем.

2 код это уже процесс получения изображений с видео, раньше работал стабильно, но пришлось добавить тот класс для улучшения работы. Как я уже говорил, тот класс выполняет свою работу качественно, но изображение с видео получаются полностью чёрными во вес экран, а все остальное норм. Подскажите, что я тут делаю не так?
________
посл. ред. 09.06.2019 в 17:39; всего 2 раз(а); by Boy
Почти полный код


<?php
if ($file['server'] == NULL){
if (is_file(H . "video/video/" . $file['id'] . $file['ext'])){
// Скрин
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `video_screen` WHERE `id_video` = '". $file['id'] ."'"),0)==0){
$x = 0;
for ($x=0; $x++<$set['max_fotoVideo'];){
if (is_file(H."video/foto/mini/" . $file['id'] . "_" . $x . ".png")){
if ($file['ext'] != '.mp4')echo "<img src = '/video/foto/mini/" . $file['id'] . "_" . $x . ".png' itemprop='thumbnail' height='" . $set['size_foto_2'] . "px' style='padding: 5px;' alt='" . filter(str_replace('_', ' ', $file['name2'])) . "' />";
} else {
// Главная
if ($x == 1){
mysql_query("INSERT INTO `video_screen` (`id_video`, `screen_key`, `time`, `oblozhka`, `num`) VALUES ('". $file['id'] ."', '".$file['id'] . "_" . $x ."', '".time()."', '1', '".$x."')");
$fotoid = mysql_insert_id();
mysql_query("UPDATE `video_file` SET `logo` = '".$x."' WHERE id = '". $file['id'] ."' LIMIT 1");
} else {
mysql_query("INSERT INTO `video_screen` (`id_video`, `screen_key`, `time`, `num`) VALUES ('". $file['id'] ."', '".$file['id'] . "_" . $x ."', '".time()."', '".$x."')");
}

$moment_s = (15 * $x);
$movie = new ffmpeg_movie(H . "video/video/" . $file['id'] . "" . $file['ext'] . "");
$frames_count = $movie->getFrameCount();
$frames_rate = $movie->getFrameRate();
$seconds = ceil($frames_count/$frames_rate);

for($k=1; $k<=$seconds-15; $k=$k+$moment_s){
$frame = ceil($k*$frames_rate);
echo $frame."<br>";
$image = $movie->getFrame($frame);
$show_img = $image->toGDImage();
#imagejpeg($show_img, H . "video/foto/mini/" . $file['id'] . "_" . $x . ".png");
$image = new SimpleImage();
$image->load($show_img);
$image->resize($res1, $res2);
$image->save(H . "video/foto/mini/" . $file['id'] . "_" . $x . ".png");
}

header('Location: /watch/' . $file['name_translit'] . '/');
}
}
}
?>

________
посл. ред. 09.06.2019 в 17:30; всего 1 раз(а); by Boy
попробуй расширение 100 на 100поставить.
Тихий (10.06.2019 в 12:01)
попробуй расширение 100 на 100поставить.

Ты вообще тему читал, что такой бред пишешь?
Тихий (10.06.2019 в 12:01)
попробуй расширение 100 на 100поставить.

Это не поможет
Онлайн: 5
Время:
Gen. 0.0806
(c) Bym.Guru 2010-2026