Last active
August 29, 2015 14:18
-
-
Save jdecool/5d58a252b59e69ecd90d to your computer and use it in GitHub Desktop.
ImageWorkshop issue #71 sample code
This file contains 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 characters
{ | |
"require": { | |
"sybio/image-workshop": "~2.0", | |
"codeguy/upload": "~1.3" | |
} | |
} |
This file contains 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 characters
<?php | |
require __DIR__.'/../vendor/autoload.php'; | |
use Upload\File; | |
use Upload\Storage\FileSystem; | |
use PHPImageWorkshop\ImageWorkshop; | |
if (!empty($_FILES)) { | |
$storeFolder = '.'; | |
$storage = new FileSystem($storeFolder); | |
$file = new File('userfile', $storage); | |
$new_filename = uniqid(); | |
$file->setName($new_filename); | |
$data = array( | |
'name' => $file->getNameWithExtension() | |
); | |
$witdh = 400; //$this->app->request->post("width"); | |
// NOT USED IN SAMPLE | $top = $this->app->request->post("top"); | |
// NOT USED IN SAMPLE | $left = $this->app->request->post("left"); | |
$file->upload(); | |
$path = $storeFolder . DIRECTORY_SEPARATOR . $data["name"]; | |
$layer = ImageWorkshop::initFromPath($path); | |
$layer->resizeInPixel($witdh, null, true); | |
$layer->save($storeFolder, $data["name"], true, null, 90, false); | |
} | |
?> | |
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> | |
File : <input name="userfile" type="file" /> | |
<input type="submit" value="Submit" /> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment