[3.2][RC] Auto-Resize Images Server-side

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Anti-Spam Guide
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
Post Reply
dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

[3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Thu Nov 09, 2017 6:50 am

Extension Name: Auto-Resize Images Server-side
Author: dingus33

Extension Description: Automatically resize (shrink) image attachments server-side upon upload.
Extension Version: 1.0.3

Requirements: Requires ImageMagick.

Screenshots:
Image

Extension Download: https://github.com/ftc2/phpbb-autoresiz ... -1.0.3.zip

Features:

# Auto-Resize Images Server-side

## Installation

Copy the extension to phpBB/ext/ftc2/autoresize

Go to "ACP" > "Customise" > "Extensions" and enable the "Auto-Resize Images Server-side" extension.

Requires ImageMagick.

You may need to tweak the following settings to allow uploading larger files:

"ACP" > "General" > "Board configuration" > "Attachment settings":
  • set `Maximum file size` to a large value (or 0)
  • set `Maximum image dimensions` to 0
`php.ini` for the PHP installation used by your web server (look at your `phpinfo()` page):
  • increase `post_max_size`
  • increase `upload_max_filesize`
If you're getting an `HTTP error` error popup when uploading large files, look in your browser's console.
If you see plupload triggering `413 (Request Entity Too Large)`, then try configuring your web server to allow a larger client request body.

## Description

Automatically resize (shrink) image attachments server-side upon upload.

Hooks to the `core.modify_uploaded_file` PHP event.

Note that phpBB supports client-side image resizing via plupload, a feature that should be better advertised...
You can use this feature by specifying `Maximum image dimensions` in "ACP" > "General" > "Board configuration" > "Attachment settings".

However, the output quality is not that good, especially over large dimensional changes.

Resizing server-side with ImageMagick produces significantly better results (and smaller filesize in my testing) due to superior resize algorithm (Lanczos filter) at the expense of server load.

If image quality is important to you and your server can handle it, or if you don't have people constantly uploading files, then this might be an attractive solution.

Example:

phpBB built-in resizing (plupload):
Image

ImageMagick resizing with this extension with default -resize parameters:
Image

The second image has a slightly smaller filesize.

## Settings

From the ACP, you can trigger resizing based on uploads exceeding max filesize, max dimensions (width,height), or either one.

Regardless of how resizing is triggered, the image will be shrunk to not exceed specified max dimensions. Shrunk image is not *guaranteed* to be smaller than the max filesize.

You may specify ImageMagick parameters if you wish as well.

This extension also includes a feature to log debug messages to a text file.

## License

GPLv2
Last edited by dingus33 on Tue Nov 21, 2017 11:24 am, edited 2 times in total.

fabiomaticus
Registered User
Posts: 127
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [3.2][RC] Auto-Resize Images Server-side

Post by fabiomaticus » Fri Nov 10, 2017 6:50 am

Hi, fantastic extension

User avatar
Ger
Recognised Extension Developer
Posts: 1736
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][RC] Auto-Resize Images Server-side

Post by Ger » Fri Nov 10, 2017 7:37 am

dingus33 wrote:
Thu Nov 09, 2017 6:50 am
phpBB built-in resizing (plupload):
https://i.imgur.com/uQW8SfP.jpg

ImageMagick resizing with this extension with default -resize parameters:
https://i.imgur.com/Os8njgm.jpg

The second image has a slightly smaller filesize.
No offence, but to me it seems that the Plupload version has retained much more detail.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

fabiomaticus
Registered User
Posts: 127
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [3.2][RC] Auto-Resize Images Server-side

Post by fabiomaticus » Fri Nov 10, 2017 2:31 pm

I have this error in log file:
ERROR: PHP passthru() function not found.

maras2626
Registered User
Posts: 64
Joined: Tue Feb 07, 2017 4:48 pm

Re: [3.2][RC] Auto-Resize Images Server-side

Post by maras2626 » Mon Nov 13, 2017 12:02 am

