Update _test folder
This commit is contained in:
77
_test/thumbs.php
Normal file
77
_test/thumbs.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php require ("3-protect.php");
|
||||
include 'functions.php';
|
||||
|
||||
/* ------------- */
|
||||
/* Create thumbs */
|
||||
/* ------------- */
|
||||
|
||||
$domain = 'sentier';
|
||||
localize($domain);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?php gettext('Insert photos in Sqlite base'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="css/sls.css" />
|
||||
<link rel='stylesheet' href='css/lc_lightbox.min.css' />
|
||||
<link rel='stylesheet' href='css/open_close_fx.css' />
|
||||
<link rel='stylesheet' href='css/minimal.css' />
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
function create_thumb($thumb_w, $thumb_h, $image, $src_folder, $dest_folder) {
|
||||
|
||||
list($origin_w, $origin_h) = getimagesize($image);
|
||||
$origin_ratio = round($origin_w / $origin_h, 1);
|
||||
#$outFile = str_replace("photos/img", "photos/thumb", $image);
|
||||
$outFile = str_replace($src_folder, $dest_folder, $image);
|
||||
|
||||
if ($origin_w != null && $origin_h != null) {
|
||||
if ($thumb_w / $thumb_h > $origin_ratio) {
|
||||
$thumb_w = $thumb_h * $origin_ratio;
|
||||
} else {
|
||||
$thumb_h = $thumb_w / $origin_ratio;
|
||||
}
|
||||
|
||||
if ($origin_w >= 400 && $origin_h >= 400) {
|
||||
$image = new Imagick($image); // !!!
|
||||
$image->thumbnailImage($thumb_w, $thumb_h);
|
||||
$image->writeImage($outFile);
|
||||
$image->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Taille des vignettes
|
||||
$th_w = 300;
|
||||
$th_h = 300;
|
||||
|
||||
$src_folder = 'photos/img/';
|
||||
$dest_folder = 'photos/thumbs/';
|
||||
$dir = (new AdvancedFilesystemIterator($src_folder))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP|avif|AVIF$/');
|
||||
|
||||
foreach($dir as $file){
|
||||
$file = $file->getpathName();
|
||||
create_thumb($th_w, $th_h, $file, $src_folder, $dest_folder);
|
||||
}
|
||||
?>
|
||||
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user