private function create_thumb($key, $size) { $thumb_key = self::IMAGE_CACHE_FOLDER . $this->option_thumbnail["width"] . "x" . $this->option_thumbnail["height"] . "-" . $this->option_thumbnail["resize"] . "/" . $key; if (!$this->s3_client->doesObjectExist($this->bucket, $thumb_key)) { $temp_original_image = self::create_unique_temp_filename($key); $temp_converted_image = self::create_unique_temp_filename($key); // echo "Creating ... "; $download = $this->s3_client->getObject(array("Bucket" => $this->bucket, "Key" => $key, "SaveAs" => $temp_original_image)); // echo "Size is " . $this->option_thumbnail["width"]; $this->total_converted_size += $size; $resizeObj = new resize($temp_original_image); if ($resizeObj->validImage()) { $resizeObj->resizeImage($this->option_thumbnail["width"], $this->option_thumbnail["height"], $this->option_thumbnail["resize"]); $resizeObj->saveImage($temp_converted_image, 100); $upload = $this->s3_client->putObject(array("Bucket" => $this->bucket, "Key" => $thumb_key, "SourceFile" => $temp_converted_image, "ContentType" => $download["ContentType"], "ACL" => "public-read", "StorageClass" => "REDUCED_REDUNDANCY")); unlink($temp_converted_image); } else { $thumb_key = $key; //TODO } unlink($temp_original_image); } return $thumb_key; }