Skip to content

Commit

Permalink
Merge branch 'release/1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
hueyl77 committed May 16, 2017
2 parents 9f3fdba + 1527c57 commit 2fc43de
Show file tree
Hide file tree
Showing 37 changed files with 3,804 additions and 457 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Filestack-php Changelog

## 1.0.4 (May 16, 2017)
- FS-398 added zip() and compress() functionalities
- FS-406 added screenshot() functionality
- FS-408 added collage() funcionality
- FS-94 added debug() call
- FS-409 added convertFile() functionality
- FS-410 added Audio and Video conversions

## 1.0.3 (May 8, 2017)
- FS-89 Integrated tests with TravisCI
- FS-90 Implemented Security
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ If you have problems, please create a [Github Issue](https://github.com/filestac

## Contributing

Please see [CONTRIBUTING.md](https://github.com/filestack/filestack-php/blob/master/CONTRIBUTING.md) for details.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

## Credits

Thank you to all the [contributors](https://github.com/filestack/filestack-php/graphs/contributors).

Thank you to all the [contributors](https://github.com/filepicker/filestack-php/graphs/contributors).

## Other Resources

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.0.4
29 changes: 2 additions & 27 deletions examples/client-no-security.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
$client = new FilestackClient($test_api_key);

// upload a file
$filelink = null;
$options = ['Filename' => 'somefilename.jpg'];

try {
$filelink = $client->upload($test_filepath, $options);
var_dump($filelink);
Expand Down Expand Up @@ -42,31 +44,4 @@
$result = $client->download($filelink->url(), $destination);
var_dump($result);

// transform an image from url
$url = "https://cdn.filestackcontent.com/vA9vFnjRVGmEbNPy3beQ";
$transform_tasks = [
'crop' => ['dim' => '[10,20,200,250]'],
'resize' => ['w' => '100', 'h' => '100'],
'rotate' => ['b' => '00FF00', 'd' => '45'],
];

$content = $client->transform($url, $transform_tasks);

// save file to local drive
$filepath = __DIR__ . '/../tests/testfiles/transformed_file.jpg';
file_put_contents($filepath, $content);

// transform an image from url with store()
$url = "https://cdn.filestackcontent.com/vA9vFnjRVGmEbNPy3beQ";
$transform_tasks = [
'resize' => ['width' => '100', 'height' => '100'],
'rotate' => ['background' => 'red', 'deg' => '45'],
'store' => []
];

$result = $client->transform($url, $transform_tasks);
$json = json_decode($result);

var_dump($json);

/* overwrite() and delete() require security settings turned on */
52 changes: 52 additions & 0 deletions examples/client-transformations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
use Filestack\FilestackClient;
use Filestack\FilestackSecurity;
use Filestack\Filelink;
use Filestack\FilestackException;

$test_api_key = 'A5lEN6zU8SemSBWiwcGJhz';
$test_secret = '3UAQ64UWMNCCRF36CY2NSRSPSU';
$test_filepath = __DIR__ . '/../tests/testfiles/calvinandhobbes.jpg';

# Filestack client examples
$security = new FilestackSecurity($test_secret);
$client = new FilestackClient($test_api_key, $security);

// transformations
$transformed_file = $client->transform($filelink->handle, $transform_tasks);
# or
$transformed_file = $client->transform($url, $transform_tasks);

$destination = __DIR__ . '/../tests/testfiles/my-transformed-file.png';

$contents = $transformed_file->getContent();
file_put_contents($destination, $contents);
# or
$result = $transformed_file->download($destination);

// zipping files
$sources = [
'https://d1wtqaffaaj63z.cloudfront.net/images/20150617_143146.jpg',
$filelink->handle
];

$zipped_filelink = $client->zip($sources);
$destination = __DIR__ . '/../tests/testfiles/contents-zipped.zip';

$result = $zipped_filelink->download($destination);
# or
$contents = $zipped_filelink->getContent();
file_put_contents($destination, $contents);

// debugging transformation calls
$transform_tasks = [
'resize' => ['w' => '100', 'h' => '100'],
'detect_faces' => []
];

/**
* calling debug() will return a json item detailing
* any errors the tasks may return
*/
$json_response = $client->debug($this->test_file_handle, $transform_tasks);
print_r($json_response);
33 changes: 2 additions & 31 deletions examples/client-with-security.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
$client = new FilestackClient($test_api_key, $security);

// upload a file
$filelink = null;
$options = ['Filename' => 'somefilename.jpg'];

try {
$filelink = $client->upload($test_filepath, $options);
var_dump($filelink);
Expand Down Expand Up @@ -42,34 +44,3 @@
// overwrite a file
$filelink2 = $client->overwrite($test_filepath, $filelink->handle);
var_dump($filelink2);

// transform an image from url
$url = "https://cdn.filestackcontent.com/vA9vFnjRVGmEbNPy3beQ";
$transform_tasks = [
'crop' => ['dim' => '[10,20,200,250]'],
'resize' => ['w' => '100', 'h' => '100'],
'rotate' => ['b' => '00FF00', 'd' => '45'],
];

$content = $client->transform($url, $transform_tasks);

// save file to local drive
$filepath = __DIR__ . '/../tests/testfiles/transformed_file.jpg';
file_put_contents($filepath, $content);

// transform an image from url with store()
$url = "https://cdn.filestackcontent.com/vA9vFnjRVGmEbNPy3beQ";
$transform_tasks = [
'resize' => ['width' => '100', 'height' => '100'],
'rotate' => ['background' => 'red', 'deg' => '45'],
'store' => []
];

$result = $client->transform($url, $transform_tasks);
$json = json_decode($result);

var_dump($json);

// delete a file
$result = $client->delete($filelink->handle);
var_dump($result);
53 changes: 53 additions & 0 deletions examples/converting-file-formats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
use Filestack\FilestackClient;
use Filestack\FilestackSecurity;
use Filestack\Filelink;
use Filestack\FilestackException;

$test_api_key = 'A5lEN6zU8SemSBWiwcGJhz';
$test_secret = '3UAQ64UWMNCCRF36CY2NSRSPSU';
$test_filepath = __DIR__ . '/../tests/testfiles/calvinandhobbes.jpg';

/**
* You can create convert a filelink or url from one format to another,
* to see the list of formats, go to :
* https://www.filestack.com/docs/image-transformations/conversion
*/

$security = new FilestackSecurity($test_secret);
$client = new FilestackClient($test_api_key, $security);

$output_options = [
'background' => 'white',
'density' => 50,
'compress' => true,
'colorspace' => 'input',
'quality' => 80,
'strip' => true,
'pageformat' => 'letter',
'pageorientation' => 'landscape'
];

$filelink = $client->convertFile($source, 'pdf', $output_options);
$destination = __DIR__ . '/../tests/testfiles/convert-file-test.pdf';

$result = $filelink->download($destination);
# or
$contents = $filelink->getContent();
file_put_contents($destination, $contents);

/**
* Or you can convert using a filelink object
*/

$filelink = $client->upload($test_filepath);
$converted_filelink = $filelink->convertFile($source, 'pdf', $output_options);

$destination = __DIR__ . '/../tests/testfiles/convert-filelink-test.pdf';
$result = $converted_filelink->download($destination);
# or
$contents = $converted_filelink->getContent();
file_put_contents($destination, $contents);

// delete remote file
$filelink->delete();
46 changes: 46 additions & 0 deletions examples/create-collages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
use Filestack\FilestackClient;
use Filestack\FilestackSecurity;
use Filestack\Filelink;
use Filestack\FilestackException;

$test_api_key = 'A5lEN6zU8SemSBWiwcGJhz';
$test_secret = '3UAQ64UWMNCCRF36CY2NSRSPSU';
$test_filepath = __DIR__ . '/../tests/testfiles/calvinandhobbes.jpg';

$sources = [
'9K1BZLt6SAyztVaOtAQ4',
'FWOrzDcpREanJDI3hdR5',
'Vi6RUEi6TgCSo9FXYVxP',
'https://d1wtqaffaaj63z.cloudfront.net/images/E-0510.JPG'
];

/**
* You can create a collage using the client
*/

$security = new FilestackSecurity($test_secret);
$client = new FilestackClient($test_api_key, $security);

$collage_filelink = $client->collage($sources, 800, 600);
$destination = __DIR__ . '/../tests/testfiles/collage-test.png';

$result = $collage_filelink->download($destination);
# or
$contents = $collage_filelink->getContent();
file_put_contents($destination, $contents);

/**
* Or you can create a collage using a filelink
*/

$filelink = $client->upload($test_filepath);
$collage_filelink = $filelink->collage($sources, 800, 600)->save();

$result = $collage_filelink->download($destination);
# or
$contents = $collage_filelink->getContent();
file_put_contents($destination, $contents);

// delete remote file
$filelink->delete();
24 changes: 24 additions & 0 deletions examples/create-screenshots.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
use Filestack\FilestackClient;
use Filestack\FilestackSecurity;
use Filestack\Filelink;
use Filestack\FilestackException;

$test_api_key = 'A5lEN6zU8SemSBWiwcGJhz';
$test_secret = '3UAQ64UWMNCCRF36CY2NSRSPSU';

$security = new FilestackSecurity($test_secret);
$client = new FilestackClient($test_api_key, $security);

// take a screenshot of a url
$url = 'https://en.wikipedia.org/wiki/Main_Page';
$screenshot_filelink = $client->screenshot($url);
$destination = __DIR__ . '/../tests/testfiles/screenshot-test.png';

$result = $screenshot_filelink->download($destination);
# or get contents then save
$contents = $screenshot_filelink->getContent();
file_put_contents($destination, $contents);

// delete remote file
$screenshot_filelink->delete();
39 changes: 0 additions & 39 deletions examples/filelink-no-security.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,3 @@
$filelink->download($test_filepath);

// delete() and overwrite() methods require security

// transformations
$transform_tasks = [
'crop' => ['dim' => '[10,20,200,250]'],
'resize' => ['w' => '100', 'h' => '100'],
'rotate' => ['b' => '00FF00', 'd' => '45']
];

$transformed_content = $filelink->transform($transform_tasks);

// save file to local drive
$filepath = __DIR__ . '/../tests/testfiles/transformed_file.jpg';
file_put_contents($filepath, $transformed_content);

// transformation save to destination
$success = $filelink->transform($transform_tasks, $filepath);

// chaining transformations
$crop_options = ['dim' => '[10,20,200,250]'];
$rotate_options = ['b' => 'red', 'd' => '45'];

$contents = $filelink->crop($crop_options)
->rotate($rotate_options)
->downloadTransformed($filepath);

/*
* must call resetTransform() to clear previous transformation calls if
* you're using the same filelink instance that has been transformed before
*/
$filelink->resetTransform();

// transform then store to cloud
$transformed_filelink = $filelink
->circle()
->blur(['amount' => '20'])
->store();

var_dump($transformed_filelink);
echo "\nnew transformed file cdn url is: " . $transformed_filelink->url();

0 comments on commit 2fc43de

Please sign in to comment.