Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 26th 2014, 3:36pm
@dion

as I had follow instruction replace the code to the Function_posting.php and user.php
change to avatar setting to
1) file size 262144 (default 30614)
2) max avatar size: 150x140 (default 90x90)

after clear all cookies, UCP edit avatar upload a jpg file(254K) and message as below:
"The submitted avatar is 813 pixels wide and 814 pixels high. Avatars must be at least 20 pixels wide and 20 pixels high, but no larger than 150 pixels wide and 150 pixels high."

This is the same issue before modifying the above two files!

Secondly, what is the attachment setting advice?

thanks you
Damien
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 26th 2014, 7:44pm
Are you using phpBB 3.0.x or phpBB 3.1? I ask because you said you modified the user.php file, which exists in phpBB 3.1 but not in phpBB 3.0.x.

This modification is not for phpBB3.1.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 26th 2014, 8:49pm
@dion

Sorry for typing, i am using newest version phpbb3.0.12. and the file is 1)includes/functions_user.php.
2)includes/functions_posting.php
I double check the codes follow on post #1,#2 all well done in these files!
ACP setting match your requirement!

thanks
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 26th 2014, 11:52pm
Thank you for this report. I did some testing and found a bug in the modification. There were specific cases where one could receive the exact error you received. Posts #1 and #2 have been edited to include the bug fixes.

IMPORTANT NOTE TO EVERYONE:

If you had previously applied the code changes in posts #1 and #2, please make the changes again using the updated modification code in those posts.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 27th 2014, 2:43pm
@Dion

after re-update this New version, my phpbb3 still have the same issue that cannot resize avatar and cannot re-size on upload attachment. (note I am using "Choose File"upload function)

issue as below:
1) for avatar....same message on post #21
2) upload file attachment, the file is 3.3M 2480x3507, quote"xxxxx.jpg (3.14 MiB) Not viewed yet"

During the whole processing which is not functioning on resizing for oversize without it still can edit avatar if the criteria match without error.

what shall I do now?

thanks you
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 27th 2014, 4:44pm
The only way the avatar/attachment would not be resized is if the create_thumbnail() function failed. That could only happen if your server does not support the PHP getimagesize() function, or if there is some sort of problem with the GD extension and/or ImageMagick application.

There isn't anything more I can do on my end...sorry. I suggest you contact your hosting company and find out if there are any problems with GD and/or ImageMagick.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted August 28th 2014, 12:08am
@Dion

Well noted with thanks!
What is the .GD stand for? I will ask my website hosting do they support about these files as below:
1) ImageMagick
2) GD
3)getimagesize() php

I will get back to you as soon as have problem solved!

thanks you anyway!
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted September 6th 2014, 9:05pm
@Dion

checked with my hosting Godaddy, they said the above all supported by default.

Is there anything else can make it work?
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted September 16th 2014, 11:31am
I just want image attachment resizing, so I've only edited functions_posting.php. I get the following error when trying to post something:

Parse error: syntax error, unexpected 'if' (T_IF) in \phpBB\includes\functions_posting.php on line 653


That's the code on line 653:

	if (!$img_filesize || $img_filesize <= $min_filesize)
φ
Posts: 1
Joined: September 6th 2014, 3:40am
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted September 17th 2014, 3:14pm
hi Dino

Finally it is fixed because of overlook the setting
1) Search right Path Imagemagick
2) Set Create Thumbnail to YES

you are great!
Thanks you
Damien
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted September 17th 2014, 4:06pm
Dreamer said:
I just want image attachment resizing, so I've only edited functions_posting.php. I get the following error when trying to post something:

Parse error: syntax error, unexpected 'if' (T_IF) in \phpBB\includes\functions_posting.php on line 653


That's the code on line 653:

	if (!$img_filesize || $img_filesize <= $min_filesize)

I checked the code and can find nothing which would cause the error you received. Is it possible you had a transcription error? Please make sure you have the correct edits.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted September 17th 2014, 4:06pm
damien990 said:
hi Dino

