This is based on the assumption that all the code in the OP message was right, and simply reinstalled it as requested.
Update : four upvotes (for now) indicate that the OP was correct not only in terms of code, but also in relation to the extent of the problem. Of course, I do OSS, so of course, let me know if this interests you, so we can improve it on github (any action is ok - raise a question, raise an answer, post a comment or any combination of them).
function resize($imgName, $srcName) { $image = new Imagick($imgName); $imageprops = $image->getImageGeometry(); $w=$imageprops['width']; $h=$imageprops['height']; $edge = min($w,$h); $ratio = $edge / 640; $tWidth = ceil($w / $ratio); $tHeight = ceil($h / $ratio); if ($imageprops['width'] <= 640 && $imageprops['height'] <= 640) { return $imgName; } else { $image->resizeImage($tWidth,$tHeight,imagick::FILTER_LANCZOS, 0.9, true); } $extension=end(explode(".", $srcName)); // Change "/tmp" if you're running this on Windows $tmpName=tempnam("/tmp", "resizer_").".".$extension; $image->writeImage($tmpName); return $tmpName } global $s3; if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { return ""; } $upload = isset($_FILES['files']) ? $_FILES['files'] : null; $info = array(); if ($upload && is_array($upload['tmp_name'])) { foreach($upload['tmp_name'] as $index => $value) { $file_name = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index]); $fileTempName = resize($upload['tmp_name'][$index], $file_name); $extension=end(explode(".", $file_name)); $rand = rand(1,100000000); $sha1 = sha1($rand); $md5 = md5($sha1); $filename = substr($md5, 0, 8); $fileName=$filename.".".$extension; $fileName = $prefix.str_replace(" ", "_", $fileName); $response = $s3->create_object($bucket, $fileName, array('fileUpload' => $fileTempName, 'acl' => AmazonS3::ACL_PUBLIC, 'meta' => array('keywords' => 'example, test'),)); if ($response->isOK()) { $info[] = getFileInfo($bucket, $fileName); } else { // `echo "<strong>Something went wrong while uploading your file... sorry.</strong>";` } unlink($fileTempName); }
Gutza source share