[ABD] Auto-Resize Images Server-side

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

[ABD] Auto-Resize Images Server-side

Post by dingus33 »

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

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

Requirements: Requires ImageMagick and the PHP exec() function to call it.

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

Features:

Auto-Resize Images Server-side

Installation

Requires ImageMagick and the PHP exec() function to call it.

Copy the extension to phpBB3/ext/ftc2/autoresize

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

You may need to tweak the following settings to allow uploading larger files or enable exec():

"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 or go to "ACP" > "System" > "General Tasks" > "PHP information"):
  • increase post_max_size
  • increase upload_max_filesize
  • look at disable_functions and remove exec if it's there
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.

Image

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 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.

You must specify the path to ImageMagick. The mogrify binary must be available there.

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

Changelog

v1.0.5 (06-05-2019)
  • fixed deprecated license string
v1.0.4 (05-31-2019)
  • adds -auto-orient to the default ImageMagick parameters to fix rotation issues on some uploaded images
License

GPLv2
Last edited by dingus33 on Sat Feb 22, 2020 9:19 pm, edited 15 times in total.
fabiomaticus
Registered User
Posts: 135
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

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

Post by fabiomaticus »

Hi, fantastic extension
User avatar
Ger
Registered User
Posts: 2107
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 »

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:

-Don't PM me for support-
fabiomaticus
Registered User
Posts: 135
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

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

Post by fabiomaticus »

I have this error in log file:
ERROR: PHP passthru() function not found.
maras2626
Registered User
Posts: 68
Joined: Tue Feb 07, 2017 4:48 pm

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

Post by maras2626 »

Hi, extension unfortunately does not work :(
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

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

Post by dingus33 »

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.
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

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

Post by dingus33 »

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?
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

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

Post by dingus33 »

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: 135
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

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

Post by fabiomaticus »

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.
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

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

Post by dingus33 »

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 »

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:
User avatar
dingus33
Registered User
Posts: 136
Joined: Fri Sep 29, 2017 11:11 am

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

Post by dingus33 »

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: 52
Joined: Thu Dec 14, 2017 7:41 am
Location: US

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

Post by Fezroux »

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
mastnacek
Registered User
Posts: 83
Joined: Thu Oct 25, 2018 6:43 am

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

Post by mastnacek »

Hello
I installed your extension. Path to imagemagick i use /home/www/tmp/ and phpbb agree with it.
After upload image filesize is same. No errors and in log I have this

INFO: [2018-10-25 07:52:51am] mastnacek: krmelec_2.jpg
INFO: image filesize too big; resizing.
INFO: /home/www/tmp/mogrify -resize 200x200\> "files/49_c4f852971b5eeba6eab44a7d7efb9c9a"
INFO: resized from 418695 B to 418695 B
INFO: resize execution time: 0.1436550617218s

Where could be a mistake?
Exabot
Translator
Posts: 217
Joined: Sun Jan 18, 2015 8:21 pm
Location: Estonia

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

Post by Exabot »

Ext not working phpbb 3.2.5
Locked

Return to “Abandoned Extensions”