title: php convert images and upload to amazon s3
body: <p>I am looking for a best practice while uploading images to amazon s3 server and serving from there.</p>
  
  <p>We need four different sizes of an image. So just after image upload we convert the image and scale in 4 different widths and heights. And then we send them to the amazon s3 using official php api. </p>
  
  <pre><code>// ...
  // image conversions, bucket setting, s3 initialization etc.
  
  $sizes= array("", "48", "64", "128");
  
  foreach($sizes as $size) {
      $filename = $upload_path.$dest_file.$size.$ext;
      $s3-&gt;batch()-&gt;create_object($bucket, , array(
                  'fileUpload' =&gt; $filename,
                  'acl' =&gt; AmazonS3::ACL_PUBLIC,
              ));
  } 
  </code></pre>
  
  <p>But for a 1M image the client sometimes wait up to 30 seconds which is a very long time. </p>
  
  <p>Instead of sending images immediately to S3, it may be better to add them to a job queue. But the user should see the uploaded image immediately.</p>