mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Make better portrait thumbnails
This commit is contained in:
parent
57f923936a
commit
2ab1c49bb0
4 changed files with 95 additions and 121 deletions
|
@ -1783,7 +1783,6 @@ function im_resize($file_src, $file_dest, $wd, $hd, $q = 80) {
|
|||
}
|
||||
|
||||
function im_resizeV2($file_src, $file_dest, $wd, $hd, $q = 80) {
|
||||
return scaleUpImage($file_src, $file_dest, $wd, $hd);
|
||||
|
||||
//_error_log("im_resizeV2: $file_src, $file_dest, $wd, $hd, $q");
|
||||
$newImage = im_resize($file_src, $file_dest, $wd, $hd, 100);
|
||||
|
@ -1880,7 +1879,15 @@ function scaleUpImage($file_src, $file_dest, $wd, $hd) {
|
|||
$old_y = imageSY($src_img);
|
||||
|
||||
$sizes = scaleUpAndMantainAspectRatioFinalSizes($wd, $old_x, $hd, $old_y);
|
||||
|
||||
/*
|
||||
if($wd!==200){
|
||||
echo "<h1>Original</h1>X={$old_x} Y={$old_y}";
|
||||
echo "<h1>Destination</h1>X={$wd} Y={$hd}";
|
||||
echo '<h1>Results</h1>';
|
||||
var_dump($sizes);exit;
|
||||
}
|
||||
*
|
||||
*/
|
||||
$thumb_w = $sizes['w'];
|
||||
$thumb_h = $sizes['h'];
|
||||
|
||||
|
@ -3899,7 +3906,7 @@ function convertImageIfNotExists($source, $destination, $width, $height, $scaleU
|
|||
_error_log("convertImageToRoku: source does not exists");
|
||||
return false;
|
||||
}
|
||||
if (file_exists($destination)) {
|
||||
if (file_exists($destination) && filesize($destination) > 1024) {
|
||||
$sizes = getimagesize($destination);
|
||||
if ($sizes[0] < $width || $sizes[1] < $height) {
|
||||
_error_log("convertImageIfNotExists: file is smaller " . json_encode($sizes));
|
||||
|
|
|
@ -4179,24 +4179,8 @@ if (!class_exists('Video')) {
|
|||
$obj->thumbsGif = $gifSource['url'];
|
||||
}
|
||||
if (file_exists($jpegPortraitSource['path'])) {
|
||||
// create thumbs
|
||||
if (!file_exists($jpegPortraitThumbs['path']) && filesize($jpegPortraitSource['path']) > 1024) {
|
||||
_error_log("Resize JPG 1 {$jpegPortraitSource['path']}, {$jpegPortraitThumbs['path']}");
|
||||
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
|
||||
im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
|
||||
} else {
|
||||
im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
|
||||
}
|
||||
}
|
||||
// create thumbs
|
||||
if (!file_exists($jpegPortraitThumbsSmall['path']) && filesize($jpegPortraitSource['path']) > 1024) {
|
||||
_error_log("Resize JPG 2 {$jpegPortraitSource['path']}, {$jpegPortraitThumbsSmall['path']}");
|
||||
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
|
||||
im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
|
||||
} else {
|
||||
im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait, 5);
|
||||
}
|
||||
}
|
||||
convertImageIfNotExists($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait, true);
|
||||
convertImageIfNotExists($jpegPortraitThumbsSmall['path'], $jpegPortraitThumbsSmall['path'], $advancedCustom->thumbsWidthPortrait/2, $advancedCustom->thumbsHeightPortrait/2, true);
|
||||
} else {
|
||||
if ($type == "article") {
|
||||
$obj->posterPortrait = "" . getCDN() . "view/img/article_portrait.png";
|
||||
|
@ -4229,26 +4213,8 @@ if (!class_exists('Video')) {
|
|||
if (file_exists($jpegSource['path'])) {
|
||||
$obj->poster = $jpegSource['url'];
|
||||
$obj->thumbsJpg = $thumbsSource['url'];
|
||||
// create thumbs
|
||||
if (!file_exists($thumbsSource['path']) && filesize($jpegSource['path']) > 1024) {
|
||||
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
|
||||
//_error_log("Resize JPG 3 useFFMPEGToGenerateThumbs {$jpegSource['path']}, {$thumbsSource['path']}");
|
||||
im_resizeV3($jpegSource['path'], $thumbsSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
|
||||
} else {
|
||||
//_error_log("Resize JPG 3 {$jpegSource['path']}, {$thumbsSource['path']}");
|
||||
im_resizeV2($jpegSource['path'], $thumbsSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
|
||||
}
|
||||
}
|
||||
// create thumbs
|
||||
if (!file_exists($thumbsSmallSource['path']) && filesize($jpegSource['path']) > 1024) {
|
||||
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
|
||||
//_error_log("Resize Small JPG 4 useFFMPEGToGenerateThumbs {$jpegSource['path']}, {$thumbsSmallSource['path']}");
|
||||
im_resizeV3($jpegSource['path'], $thumbsSmallSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
|
||||
} else {
|
||||
//_error_log("Resize Small JPG 4 {$jpegSource['path']}, {$thumbsSmallSource['path']}");
|
||||
im_resizeV2($jpegSource['path'], $thumbsSmallSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape, 5);
|
||||
}
|
||||
}
|
||||
convertImageIfNotExists($jpegSource['path'], $thumbsSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape, true);
|
||||
convertImageIfNotExists($jpegSource['path'], $thumbsSmallSource['path'], $advancedCustom->thumbsWidthLandscape/2, $advancedCustom->thumbsHeightLandscape/2, true);
|
||||
} else {
|
||||
if ($type == "article") {
|
||||
$obj->poster = "" . getCDN() . "view/img/article.png";
|
||||
|
|
|
@ -34,13 +34,13 @@ class CustomizeAdvanced extends PluginAbstract {
|
|||
return array(
|
||||
'EnableMinifyJS',
|
||||
'usePreloadLowResolutionImages',
|
||||
'useFFMPEGToGenerateThumbs',
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDataObjectExperimental() {
|
||||
return array(
|
||||
'autoPlayAjax',
|
||||
'useFFMPEGToGenerateThumbs',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
|
|||
die(json_encode($obj));
|
||||
}
|
||||
if (file_exists($global['systemRootPath'].$obj->file)) {
|
||||
im_resizeV2($global['systemRootPath'].$obj->file, $global['systemRootPath'].$obj->fileThumbs, $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
|
||||
//im_resizeV2($global['systemRootPath'].$obj->file, $global['systemRootPath'].$obj->fileThumbs, $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
|
||||
convertImageIfNotExists($global['systemRootPath'].$obj->file, $global['systemRootPath'].$obj->fileThumbs, $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape, true);
|
||||
} else {
|
||||
$obj->msg = "Image not created {$tmpDestination} {$global['systemRootPath']}{$obj->file}" ;
|
||||
die(json_encode($obj));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue