Attachment files - Can I resize them?

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
jester77
Registered User
Posts: 68
Joined: Sat Nov 11, 2006 4:22 pm
Name: Jon

Attachment files - Can I resize them?

Post by jester77 » Sat Jan 23, 2010 11:21 am

Hi All,
As it says it the title can I resize the ones that have already been uploaded to try and save some webspace?
I've downloaded them but they have no extension so I can't batch resize them with my normal programs.
Thanks.

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Wed Apr 13, 2011 7:03 pm

Anybody?

I have the same problem, people will attach a huge file then it automatically resizes the pic to be displayed, I have the settings set to create a thumbnail 800x600 so this works perfectly but I am stuck with the orignal pic that is many times over a meg some 2 megs.

I have given up on trying to train people to resize their pictures before uploading lets face it this is not going to happen, I even had it reject pictures over 500k for a while but spent most my life trying to explain to users why they could not attach pictures.

I tried the photobucket suggestion this is worthless too now we have a bunch of post with dead photobucket accounts and people wanting to see the pictures.

None of this was any problem with phpbb2 life was great, every month or so I would download the latest pictures uploaded in the "files" directory then resize them on my computer then upload them back to the server over writing the bloated pictures, the problem now is phpbb3 renames the file and it has no extension so now I have GIGS of wasted space on the server and cant not batch resize the pictures.

I have unlimited server space but having gigs of bloated files when downloading and restoring backups is just nuts.

Is their a way to download the pictures batch convert the file names, resize the pictures and then batch convert the file names back?

Is their a way to change the code so the attachments keeps the files on the server in their original names and format?

Thanks.

Pit$Bull
Former Team Member
Posts: 23099
Joined: Sat Dec 02, 2006 4:08 pm
Name: Can't Remember

Re: Attachment files - Can I resize them?

Post by Pit$Bull » Wed Apr 13, 2011 7:06 pm

You can limit the file size, but no conversion is possible.

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Wed Apr 13, 2011 7:18 pm

Pit$Bull wrote:You can limit the file size, but no conversion is possible.
Hi thanks, already knew this looking for a solution, fix, mod, script change, solution for the problem.

Anybody else.

Thanks in advance :)

Pit$Bull
Former Team Member
Posts: 23099
Joined: Sat Dec 02, 2006 4:08 pm
Name: Can't Remember

Re: Attachment files - Can I resize them?

Post by Pit$Bull » Wed Apr 13, 2011 7:19 pm

No conversion is possible.

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Wed Apr 13, 2011 8:47 pm

Pit$Bull wrote:No conversion is possible.
Is their any way the attachment mod for phpbb2 can be added to phpbb3 so it does not butcher the file names?

Pit$Bull
Former Team Member
Posts: 23099
Joined: Sat Dec 02, 2006 4:08 pm
Name: Can't Remember

Re: Attachment files - Can I resize them?

Post by Pit$Bull » Wed Apr 13, 2011 8:50 pm

phpBB2 MOD's are not compatible with phpBB3.

There is a very good image resize MOD (not file size) http://www.phpbb.com/customise/db/mod/r ... ge_resizer

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Wed Apr 13, 2011 9:30 pm

Pit$Bull wrote:phpBB2 MOD's are not compatible with phpBB3.

There is a very good image resize MOD (not file size) http://www.phpbb.com/customise/db/mod/r ... ge_resizer

I was searching around and ran into that mod I was under the impression that it only resized the pictures as the page was loading and this was to make them fit the screen, it does not resize the pictures that are stored on the server itself?

We are not having any image display problems using the provided attachment mod settings we have that under control perfectly it re-sizes perfectly, any picture larger than 800x600 is resized and a 800x600 thumbnail is created the problem were having the over sized file that is left on the server and never used, the 800x600 picture size satisfies everybody its rare when you see someone has actually clicked on a 800x600 thumbnail and viewed the larger file sizes.

Whats with the file name changing of the pictures all my pictures in the "files" directory from when we were running phpbb2 still have the jpg extensions on them all the files attached after we converted to phpbb3 have no extension.


Thanks again.

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10347
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Attachment files - Can I resize them?

Post by Noxwizard » Wed Apr 13, 2011 10:03 pm

The name change is a security measure to prevent browsers from mis-rendering maliciously crafted images. You can read more about it here: http://blog.phpbb.com/2008/10/25/attach ... -explorer/
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 50895
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Attachment files - Can I resize them?

Post by stevemaury » Wed Apr 13, 2011 10:23 pm

Also, it permits different files which have the same name, which can happen when people upload files.

I am not sure why you have to explain to people why they cannot upload pictures, because the message they get when they try to exceed the limit you imposed makes it very clear.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Wed Apr 13, 2011 10:50 pm

stevemaury wrote:Also, it permits different files which have the same name, which can happen when people upload files.

I am not sure why you have to explain to people why they cannot upload pictures, because the message they get when they try to exceed the limit you imposed makes it very clear.
This does nothing to resolve the problem that phpbb3 has created but I will answer it anyways, you have to explain to the user simply because they have no idea what to do after reading the error they just got the last 15 post they made with pictures worked perfectly, they have never resized pictures before in their life, they have no idea what mega pixel means or how to adjust it on their camera, I have made tutorials with step by step instructions detailing how to resize pictures most cant get past installing the new program that is required, you know how to, I know but you have to remember 99.9% of the users have no clue and are never going to be computer savoy enough to know.

