This discussion is related to the
FileUpload addon.
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.
1 • •
Comments
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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.
- Spam
- Abuse
- Troll
1 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •