title: Use imagick with S3 AWS
body: <p>These are my first steps with AWS S3, so and my goal is to use <code>imagick</code> for manipulating the image before I upload to S3 AWS.</p>
  
  <p>I use this function for resize and scale the image (works perfect on output browser):</p>
  
  <pre><code>function resizeImg($img, $width, $height) {
  
      $i = new Imagick($img);
  
      $gig = $i-&gt;getImageGeometry();
  
      // crop the image
      if(($gig['width']/$width) &lt; ($gig['height']/$height)) {
  
          $i-&gt;cropImage($gig['width'], floor($height * $gig['width'] / $width), 0, (($gig['height'] - ($height * $gig['width'] / $width)) / 2));
  
      } else {
  
          $i-&gt;cropImage(ceil($width * $gig['height'] / $height), $gig['height'], (($gig['width'] - ($width * $gig['height'] / $height)) / 2), 0);
      }
  
      $i-&gt;ThumbnailImage($width, $height, true);
  
      $i-&gt;setImageFormat("jpeg");
      $i-&gt;setImageCompressionQuality(90);
  
      $i-&gt;getimageblob(); // I tried it with and without getimageblob
  
      return $i;
  }
  </code></pre>
  
  <p>Thats my attempt, Upload to S3:</p>
  
  <pre><code>$tmpImg = $_FILES['inputImage']['tmp_name'];
  
  $newImgFile = resizeImg($tmpImg, 100, 100); 
  
  $s3-&gt;putObjectFile($newImgFile, BUCKET_NAME, $newfilename, S3::ACL_PUBLIC_READ);
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>Warning: S3::inputFile(): Unable to open input file: ���� in.....</p>
  </blockquote>
  
  <p>What I`m doing wrong? </p>
  
  <p>Is imagick not compatible with S3 AWS?</p>
  
  <p>Or is there a better way? </p>
  
  <p>And my next goal is to put different image resizes to S3, e.g 100x100, 300x300.... from same input file, but of course I have to solve before the first goal.</p>
  
  <p><strong>EXTRA:</strong></p>
  
  <p>With this  solution from here:
  <a href="https://stackoverflow.com/questions/11286222/php-imagick-write-image-directly-to-amazon-s3">PHP Imagick: Write Image directly to Amazon S3?</a></p>
  
  <p>I get this Error:</p>
  
  <blockquote>
    <p>Warning: S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method.</p>
  </blockquote>
  
  <p>If I do this: <code>$new = urlencode($new);</code> or <code>$new = strtolower($new);</code>  ...Works to upload but no readable! </p>
  
  <p>The error came from extra spaces or slashes in there, so far as I have understood</p>
  
  <p>And if its important,  here the Url from the image in S3</p>
  
  <blockquote>
    <p>https->awsCount.xxxx.xxxxx/img.jpg?AWSAccessKeyId=xxxx&amp;Expires=1383787878&amp;Signature=xxxx&amp;x-amz-security-token=AQoDYXdzEGAasAJlJXrt/7FPf84wE9stfgBfEoWaPMDHlubQBlQ6oMY6sNMT4cizkEm9khypHulLB/zJ%2BbqqAErvFBKKs2I9bKDBzrKYKhgRn%2Bta057CZaLougsxHLRGquhd5H26br/Odkq98%2BoDTnfK0LHFa9vYbX6sXDIzCSHcZx4%2B5o0y3cKlxCMsYLqw6wYD1DNjJ%2BHlWWuh%2B6V0FtpbYaErB1XUZfRRZdx3ZPEOvyZxQS7uzP8C3B1nK0wo3uqqSAhn9PPtQt5jrRutYRao2KugxK8TbkZbr/v5NOYSbpc%2BmI2iYYrUjylqgenzf85Avss0CA1GfOzg%2BMs2/TQ7evH7epr09B8Vyd89Gk1XQpVMyrTSvbzDYE8UCcgrUrXgdHTYWdGLVZ%2BBHzft9nHtNhggePD6AXMuIP%2Ba6ZMF</p>
  </blockquote>