Created
July 12, 2019 02:48
-
-
Save cybersholt/b5f35e99b4012eee074db99b72b4bde5 to your computer and use it in GitHub Desktop.
Revisions
-
cybersholt created this gist
Jul 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ <?php function s3Ranger($key) { // inspired by https://stackoverflow.com/a/4635991/2320760 $s3 = new S3Client( array( 'version' => 'latest', 'region' => 'us-east-1', 'credentials' => [ 'key' => $key, 'secret' => $secret ] ) ); $s3->registerStreamWrapper(); $result = $s3->headObject( array( 'Bucket' => $bucket, 'Key' => $key, 'Range' => "0-65536" ) ); if (!($data = file_get_contents("s3://{$bucket}/{$key}"))) { throw new \Exception('Could not read file: [' . $key . ']'); } $im = imagecreatefromstring($data); $width = imagesx($im); $height = imagesy($im); return [$width, $height]; }