Hi, extension unfortunately does not work :(

dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Fri Nov 17, 2017 8:54 pm

fabiomaticus wrote:
Fri Nov 10, 2017 2:31 pm
I have this error in log file:
ERROR: PHP passthru() function not found.
i've changed it to use the exec() function, but if your host doesn't give you access to PHP's exec() either, then you can't use this extension.
you also won't be able to use anything in phpBB that uses ImageMagick (like the thumbnail generation feature).
Last edited by dingus33 on Fri Nov 17, 2017 9:12 pm, edited 1 time in total.

dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Fri Nov 17, 2017 8:55 pm

maras2626 wrote:
Mon Nov 13, 2017 12:02 am
Hi, extension unfortunately does not work :(
can you please give me more info?
did you try enabling debug and looking at the messages?

dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Sat Nov 18, 2017 2:51 am

Ger wrote:
Fri Nov 10, 2017 7:37 am
dingus33 wrote:
Thu Nov 09, 2017 6:50 am
phpBB built-in resizing (plupload):
https://i.imgur.com/uQW8SfP.jpg

ImageMagick resizing with this extension with default -resize parameters:
https://i.imgur.com/Os8njgm.jpg

The second image has a slightly smaller filesize.
No offence, but to me it seems that the Plupload version has retained much more detail.
none taken!

to me, the plupload one looks basically unusuable. no antialiasing, full of noise.

also, just FYI, plupload has since supposedly improved their resizing algorithm. phpBB is still using a version before that update.
i tested the latest version of plupload, and it still looked really bad! that's why i made this extension.

basically, plupload is limited in what algorithms they can use because javascript just isn't as performant at the end of the day.
they were testing better ones, but they chose not to use them because they're too slow.
using ImageMagick can still be a little slow, but you get all the best algorithms along with robust autodetection that does a pretty good job of deciding which one to use by default based on the image being operated on. and it's also going to be about as performant as you can get because it's written in C.

fabiomaticus
Registered User
Posts: 127
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [3.2][RC] Auto-Resize Images Server-side

Post by fabiomaticus » Thu Nov 23, 2017 4:13 pm

dingus33 wrote:
Fri Nov 17, 2017 8:54 pm
fabiomaticus wrote:
Fri Nov 10, 2017 2:31 pm
I have this error in log file:
ERROR: PHP passthru() function not found.
i've changed it to use the exec() function, but if your host doesn't give you access to PHP's exec() either, then you can't use this extension.
you also won't be able to use anything in phpBB that uses ImageMagick (like the thumbnail generation feature).
My host said the EXEC function is Dangerous, but can activate it to my responsibility.

dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Fri Feb 02, 2018 6:57 pm

fabiomaticus wrote:
Thu Nov 23, 2017 4:13 pm
dingus33 wrote:
Fri Nov 17, 2017 8:54 pm
fabiomaticus wrote:
Fri Nov 10, 2017 2:31 pm
I have this error in log file:
ERROR: PHP passthru() function not found.
i've changed it to use the exec() function, but if your host doesn't give you access to PHP's exec() either, then you can't use this extension.
you also won't be able to use anything in phpBB that uses ImageMagick (like the thumbnail generation feature).
My host said the EXEC function is Dangerous, but can activate it to my responsibility.
it's needed to call IM (the external libs/utils instead of the PHP class/plugin). again, this is the same way phpbb itself is currently using IM.

Ivan007
Registered User
Posts: 26
Joined: Tue Jan 09, 2007 8:28 am
Contact:

Re: [3.2][RC] Auto-Resize Images Server-side

Post by Ivan007 » Mon Mar 19, 2018 8:13 pm

Dingus33,
Would you mind adding in to ACP jpg quality parameter?
This is an often required fine tuning for specific needs.

Thanks in advance!

P.S. PHP exec() is forbidden by majority of public hosting’s around the globe... this will not help your your great extension to gain popularity :cry:

dingus33
Registered User
Posts: 30
Joined: Fri Sep 29, 2017 11:11 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by dingus33 » Sun Mar 25, 2018 5:14 am

Ivan007 wrote:
Mon Mar 19, 2018 8:13 pm
Dingus33,
Would you mind adding in to ACP jpg quality parameter?
This is an often required fine tuning for specific needs.

Thanks in advance!
you should be able to use the ImageMagick parameters setting on the extension's ACP module to do that.
here is the documentation: https://www.imagemagick.org/script/mogrify.php
if you have specific questions about ImageMagick settings, let me know. i can try to help you tweak it.
fyi, right now i am using these parameters for my forum: -auto-orient -resize
Ivan007 wrote:
Mon Mar 19, 2018 8:13 pm
P.S. PHP exec() is forbidden by majority of public hosting’s around the globe... this will not help your your great extension to gain popularity :cry:
thanks, i hope someone out there is enjoying it.
i've been using it on my forum for a while now without issues. it's working well in production.

i agree, that is a problem.
as i've said before, phpBB itself does have some optional features that utilize ImageMagick directly via the php passthru() function, which is just as 'dangerous' as exec(). i assume that many web hosts disable both functions.
there is an ImageMagick php extension, but i have no idea if it's commonly installed by web hosts. if it is, then i could consider rewriting the extension to use that instead.

aside from that, i would like to clean up the code a bit more and try to submit it for validation.
i think i'll wait until phpBB 3.2.3 is released though because then i can add support for avatar resizing thanks to Ger's update to core.avatar_driver_upload_move_file_before.

Fezroux
Registered User
Posts: 25
Joined: Thu Dec 14, 2017 7:41 am

Re: [3.2][RC] Auto-Resize Images Server-side

Post by Fezroux » Thu Sep 20, 2018 1:30 am

Hello, I installed this mod which seems to be working as it should right out of the box besides one complaint. I had a member contact me saying they receive an error stating "It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct." when they try uploading an image. I found a topic here discussing this error in detail but figured I'd ask you first before I start trying the various fixes in that other thread as I imagine this being the probable cause.

I'm using this on 3.2.2

Post Reply

Return to “Extensions in Development”

Who is online

Users browsing this forum: ivailo95 and 24 guests