Automatic reduction of attachment file sizes

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Automatic reduction of attachment file sizes

Post by Kyavion » Mon Jan 22, 2018 10:11 pm

The number one complaint I hear from people is that my site won't reduce file sizes like Facebook. Even though I've provided people with links to apps and other suggestions for how to easily reduce the file size of images, they have been spoiled by the ease of Facebook. Consequently, many users participate in Facebook groups instead (which apparently reduces images to 100kb or less????).

I've read some about ImageMagick and ReImg, but I'm unclear what these do? Will these in any way reduce the file size of images?

I also found the following... https://jerrywalsh.org/2009/automatical ... -0409.html

I'm a newbie at all this, so I hate to try the jerrywalsh.org change if it's going to cause me problems down the road. Can anyone tell me whether this will work with 3.2?

Thank you all for any help you can offer.

User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 2734
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Automatic reduction of attachment file sizes

Post by thecoalman » Wed Jan 24, 2018 2:21 am

phpBB 3.2 very much handles reducing file sizes and resizing uploaded images. You can set the max dimensions for both the thumbnails and the full image. The image is resized to whatever you set the max dimensions to. The smaller the dimension the smaller the file size is. Note that on 3.0 uplaoded files are not resized and would require the code changes you linked to. That is probably an old article and if the URL is any indication from 2009.

Note that .jpg images are lossy and you can set the "quality" of the image. This will also reduce the file size but it also reduces the quality of the image. While there is no setting for this in phpBB out of the box a simple edit will suffice.

Open phpBB3 phpbb_root/phpbb/plupload/plupload.php

on line 269 find:

Code: Select all

				'resize: {width: %d, height: %d, quality: 85},',
85 is generally the "happy" setting with decent file size reduction and little loss in quality but if you want smaller files you can change the 85 to something like 75, you won't see much difference on most images.

Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion » Tue Jan 30, 2018 1:11 am

Thanks for the reply. I really appreciate it!

I pulled up the line you were referring to and it currently specifies 85...

{
$resize = '';
if ($this->config['img_max_height'] > 0 && $this->config['img_max_width'] > 0)
{
$resize = sprintf(
'resize: {width: %d, height: %d, quality: 85},',
(int) $this->config['img_max_width'],
(int) $this->config['img_max_height']
);
}

return $resize;
}

In the ACP, in Attachment Settings, the Maximum File Size is currently set to 256 KIB. Is that a good size to have? As is, users receive an error indicating the file size is too large when attempting to attach images. Right now in the ACP, Maximum image dimensions are set to 0 x 0 px. If I understand correctly, plugging in specific dimensions here should resolve the issue? What image dimensions are recommended?

Thanks again for the help!

Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion » Tue Jan 30, 2018 1:42 am

I tried changing the MAX Image Dimensions in the ACP to 720px x 720px. Unfortunately, when I attempted to attach an image with a 2MB file size, the file size wasn't automatically reduced and I received an error indicating the file size is too large. Is there something else I need to change in the settings? Thanks for the help!

Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion » Tue Jan 30, 2018 2:21 am

So I did some playing around I changed the Max File Size in the ACP from 256KiB to 0. I then tried uploading an image and while the image listed as 2MB in the "Status" when uploading, the image was resized to 540 x 720 at a file size of 144.95KiB. I did another with the Maximum Image Dimensions in the ACP set at 800 x 600 px and the image was resized to 450 x 600 px at a file size of only 105.53KiB!

What would the optimal Maximum Image Dimensions be? The 800 x 600 looks good to me, but I have only tried it with a single image. Detail in both images looked pretty good to me.

Is there any drawback to changing the max image size from 256KiB to ZERO now that I have the Maximum Image Size Dimensions set?

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1743
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Automatic reduction of attachment file sizes

Post by kinerity » Tue Jan 30, 2018 12:42 pm

Please keep in mind that we have a six hour bumping rule. All team members and community members here are volunteers, so we ask you to wait at least six hours before bumping your topic or, if no-one has replied to your last post, edit your last post. Thanks!
Kailey Truscott - Community Team

Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion » Tue Jan 30, 2018 12:47 pm

Sorry about that. I hadn't intended that as a bump--I was just updating my progress. I see what you're saying though.

User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 2734
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Automatic reduction of attachment file sizes

Post by thecoalman » Tue Jan 30, 2018 2:30 pm

Under attachment settings the max file size should be set high especially if you want to allow people to upload videos. 20MB or even more. Set the max dimensions to what you want. I would suggest trying at least 1500.

Images will be resized client side and reduced on upload. The only issue here is for those few people that have Javascript disabled and the image file will not be reduced.

Additionally you can go into "Manage attachment extension groups" and set individual limits on specific files.

Kyavion
Registered User
Posts: 22
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion » Mon Feb 05, 2018 11:53 pm

Thanks. Appreciate the guidance. Too bad there isn't a "phpBB for Dummie's" doc out there.

Post Reply

Return to “[3.2.x] Support Forum”

Who is online

Users browsing this forum: invenio and 12 guests