title: How can I resize file from s3 to public path and convert as compressed tiff? (Laravel)
body: <p>I can download it in public path and convert it to tiff I just want to ask how to resize it and compress it to 60-70kb mostly uploaded pictures from s3 is 200-400kb.</p>
  <p>Thank you in advance!</p>
  <pre><code>     
  
          $posted_folder = $_POST['folder_name'];
          $base = basename($posted_folder);
          $fetch_files = Storage::disk('s3')-&gt;allfiles($posted_folder);
          
          
          foreach($fetch_files as $encoded){
              if (!file_exists(public_path($base))) {
                  mkdir(public_path($base));
              }
              
              $link = &quot;https://&quot;.env('AWS_BUCKET').&quot;.s3.&quot;.env('AWS_DEFAULT_REGION').&quot;.amazonaws.com/&quot;.$encoded;
              $link = str_replace(' ', '%20', $link);
  
              if (@getimagesize($link) != false) {
  
  
                  $destinationPath = public_path($base.'/');
                  // $jpgname = basename($link);
  
                  $new_name = pathinfo($encoded, PATHINFO_FILENAME).&quot;.tif&quot;;
                  
                  
                  $tempFilePath = $destinationPath.$new_name ;
                  $tempFile = fopen($tempFilePath, &quot;w&quot;) or die(&quot;Error: Unable to open file.&quot;);
  
                  $fileContents = file_get_contents($link);
                  
                  $tempFile = file_put_contents($tempFilePath, $fileContents);
              }
          }
          
          
      }```
  </code></pre>