Its clear to me that now that things has evolved phpbb3 needs to evolve with it or be left behind, the smallest pictures I have seen come off a cell phone are 1.5 megs that seems to be the standard, I been getting 3 meg pictures from some users using digital cameras, if I am exceeding the capabilities or limits of phpbb and their is no way to resolve the problems I have described then its time for me to abandon phpbb3 and move onto a message board that is not so limited?

Sorry to sound negative just getting real frustrated with what seems like a really simple problem to me, phpbb3 has already proven it has the ability to check the size of the picture that is uploaded then if its for example over 800x600 it creates a thumbnail and displays it as 800x600 and not the original size presented, all we have to make it do now is delete the file over 800x600 so we dont have gigs and gigs of wasted server space.


Thanks again.

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 50895
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Attachment files - Can I resize them?

Post by stevemaury » Wed Apr 13, 2011 11:06 pm

The message says the file is too big. It says nothing about megapixels or any of the other things you mention. Of course, you can make that message say whatever you want it to say by editing the language file.

phpBB3 has created no problem. People can upload files as large as the admin allows. Attachments were not even a feature of phpBB2, but rather a MOD, so nothing has changed in the way phpBB handles attachments.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Thu Apr 14, 2011 12:41 am

stevemaury wrote:The message says the file is too big. It says nothing about megapixels or any of the other things you mention. Of course, you can make that message say whatever you want it to say by editing the language file.

phpBB3 has created no problem. People can upload files as large as the admin allows. Attachments were not even a feature of phpBB2, but rather a MOD, so nothing has changed in the way phpBB handles attachments.



"so nothing has changed in the way phpBB handles attachments"

phpbb3 changes the way it handles the files you attach, it changes the name and the extension, this has created a huge problem now I have over 4000 attachments totaling 3.2 gigs I cannot resize, this was not a problem in phpbb2 with the "mod" or what ever word games or phrase games you want to play, the thingie that allowed people to attach pictures to their messages when they post or replied or send private messages using phpbb2 what ever it is.

For some reason it does not change the file extension of PDF, KMZ, GPX, TXT, DOC, XLS, AVI, MPG, WMV etc. files the only security concerns are just with pictures.

I see no need for you to continue to reply you have no solutions, reading other post on this site and the lack of replies on this subject I guess I need to seek help else where.

Thanks again.

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 50895
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Attachment files - Can I resize them?

Post by stevemaury » Thu Apr 14, 2011 2:08 am

There is no solution because there is no problem. You are incorrect when you say only .jpg file extensions are eliminated. In fact, all file attachments in phpBB3 have no extension. And you are incorrect about the way phpBB2 handled attachments since phpBB2 DID NOT have attachments as a feature. There was a MODification that supplied an attachment functionality. MODifications are not supported by nor created by phpBB.

I understand your concern, but the files you permit your users to attach are the files that will be attached. That simple.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)

carla1234
Registered User
Posts: 48
Joined: Mon Jan 24, 2011 7:01 pm

Re: Attachment files - Can I resize them?

Post by carla1234 » Thu Apr 14, 2011 5:31 pm

Is their any reasons why NOT to use the below?

Open the file includes/functions_upload.php
Search

Code: Select all

    function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)
Insert the code (the function) before it

Code: Select all

        /**
        * Resize images with the true diemensions (800*600)
        */
        function resize_images()
        {
           if ( $this->is_image() ) {
           $limite_largeur = "800px";
           $limite_hauteur = "600px";
           $size = getimagesize($this->destination_file);
           $largeur = $size[0];
           $hauteur = $size[1];
           if($hauteur > $limite_hauteur OR $largeur > $limite_largeur)
           {
           if($largeur > $limite_largeur)
           {
           $hauteur = $hauteur / ($largeur / $limite_largeur);
           $largeur = $limite_largeur;
           }
           if($hauteur > $limite_hauteur)
           {
           $largeur = $largeur / ($hauteur / $limite_hauteur);
           $hauteur = $limite_hauteur;
           }
           
           $destination = imagecreatetruecolor($largeur, $hauteur);
           if ( $this->extension == "jpg" || $this->extension == "jpeg" ) $source = imagecreatefromjpeg($this->destination_file);
           elseif ( $this->extension == "png" ) $source = imagecreatefrompng($this->destination_file);
           elseif ( $this->extension == "gif" ) $source = imagecreatefromgif($this->destination_file);
                   
           imagecopyresampled($destination, $source, 0, 0, 0, 0, $largeur, $hauteur, $size[0], $size[1]);
           if ( $this->extension == "jpg" || $this->extension == "jpeg" ) imagejpeg($destination, $this->destination_file);
           elseif ( $this->extension == "png" ) imagepng($destination, $this->destination_file);
           elseif ( $this->extension == "gif" ) imagegif($destination, $this->destination_file);
           }
        }
        } 
Search

Code: Select all

    if (sizeof($this->error))
             {
                return false;
             }

             phpbb_chmod($this->destination_file, $chmod);
insert before it

Code: Select all

    if ( $this->is_image() )
                {
                    $this->resize_images();
                }
With this change, in the forum highly loaded pictures are reduced server-laterally to the quantity 800x600 (no matter, they were as large before).

If one would like other sizes, then one must change the following in the function:
Look in the file for the

Code: Select all

    $limite_largeur = "800px";
    $limite_hauteur = "600px";
In place of 800px and 600px put in what ever size you want the pictures resized to.

Locked

Return to “[3.0.x] Support Forum”