Well, it should happen as you set in acp: x-dimension is the horizontal axis, and y-dimension the vertical. I assume you set both to 600?shortmort37 wrote:I currently have thumbnail width set to 600 in the attachment settings of the ACP. But, a portrait mode image that has been uploaded has a scaled thumbnail dimensions at 447 in width, and 600 in height.
Do I take it, that "thumbnail width" really means the longest dimension?
Yes, that's right. Existing thumbnails are not affected. If you don't want to resize your thumbnails and your older ones are bigger than the newer ones, you can add a rule to your css (must be inshortmort37 wrote:And, if I were to reduce the thumbnail width to, say, 400 - there would be no rescaling of previously uploaded thumbnails, correct? And a thumbnail whose width is now in excess of 400 pixels would continue to display?
content.css
Code: Select all
dl.thumbnail img {
padding: 3px;
border: 1px solid transparent;
box-sizing: border-box;
}
No, there is none, but it should work with a relative simple script:shortmort37 wrote:Is there any utility, that would rescale all priors thumbnails to the new width?
thumbnail
= 1), check the current dimension (getimagesize-function), if they are bigger than allowed, call the generate_thumbnail-function from phpBBHi Dan, i edited my previous post before you answered because i misread your postingshortmort37 wrote:I am using ImageMagick. I don't see an option to set the maximum vertical thumbnail dimension - just the horizontal, which is set to 600. (My maximum image size is set to 5120x4096.). But since the photo in question came from my iPhone, I am sure the scaling was due to the metadata associated with the orientation.
Maybe it is worth to report it to the bug tracker (because there is a change in the acp language file needed).canonknipser wrote:Just checked again: In the core code, there is a function which checks the original orientation and uses the parameter in acp as "longest edge" instead of "width".
So, this is a "works as designed" and the acp-parameter must be read as "longest edge".
OK, i will try my bestshortmort37 wrote:So yes, I would very much be interested in your script!
Code: Select all
<?php
/**
* This script will re-generate all thumbnails for attachments from the attachment folder (default
* "files"), useful after changing the thumbnail width (= longest edge) via acp
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
// Name of script - change if you use a different name for the script
$scriptname = 'gen_thumb.php';
// Specify the number of attachments to handle in one run - reduce if you receive a timeout from server
$interval = 100;
// read id of last attachement copied
if (isset($config['last_thumb_id']))
{
$last_thumb_id = $config['last_thumb_id'];
}
else
{
$last_thumb_id = 0;
set_config('last_thumb_id', 0);
}
// count number of attachments to process
$sql = 'SELECT COUNT(attach_id) AS num_attach FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id > ' . (int) $last_thumb_id . ' AND thumbnail = 1 ORDER BY attach_id ASC';
$result = $db->sql_query($sql);
$attachs_count = (int) $db->sql_fetchfield('num_attach');
// Output Information
echo dheader();
// read required information from attachment table
$sql = 'SELECT attach_id, physical_filename, mimetype FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id > ' . (int) $last_thumb_id . ' AND thumbnail = 1 ORDER BY attach_id ASC';
$result = $db->sql_query_limit($sql, $interval);
// how many attachment do we copy in this run?
$actual_num = $db->sql_affectedrows($result);
if ($actual_num == 0)
{
// nothing to do
$complete = true;
}
else
{
$complete = false;
if ($attachs_count <= $interval)
{
// this is the last run
$complete = true;
}
while ($row = $db->sql_fetchrow($result))
{
// for each attachment
//remember id
$last_thumb_id = $row['attach_id'];
// build source filename including path (we fetch the path from config
$source = $phpbb_root_path . $config['upload_path'] . '/' . $row['physical_filename'];
// build destination filename including path
$destination = $phpbb_root_path . $config['upload_path'] . '/thumb_' . $row['physical_filename'];
// copy the file
if (create_thumbnail($source, $destination, $row['mimetype']))
{
// write info to user
echo sprintf("<tr><td class='succ'>creation of thumbnail succesful:</td><td>%s</td><td>%s</td><td>%s</td></tr>", $last_thumb_id, $source, $destination);
}
else
{
echo sprintf("<tr><td class='error'>creation of thumbnail failed:</span></td><td>%s</td><td>%s</td><td>%s</td></tr>", $last_thumb_id, $source, $destination);
}
}
// write last attachment id in config
if ($complete)
{
$last_thumb_id = 0;
set_config('last_thumb_id', 0);
}
else
{
set_config('last_thumb_id', $last_thumb_id);
}
}
// finished
echo dfooter();
function dheader()
{
global $attachs_count, $interval, $last_thumb_id;
if ($interval > $attachs_count)
{
$interval = $attachs_count;
}
$remain = $attachs_count - $interval;
return '<html>
<head>
<title>copy ' . $interval . ' attachments in this run, ' . $remain . ' remain to generate, starting with id '. $last_thumb_id .'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<style>
a:visited {COLOR: #3A4273; TEXT-DECORATION: none}
a:link {COLOR: #3A4273; TEXT-DECORATION: none}
a:hover {COLOR: #3A4273; TEXT-DECORATION: underline}
.error {COLOR: red; ; FONT-WEIGHT: bold}
.succ {COLOR: green; ; FONT-WEIGHT: bold}
body, table, td {COLOR: #3A4273; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; LINE-HEIGHT: 20px; scrollbar-base-color: #E3E3EA; scrollbar-arrow-color: #5C5C8D}
input {COLOR: #085878; FONT-FAMILY: Tahoma, Verdana, Arial; FONT-SIZE: 12px; background-color: #3A4273; color: #FFFFFF; scrollbar-base-color: #E3E3EA; scrollbar-arrow-color: #5C5C8D}
.install {FONT-FAMILY: Arial, Verdana; FONT-SIZE: 20px; FONT-WEIGHT: bold; COLOR: #000000}
</style>
</head>
<body bgcolor="#3A4273\" text="#000000">
<table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">
<tr>
<td>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><th colspan="4">copy ' . $interval . ' attachments in this run, ' . $remain . ' remain to generate, starting with id '. $last_thumb_id .'</th></tr>
<tr>
<th>Status</th><th>Attach_ID</th><th>phpBB internal file name</th><th>generated thumbail</th>
</tr>';
}
function dfooter()
{
global $scriptname, $complete;
if (!$complete)
{
$next_step_link = '<a href="' . $scriptname . '">Click to continue with next step</a>';
}
else
{
$next_step_link = "<b>Completed</b>";
}
return '<tr><td colspan="4" align="center">' . $next_step_link . '</td></tr>
</table>
</td>
</tr>
</table><br>
</body>
</html>';
}
?>
$interval
-variable.Any idea why some thumbs are failing why most of them is going fine?canonknipser wrote:It generates up to 100 thumbs in one run, you can change this value by modifying the$interval
-variable.
You can restart the script for the next block of attachments by clicking the link at the bottom or just by refreshing your browser.
When all thumbs are regenerated, the next run will start from the beginning
If they weren't images, they should not have a thumbnail info in the database. The scripts reads all entries in attachment table with the thumbnail-flag set to true and uses the phpBB-core-functions to create the thumbnail file. So, a thumbnail must have been present at some point ...Lumpy Burgertushie wrote:wild guess: maybe those attachments are not images but something else.
hard to say from the output, so can you give more information?kocureq wrote:Any idea why some thumbs are failing why most of them is going fine?
yourboardaddress/download/file.php?id=36&mode=view
, the image should be displayed)It makes me wonder: If thumbnails can be scaled dynamically with css - wouldn't it be possible (with an extension), to always render a thumbnail of the desired size? i.e., eliminate creating and storing thumbnails on upload, and render the thumbnail from the unscaled image dynamically in accordance with the ACP setting on download?canonknipser wrote:If you don't want to resize your thumbnails and your older ones are bigger than the newer ones, you can add a rule to your css (must be incontent.css
to set the max-width for a attachment thumbnail - i'm not good in css, so i didn't put any codingCode: Select all
dl.thumbnail img { padding: 3px; border: 1px solid transparent; box-sizing: border-box; }
) This way you can present a smaller version of the current thumbnail
![]()
It doesn't hurt to make an extension requestshortmort37 wrote:It makes me wonder: If thumbnails can be scaled dynamically with css - wouldn't it be possible (with an extension)