Avatar serverside resize

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The next feature release of phpBB 3 will be 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.2.x. If you need support for phpBB 3.2.x please visit the 3.2.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
brinkman
Registered User
Posts: 1
Joined: Wed Apr 11, 2012 7:32 pm

Avatar serverside resize

Post by brinkman »

Hi.

I think there could be on option to resize uploaded avatars that are to big to desired dimension (for example 100x100).
I mean with Imagemagick (or GD as failback). It is annoying to manualy resize avatars on computer each time you want to upload them.
I think almost all sistems have that option.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Avatar serverside resize

Post by Oleg »

Yes this would be nice.

User avatar
Dragosvr92
Registered User
Posts: 624
Joined: Tue May 31, 2011 12:08 pm
Location: Romania
Contact:

Re: Avatar serverside resize

Post by Dragosvr92 »

Agreed... this always annoyed me. The image you upload should be resized to the maximum avatar size set by the board owner/admin, and notify the user that his avatar image was resized to the x size. I dont know why phpbb hasnt incuded this yet.
Previous user: TheKiller
Avatar on Memberlist 1.0.3

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: Avatar serverside resize

Post by bantu »

Yup, would be nice.

Local uploads can also be resized via JavaScript. Plupload has this feature. Also see viewtopic.php?p=240349#p240349

User avatar
DionDesigns
Registered User
Posts: 51
Joined: Sat Apr 21, 2012 4:29 am
Location: Uncertain due to momentum
Contact:

Re: Avatar serverside resize

Post by DionDesigns »

Open /includes/functions_user.php and locate the following line (~ line 2078):

Code: Select all

$prefix = $config['avatar_salt'] . '_';
Insert BEFORE the above line:

Code: Select all

$file->resize($config['avatar_max_width'], $config['avatar_max_height']);
Add this function to includes/functions_upload.php (I put it just before the clean_filename function):

Code: Select all

 
The function will also resize attached images if called from the appropriate location.
Last edited by DionDesigns on Sat Jun 16, 2012 12:55 am, edited 1 time in total.

User avatar
DionDesigns
Registered User
Posts: 51
Joined: Sat Apr 21, 2012 4:29 am
Location: Uncertain due to momentum
Contact:

Re: Avatar serverside resize

Post by DionDesigns »

I probably should mention that image resizing requires a LOT of memory. While it's probably not an issue with avatars, it most likely will be with attached images. Adding the following line to the start of posting.php and ucp.php should eliminate most of those issues:

Code: Select all

ini_set('memory_limit','128M');
I would imagine that this (per-script) method to increase memory will work with most hosting companies. If you want the extra memory on all pages in phpBB3, add the line to includes/startup.php instead.

Finn Skovgaard
Registered User
Posts: 1
Joined: Fri Nov 23, 2012 9:34 pm

Re: Avatar serverside resize

Post by Finn Skovgaard »

Is someone here willing to spell it out 'for dummies' precisely what to update to make this work for uploading an avatar from the user's local computer? I'm on 3.0.11.

Adding the line to /includes/functions_user.php is simple enough.

It is
"Add this function to includes/functions_upload.php (I put it just before the clean_filename function):"
I don't follow. Add what? Which function? Where do I copy the function code to insert?

Another question is, when I update this code, should I just overwrite the existing one, or is there something to do to keep it consistent with update procedures? It's a new installation, and I haven't been through upgrades/mods yet.

All I want is to relieve the end user of the need to manually resize his or her profile photo (avatar), particularly since it's a forum for non-techies. Only local upload is allowed. Automatic resizing of profile photos is becoming the norm today, and ease of use is very important on the forum concerned.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: Avatar serverside resize

Post by Oleg »

Finn Skovgaard wrote:Is someone here willing to spell it out 'for dummies' precisely what to update to make this work for uploading an avatar from the user's local computer? I'm on 3.0.11.
The earlier post is missing a part of the code, therefore someone has to write it first.

Also, please note that this is not a support forum.

Another avatar resize topic: viewtopic.php?f=99&t=42863

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: Avatar serverside resize

Post by Pony99CA »

This is a good idea, but I disagree with the following:
TheKiller wrote:The image you upload should be resized to the maximum avatar size set by the board owner/admin, and notify the user that his avatar image was resized to the x size.
Making an image larger can cause pixellation. If you want to maximize the avatar, there should be an option to upload as-is if the user doesn't like how the up-sized avatar preview looks or intentionally wants a smaller avatar (perhaps to stand out).

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

ecwpa
Registered User
Posts: 181
Joined: Mon Jan 24, 2005 2:10 am
Contact:

Re: Avatar serverside resize

Post by ecwpa »

+1 to this
Slightly better English than it was in 2005, still improving :D

Post Reply