Finally it is fixed because of overlook the setting
1) Search right Path Imagemagick
2) Set Create Thumbnail to YES

you are great!
Thanks you
Damien

I'm glad you were able to figure out why the image resizing wasn't working.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 8th 2015, 12:03am
HI Dino

after update to new version phpbb3.1.4 which the functions_posting.php and functions_user.php files content cannot meet your criterial. your script cannot been paste into the files?

WOuld you make any update of this script.

ps: only funcions_posting.php script can be replaced on post 1.

Thanks
φ
Posts: 9
Joined: August 26th 2014, 2:17pm
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 8th 2015, 9:49am
This should be of some assistance: t9093/serverside-resize-of-uploaded-avatars/
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 23rd 2015, 6:15pm
Hi, your mod is great , thank you!. I have only one question. How can I change the image quality ? As I want to compress the image on upload.
φ
Posts: 22
Joined: May 2nd 2015, 4:29pm
Likes Given: 4
1
#36
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 23rd 2015, 10:11pm
Near the end of the new create_thumbnail() funnction, you'll find the following code block:

			switch ($type['format']) {
case IMG_GIF:
imagegif($new_image, $destination);
break;

case IMG_JPG:
imagejpeg($new_image, $destination, 90);
break;

case IMG_PNG:
imagepng($new_image, $destination);
break;

case IMG_WBMP:
imagewbmp($new_image, $destination);
break;
}

The JPG quality is set to 90. If you want smaller files, you can safely reduce it to 60. If you want to further compress a PNG image, use this line:

					imagepng($new_image, $destination, 9);

There is no way to alter how GIF or BMP images are saved.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 24th 2015, 4:06am
Thank you for your fast reply. I tried the trick but is not working :( . Maybe is working on avatars, I didn`t tried but I need compression for image attachments.
p.s. Is there a way I can have the mod that you have when you post a comment ? With that pop-up confirmation message without redirect to another page ?
φ
Posts: 22
Joined: May 2nd 2015, 4:29pm
Likes Given: 4
1
#38
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 24th 2015, 9:02am
What I posted is the only way to reduce the saved size of image attachments. No further compression is possible unless you choose to reduce the dimensions of saved image attachments. To do this, look at post #2, and change the 640/480 in this line to smaller dimensions:

$result = create_thumbnail($file->get('filename'), '', '', 640, 480);

All the code to AJAXify the posting page can be found in this topic.
φ
Posts: 1600
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted May 24th 2015, 10:09am
I discovered something funny, I`m using your mod and the mod "Advanced Attach Watermark" and I now can compress a 4.7MB jpg image to maximum 800x600 70kb image with watermark added and still good quality. You just need to set "Watermark Type: to image" and "JPG Quality Output: to 65" from the mod`s settings. If somebody need good image compression, this is the way. Thank you again for this great mod.
φ
Posts: 22
Joined: May 2nd 2015, 4:29pm
Likes Given: 4
Automatic Resizing of Uploaded Avatars and Image Attachments
Posted November 6th 2015, 7:54pm
hello

I found this thread and I tried to follow the instructions.

I was able to edit the functions_posting.php fine

but the functions_user.php I could not find the code

$prefix = $config['avatar_salt'] . '_';
$file->clean_filename('avatar', $prefix, $data['user_id']);


I am wondering if this is perhaps due to the phpbb board being 3.1.6 now and may be outdated as an option to install this


also I am only interested in avatar resizing and not the image resizing since i have that taken care of already.

Thanks for any info on this!

EDIT:
Nevermind ... I figured it out. I have two websites .. I did it on the wrong one. But I also found that there is a link that edits the upload.php .. and that is the key to get this working and the functions_user.php is not needed for the avatar resize .. so all is good now .. thanks for this!
φ
Posts: 1
Joined: November 6th 2015, 6:58pm

Who is online

Users browsing this forum: No registered users and 0 guests