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: 31
Joined: Wed Jan 17, 2018 10:59 pm

Automatic reduction of attachment file sizes

Post by Kyavion »

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: 5871
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Automatic reduction of attachment file sizes

Post by thecoalman »

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.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
Kyavion
Registered User
Posts: 31
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion »

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: 31
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion »

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: 31
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion »

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
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Automatic reduction of attachment file sizes

Post by Kailey »

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 Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
Kyavion
Registered User
Posts: 31
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion »

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: 5871
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Automatic reduction of attachment file sizes

Post by thecoalman »

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.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
Kyavion
Registered User
Posts: 31
Joined: Wed Jan 17, 2018 10:59 pm

Re: Automatic reduction of attachment file sizes

Post by Kyavion »

Thanks. Appreciate the guidance. Too bad there isn't a "phpBB for Dummie's" doc out there.
User avatar
wollastoni
Registered User
Posts: 82
Joined: Fri Mar 18, 2022 10:07 am
Location: BZH, France

Re: Automatic reduction of attachment file sizes

Post by wollastoni »

Does the automatic reduction decrease the weight of images on our server ?

My issue is not the image size in pixels, but the weight of attachments due to hosting costs.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26506
Joined: Fri Aug 29, 2008 9:49 am

Re: Automatic reduction of attachment file sizes

Post by Mick »

You should start your own topic, this one is four years old and marked solved.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Post Reply

Return to “[3.2.x] Support Forum”