Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Resample images

edited February 2011 in Vanilla 2.0 - 2.8
I know this is general purpose allowing uploading many file types, but for images it would be great if FileUpload could have a setting to re-sample images to conform to a configured maximum X & Y dimensions while maintaining aspect ratio.


  • Yes, it would be great !
  • Yes, i think so too. It would also nice to have a lightbox to view the images.
  • moensmoens New
    edited March 2011
    Tim has said that in the next version of FileUpload, this feature will be added... but here is a very naive way to make this work in the mean time (if you have GD php module):

    Using FileUpload 1.4.0, in the class.fileupload.plugin.php after the PostController_Upload_Create function checks for $maxUploadSize on lines 597 - 601, add the following to resize the temp file before it is moved:

    // Added to auto re-size images over 650px x 650px $FileParams = getimagesize($FileTemp); if ( ($FileParams[0] > 650) || ($FileParams[1] > 650) ) { include_once('/EDIT/THIS/PATH/TO/SimpleImage.php'); $resizedImage = new SimpleImage(); $resizedImage->load($FileTemp); if ($FileParams[0] >= $FileParams[1]) { $resizedImage->resizeToWidth(650); } else { $resizedImage->resizeToHeight(650); } $resizedImage->save($FileTemp); $FileSize = filesize($FileTemp); } //end add
    ...then save this image resize class* somewhere (I put it in the same dir as the class.fileupload.plugin.php in the FileUpload plugin).

    In this case, it checks for images larger than 650px x 650px and resizes them... you could, obviously, be more creative, but I had very simple requirements.

    *Props to Simon Jarvis for his gift of a neat and simple php image resize class.
Sign In or Register to comment.