|
Joined: Mar 2005
Posts: 15
stranger
|
stranger
Joined: Mar 2005
Posts: 15 |
If an Avatar uploaded by an user is not exactly the size of the admin-defined maximum (e.g. 80x80 pixels), it is distorted to fit 80x80, no matter how the proportions were before. This leads to funny pictures...
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
Yeah, if it's too big - but avatars smaller than your 80x80 should appear correctly, right?
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Jun 2006
Posts: 16,303 Likes: 116
|
Joined: Jun 2006
Posts: 16,303 Likes: 116 |
You could turn off the max size, and images will be "As they're uploaded" but this can lead to issues with users uploading things too big.
|
|
|
|
Joined: Mar 2005
Posts: 15
stranger
|
stranger
Joined: Mar 2005
Posts: 15 |
As always in life, it's not a question of size It's distorted even if smaller then the limit. Try to set the limit on e.g. 120x80 and upload an avatar 80x80 and you'll see, what I mean.
|
|
|
|
Joined: Jun 2006
Posts: 16,303 Likes: 116
|
Joined: Jun 2006
Posts: 16,303 Likes: 116 |
I completely understand; the issue is the limit; the limit sets the size in the html code when they're loaded... If you delete the fields (or edit the size out of the templates) it will no longer set a size for the avitars.
|
|
|
|
Joined: Mar 2005
Posts: 15
stranger
|
stranger
Joined: Mar 2005
Posts: 15 |
In which file would I do that (delete or edit the size out of the templates)? And how could I make sure that in the next update it's not changed back?
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
This ends up being an issue if the getimagesize function doesn't work on the PHP installation. In that case it just uses the max width/height set in the control panel. You could just set both of those to blank to get around this for now.
Hopefully since we're doing a bit of image stuff with either GD or ImageMagick now we can try getting the image sizes with other options as well if getimagesize doesn't work.
|
|
|
|
Joined: Dec 2003
Posts: 1,796
Pooh-Bah
|
Pooh-Bah
Joined: Dec 2003
Posts: 1,796 |
Would a more current version of php solve this?
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
Well, this is supposed to have been available even in PHP 3. I've done testing on various servers and I haven't been able to find the common factor. Even on some servers that have a newer version of PHP installed, getimagesize will just return null.
|
|
|
|
Joined: Nov 2006
Posts: 3,095 Likes: 1
Carpal Tunnel
|
Carpal Tunnel
Joined: Nov 2006
Posts: 3,095 Likes: 1 |
I would think some type of global var or path is different or missing then.
|
|
|
|
Joined: Aug 2006
Posts: 1,649 Likes: 1
Pooh-Bah
|
Pooh-Bah
Joined: Aug 2006
Posts: 1,649 Likes: 1 |
FWIW - I only had a problem when I imported from Classic. My Classic avatars were all 64x64 but when I set up Threads, I changed my default to 72x72. Importing all the 64x64 avatars resized them to 72x72 in Threads. What I had to do was run a query that Rick gave me to resize all the avatars to 64x64 (they're actual size, despite the max) and all is well -- even newly added/uploaded/user avatars are displayed properly if they're smaller than 72x72 (my max), and if they're larger, they're resized to 72x72.
GangsterBB.NET (Ver. 7.6.1.1) PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54 2007 Content Rulez Contest - Hon Mention UBB.classic 6.7.2 - RIP
|
|
|
|
Joined: Jun 2006
Posts: 16,303 Likes: 116
|
Joined: Jun 2006
Posts: 16,303 Likes: 116 |
Any page that uses avitars will need to be edited if you want to edit the sizes out, if you look at the URL of a page you're on you can see what template needs edited. Example:
https://www.ubbcentral.com/forums/ubbthreads.php/ubb/[b]showflat[/b]/Number/174285/page/1/gonew/1#UNREAD This page I'm on is showflat, thus the template is showflat.tmp; or you can just leave the max size fields unset in the controlpanel...
|
|
|
|
Joined: Aug 2006
Posts: 111
member
|
member
Joined: Aug 2006
Posts: 111 |
Was this ever resolved?
I'm running v7.1 and I just had this issued reported to me and I just verified it. The images are not sizing correctly if they are not 80x80.
Fred
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
Basically, it boils down to a server specific problem. There are some PHP installs where getimagesize() just doesn't work, so there is no way for it to figure out the width/height of the image so it defaults to the config size.
In 7.2, since we now have the option of using GD2 or ImageMagick for CAPTCHA, I'll see if there is a way we can use those to determine the size of the image when getimagesize() doesn't work.
|
|
|
|
Joined: Aug 2006
Posts: 111
member
|
member
Joined: Aug 2006
Posts: 111 |
Rick,
I didn't have a problem with 6.5.5, users could upload an image and if they were larger then 80x80 it wouldn't let them do it and if it was smaller it didn't care.
Is there a code modification for this? Looking at Gizmo's it seems to try to take care of this on the show threaded list, but isn't the problem here on the editbasic file? I ask because the pictures on my site are also messed up in the user list and Gizmo's code doesn't touch that.
Fred
|
|
|
|
Joined: Aug 2006
Posts: 111
member
|
member
Joined: Aug 2006
Posts: 111 |
I had a mod set on restricting image sizes on my 6.5.5 board so images wouldn't run off the page or rather force a scroll of the entire topic/thread. I didn't put it back in for 7.1 because I think Rick handles this in the code (am I right on that?). But maybe this would also help to set code to check for the image size on uploading in editbasic? Here are the two code pieces I used. I don't know the original author or I would give them credit. The first one is in a file called "checkimages.php" <?php
/*~~~ begin configuration settings ~~~*/
/* maximum number of images per post */
$config['MaxImages']= 20;
/* maximun width of images in pixels */
$config['ImageWidth'] = 850;
/* maximun height of images in pixels */
$config['ImageHeight'] = 1400;
/* maximum image size in kilobytes*/
$config['ImageSize'] = 384;
/*~~~ end configuration settings ~~~*/
$ubbt_lang['ImageLimits'] = "
One or more images are not within the size limits !<br>
The maximum allowed image width is <b>{$config['ImageWidth']}</b> pixels.<br>
The maximum allowed image height is <b>{$config['ImageHeight']}</b> pixels.<br>
The maximum allowed file size is <b>{$config['ImageSize']}</b> kilobytes.
";
$ubbt_lang['MaxImages'] = "
Too many images! <br>
The maximum number of images in one post is <b>{$config['MaxImages']}</b><br>
";
$images = preg_match_all("/(\[IMG\]|\[{$ubbt_lang['TEXT_IMAGE']}\])http([^\[]*)\.(gif|jpg|png)(\[\/IMG\]|\[\/{$ubbt_lang['TEXT_IMAGE']}\])/i",$Body,$out,PREG_SET_ORDER);
if($images) {
for($n=0 ; $n < $images ; $n++){
$imagesunique[] = "http" . $out[$n]['2'] . "." . $out[$n]['3'];
}
$imagesunique = array_values(array_unique($imagesunique));
}
if($part1 == 1) {
if ($images > $config['MaxImages']) {
$peditchange = 1;
$preview = 1;
$executionend = 1;
}
if($executionend != 1) {
for($n=0 ; $n < count($imagesunique) ; $n++){
$imageUrl = $imagesunique[$n];
$imagehw = getimagesize($imageUrl);
if ($imagehw['0'] > $config['ImageWidth']) {
$peditchange = 1;
$preview = 1;
break;
}
if ($imagehw ['1'] > $config['ImageHeight']) {
$peditchange = 1;
$preview = 1;
break;
}
$imageSize = remote_file_size($imageUrl);
if ($imageSize > $config['ImageSize']) {
$peditchange = 1;
$preview = 1;
break;
}
}
}
}
if($part2 == 1) {
if ($images > $config['MaxImages']) {
$html -> not_right ($ubbt_lang['MaxImages']."You have $images images in your post.",$Cat);
}
for($n=0 ; $n < count($imagesunique) ; $n++){
$imageUrl = $imagesunique[$n];
$imageUrlError = "<br><br>".$imageUrl." :" ;
$Error=0;
$imagehw = getimagesize($imageUrl);
if ($imagehw['0'] > $config['ImageWidth']) {
$errormessage .= "$imageUrlError<br> {$imagehw['0']} pixels wide.";
$imageUrlError = "";
}
if ($imagehw ['1'] > $config['ImageHeight']) {
$errormessage .= "$imageUrlError<br> {$imagehw['1']} pixels tall.";
$imageUrlError = "";
}
$imageSize = remote_file_size($imageUrl);
if ($imageSize > $config['ImageSize']) {
$errormessage .= "$imageUrlError<br> $imageSize kilobytes large.";
$imageUrlError = "";
}
if($imageUrlError == ""){
$redtablestart = "<table bgcolor=\"#FF0000\" cellspacing=\"10\" cellpadding=\"0\"><tr><td>";
$tablestart = "<table width=\"600\" cellspacing=\"5\" cellpadding=\"0\" class=\"lighttable\"><tr><td>";
$redtableend = "</td></tr></table>";
$ImageArray[] = "<img src=\"$imageUrl\">";
$ImageArrayReplace[]= $redtablestart."<img src=\"$imageUrl\">".$redtableend;
}
}
if($ImageArray){
$PrintBody = str_replace($ImageArray,$ImageArrayReplace,$PrintBody);
$PrintBody = $PrintBody."<br><br>".$redtablestart.$tablestart.$ubbt_lang['ImageLimits'].$errormessage.$redtableend.$redtableend;
$preview = 1;
}
}
?>
and the other file is called "remotefilesize.php" <?php
function remote_file_size($url)
{
$head = "";
$url_p = parse_url($url);
$host = $url_p["host"];
$path = $url_p["path"];
$fp = fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp)
{ return false; }
else
{
fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");
fputs($fp, "HOST: dummy\r\n");
fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while (!feof($fp)) {
$headers .= fgets ($fp, 128);
}
}
fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header) {
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) {
$return = substr($header, strlen($s));
break;
}
}
$return = round($return/1024);
return $return;
}
?>
I started to post the modifications needed in the modify post file, but I would probably have to post the entire file, so I wont do that. Maybe the above to files can help you to see how they are using it. Fred
|
|
|
|
Joined: Aug 2006
Posts: 111
member
|
member
Joined: Aug 2006
Posts: 111 |
So I'm making some headroom.
First, I removed the picsize tag in the showthreaded/showflat as gizmo suggests and it does stop the distortion on these pages. However, it doesn't get rid of the distortion on either the showprofile or showmembers pages. I haven't figured out how to stop that.
However, this is not the "fix" it is only a "coverup" or bandaid if you will.
Looking at the database tables, in the user_profile table it has the avatar height and avatar width in there. My guess here is this is being populated with the getimagesize function Rick has in place in the changebasicl.inc.php file. So, the complete and probably simplest solution here would be to get this function to work, which I guess it does on some servers but not all.
Seeing that the code I posted above works on my server I guess the next thing for me would be to evaluate this code and try to find Rick's getimagesize function and see if I can make a change to make it work. The code I posted above would probably work on other servers as well, because I am pretty sure the author used a unix based server and I use a Windows based one.
Fred
|
|
|
|
Joined: Aug 2006
Posts: 111
member
|
member
Joined: Aug 2006
Posts: 111 |
FOUND THE BUG/FIX In scripts/changebasic.inc.php Find: $imagehw = getimagesize("{$config['UPLOADED_AVATAR_URL']}/$Picturefile"); Replace with: $imagehw = getimagesize("{$config['UPLOADED_AVATAR_PATH']}/$Picturefile"); Basically it is a typo, changing 'UPLOADED_AVATAR_URL to 'UPLOADED_AVATAR_PATH. Change this 1 line, resave the file and your gold, no need to change or remove any of the size stuff anywhere else. Fred
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
Wow, very nice catch Fred!
|
|
|
|
Joined: Jun 2006
Posts: 9,242 Likes: 1
Former Developer
|
Former Developer
Joined: Jun 2006
Posts: 9,242 Likes: 1 |
And thinking of this, that makes sense why it would work on some servers and not on others. Depending on how PHP is locked down, some servers can get image properties on a remote avatar, while some can't.
|
|
|
|
Joined: Jul 2006
Posts: 4,057
|
Joined: Jul 2006
Posts: 4,057 |
Fuzzy Bunny wont be happy, he missed it lol
BOOM !! Version v7.6.1.1 People who inspire me Isaac ME Gizmo
|
|
|
|
Joined: Jun 2006
Posts: 16,303 Likes: 116
|
Joined: Jun 2006
Posts: 16,303 Likes: 116 |
Missed it? I helped make Fred realise the issue :x...
|
|
|
|
Joined: Jul 2006
Posts: 4,057
|
Joined: Jul 2006
Posts: 4,057 |
Got yu you replied to "Fuzzy Bunny" pmsl....
BOOM !! Version v7.6.1.1 People who inspire me Isaac ME Gizmo
|
|
|
|
Joined: Jun 2006
Posts: 16,303 Likes: 116
|
Joined: Jun 2006
Posts: 16,303 Likes: 116 |
I was ignoring you
|
|
|
|
|
Test
by Phun - 05/28/2024 7:31 PM
|
|
0 members (),
435
guests, and
342
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
|
|