File size bigger if plupload Quality at 100%. How to keep it neutral

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
User avatar
ouiouiphoto
Registered User
Posts: 91
Joined: Mon Jun 15, 2015 5:30 am
Contact:

File size bigger if plupload Quality at 100%. How to keep it neutral

Post by ouiouiphoto »

Dear all

Bonne Année ;)

In the phpbb/plupload/plupload.php the compression quality is hard coded at 85%. I have a photo forum ans my user already take care of the compression and i want the system to be neutral so i have put 100%. But the file size is becoming bigger than the original. A 345KB file will became a 430KB File

Is the anyway to keep this neutral asking plupload not to change the original file ?

Any Idea is welcome

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

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by thecoalman »

If you have set maximum image dimensions and they are being resized the original file size is irrelevant. Quick check here on phpBB.com and no change to the file size on images not resized . On my own forum I've edited the code to address issues with orientation, this is causing them to be resampled even when they are not resized..
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison

User avatar
EA117
Registered User
Posts: 1295
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by EA117 »

thecoalman wrote:
Tue Jan 07, 2020 2:41 pm
If you have set maximum image dimensions and they are being resized the original file size is irrelevant. Quick check here on phpBB.com and no change to the file size on images not resized . On my own forum I've edited the code to address issues with orientation, this is causing them to be resampled even when they are not resized..
I'm unclear on that, because the last testing performed reached this conclusion (also related: this discussion), which had confirmed KYPREO's assertion that the image is always processed even if it's within resolution limits.

That analysis seemed to indicate that plupload's decision of "this image doesn't need to be processed before upload" requires conditions of both preserve_headers == true and quality == undefined to be true. But as we all agree, phpBB has quality hard-coded to 85%. So the quality == undefined condition is never true. And therefore the "just destroy the temp image without processing it" decision path is never taken, and image is always processed before upload "just to meet the imposed quality level."

But maybe I have something wrong in that analysis that you can spot...

User avatar
ouiouiphoto
Registered User
Posts: 91
Joined: Mon Jun 15, 2015 5:30 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by ouiouiphoto »

Thanks for you answer but the image are not resized they respect my maximum pixel size and file size. My limit is 1600px X 1600px and 1000KB. The file i upload is 1000 px X 6600 and 354KB. So with a image not resized with the quality at 85% the final size of the image is not the good one. Plupload compress.

And i just want him not to compress

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

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by thecoalman »

EA117 wrote:
Tue Jan 07, 2020 4:51 pm
I'm unclear on that, because the last testing performed ..
Works here, does not work on my forum apparently because but I have some custom edits
Attachments
Windows reports file size of 23.6 KB on my machine.
Windows reports file size of 23.6 KB on my machine.
Windows reports file size of 128 KB's on my machine.. Saved and compared uploaded version and Windows still reports it is 128KB.
Windows reports file size of 128 KB's on my machine.. Saved and compared uploaded version and Windows still reports it is 128KB.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison

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

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by thecoalman »

ouiouiphoto wrote:
Tue Jan 07, 2020 8:34 pm
Thanks for you answer but the image are not resized they respect my maximum pixel size and file size. My limit is 1600px X 1600px and 1000KB. The file i upload is 1000 px X 6600 and 354KB.
Is that a typo? 6600 is greater than 1600 ;) , have you checked dimensions of the uploaded files?
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison

User avatar
EA117
Registered User
Posts: 1295
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by EA117 »

thecoalman wrote:
Tue Jan 07, 2020 9:51 pm
Works here, does not work on my forum apparently because but I have some custom edits
I see the same result you've confirmed; that here on phpbb.com/community the upload of .JPG is able to retain it's original quality.

What I see in poking at this further is that the "phpBB processes at 85% quality even if the file is already within image resolution limits" behavior being observed in the previous tests requires that a resolution limit is in fact set. Indeed I was testing with a phpBB image resolution limit set during the previous testing, as part of the overall investigation which was occurring.

If I remove the "Maximum image dimensions:" limit on my test board (leaving only a file size limit), then I see the same behavior as phpbb.com/community where the attachment will not be re-processed at 85%. And by viewing the page source on the posting form, I can confirm that phpbb.com/community does not have an image resolution limit set for plupload to honor.

Looking back at the plupload code, this behavior appears to occur because of the !plupload.isEmptyObj(up.settings.resize) condition which is checked before invoking resizeImage(). If no image resolution limit parameters were ever passed to plupload by phpBB, there is no chance for plupload to reach the preserve_headers == true and quality == undefined test previously referenced.

