Resizing existing uploaded image attachments

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
Registered User
Posts: 103
Joined: Thu Oct 18, 2007 9:33 am

Resizing existing uploaded image attachments

Post by digitaltoast »

We've got posts and files going back 8 years and the attachment folder is now 2.5Gb with a lot of HUGE images.

Although the files have no extension, Linux's "file" command gives this info:

Code: Select all

9897_45200056c4ea07275bf57e07323eda39: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=17, height=3456, bps=218, PhotometricIntepretation=RGB, manufacturer=Panasonic, model=DMC-TZ55, orientation=upper-left, width=4608], progressive, precision 8, 4608x3456, frames 3
So my idea was to test all files in the attachments dir, and where type was jpeg AND width was > 1280 AND filesize was > 250k, then process it with the best and latest jpeg compression, keeping the EXIF data.

That's the easy(ish) part, but I notice that the attachments DB has columns for filesize and filetime.

I can probably get round the filetime bit by getting the filetime first, storing in a var, and the "touching" the file with the old date after modification. But what about that filesize column? Is this going to mess things up?


User avatar
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs

Re: Resizing existing uploaded image attachments

Post by canonknipser »

I posted a article a while ago Knowledge Base - Backing up attachments with their original filenames. Another script I posted was to resize attachment thumbnails:
Maybe you can use those scripts as a sample for your needs, eg. discover jpeg images by mime-type from DB and run the resize from inside a script.

I won't bother about the filetime and filesize matching between database and filesystem because the database entry is only for display and not checked against the file (no need to read those informations from filesystem every time a attachment is displayed)
Greetings, Frank support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

Post Reply

Return to “[3.2.x] Support Forum”