53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
require_once "./myDropBoxObj.php";
|
|
use PHPImageWorkshop\ImageWorkshop;
|
|
require_once('./PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class
|
|
|
|
date_default_timezone_set("Europe/Rome");
|
|
|
|
$dirRicetteDropBox = "IlLievitario/Images/Ricette";
|
|
|
|
$tmpFileName = "C:/Users/Denis/Desktop/Chiaravalle/Jpg/DSC_7731.jpg";
|
|
$ext = pathinfo($tmpFileName, PATHINFO_EXTENSION);
|
|
|
|
$idRicette = 5;
|
|
|
|
$newID = 125;
|
|
|
|
$imageFileName = $newID . "_full_ricetta." . $ext;
|
|
|
|
$thumbFileName = $newID . "_thumb_ricetta." . $ext;
|
|
|
|
$dropBoxObj = new myDropBox();
|
|
|
|
$folder = $dirRicetteDropBox . "/" . $idRicette;
|
|
/*
|
|
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
|
|
|
return;
|
|
*/
|
|
$layer = ImageWorkshop::initFromPath($tmpFileName);
|
|
|
|
echo $layer->getImage()->image_type;
|
|
return;
|
|
|
|
$layer->resizeByLargestSideInPixel(640, true);
|
|
|
|
$layer->save(dirname($tmpFileName), $imageFileName);
|
|
|
|
$imgData = addslashes(file_get_contents($tmpFileName));
|
|
|
|
$layer->resizeByLargestSideInPixel(300, true);
|
|
|
|
$layer->save(dirname($tmpFileName), $thumbFileName);
|
|
|
|
try {
|
|
$dropBoxObj->CreateFolder($folder);
|
|
} catch (DropboxException $ex) {
|
|
|
|
}
|
|
|
|
$dropBoxObj->UploadFile(dirname($tmpFileName) . "/" . $imageFileName, $folder . "/" . $imageFileName);
|
|
|
|
$dropBoxObj->UploadFile(dirname($tmpFileName) . "/" . $thumbFileName, $folder . "/" . $thumbFileName); |