So bottom line, even though the image may be fully within the effective phpBB image dimension limits in both scenarios, there is a different outcome depending upon whether a phpBB image dimension limit is actually set in the ACP. If no dimension limit is set in phpBB, neither the hard-coded 85% quality nor the hard-coded preserve_headers will be imposed on images uploaded. But if a dimension limit is set in phpBB, even images that are already within the set limit will be "forcibly" re-processed for quality and headers anyway.

ouiouiphoto wrote:
Tue Jan 07, 2020 1:15 pm
Is the anyway to keep this neutral asking plupload not to change the original file ?
The previous described observations mean that one way you could avoid this is to remove the "Maximum image dimensions:" limit set in ACP. (i.e. Set this back to "0 x 0 px" in the ACP Attachment Settings.) And use only the file size limit (in bytes, KB, MB, etc.) to control uploads to the board.

If you need to keep the "Maximum image dimensions:" limit, no there isn't a way to "keep whatever the current quality is in the existing JPG file." Or at least, it would require some custom phpBB core and/or plupload code changes to achieve that outcome.

KYPREO
Registered User
Posts: 307
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by KYPREO »

EA117 wrote:
Tue Jan 07, 2020 11:43 pm
snip
This all makes perfect sense and is consistent with the observations I made in other posts.

If you set maximum image dimensions, plupload will always process the image irrespective of image size.
If you don't set maximum image dimensions, it won't.

The OP can try experimenting with the image quality figure between 85 and 100% to see whether there is a nice compromise between quality and size where the image is within the maximum resolution limits.

Alternatively, there is an extension in development which processes uploaded attachments server-side using the ImageMagiick PHP plugin instead of plupload. This reportedly has a better compression algorithm.

See here: viewtopic.php?t=2445391

Personally, I like plupload if only for the fact it: (a) (now) auto-rotates images; (b) strips EXIF data to preserve user privacy.
phpBB user since 2002
www.AusRotary.com

KYPREO
Registered User
Posts: 307
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by KYPREO »

FWIW, the default quality setting in the current version of plupload is actually 90%: https://www.plupload.com/docs/v2/Options

Also note the acknowledgement by Plupload that its compression algorithm is not suitable for generating high quality images - it is designed for avatars and thumbnails primarily. They are apparently introducing a new compression algorithm in a future version. See also here: https://www.plupload.com/docs/v2/Image- ... lient-Side
phpBB user since 2002
www.AusRotary.com

User avatar
EA117
Registered User
Posts: 1295
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by EA117 »

KYPREO wrote:
Wed Jan 08, 2020 12:04 am
This all makes perfect sense and is consistent with the observations I made in other posts.

If you set maximum image dimensions, plupload will always process the image irrespective of image size.
If you don't set maximum image dimensions, it won't.
Not quite the situation I would have phrased as "makes perfect sense", but otherwise understood. 😝

KYPREO wrote:
Wed Jan 08, 2020 12:12 am
FWIW, the default quality setting in the current version of plupload is actually 90%: https://www.plupload.com/docs/v2/Options
Agreed. If phpBB was not asserting it's own hard-coded default of 85% in the parameters it's passing to plupload, then plupload 2.3.6's own internal hard-coded default visible in the source code is 90%.


To me this just feels like a hole in plupload's logic, and the previously described tests should have involved some "OR" conditions rather than just "AND" conditions. There is no "quick fix" I can see that doesn't involve changing plupload's Javascript. Neither phpBB nor plupload intended "we need to make this image file size larger than it originally was."

If you wanted to illustrate an illogical edge case, you could actually create an image which would be accepted by plupload's size filter (because the user's file size is within the phpBB-configured limit), but would then be rejected by phpBB itself because the plupload-processed image now exceeds the limit phpBB had specified to plupload.

User avatar
ouiouiphoto
Registered User
Posts: 91
Joined: Mon Jun 15, 2015 5:30 am
Contact:

Re: File size bigger if plupload Quality at 100%. How to keep it neutral

Post by ouiouiphoto »

thecoalman wrote:
Tue Jan 07, 2020 9:58 pm
Is that a typo? 6600 is greater than 1600 ;) , have you checked dimensions of the uploaded files?
Yes sorry typo error. it was 1000 X 660 ;)

Thanks a lot to all participants for all answers.

I have remove the size check and yes, the image is not modified. Perfect. I will wait for a fix in some new versions to put it back

Post Reply

Return to “[3.2.x] Support Forum”