Пример #1
0
function resizeAll($imgUrls, $agency_localDir, &$resizedUrls)
{
    /*
     * function takes an array of img urls, resize, save in the same dir and
     * load the resized urls into the second parameter
     * ----------
     * hardcode directories of json files
     * get json data from m.json
     * load the data into a new object
     * foreach image in imgUrls
     * - create a resizeObject
     * - get width/ height from json object (retrieved earlier)
     * - call resizeObject->resizeImage (args);
     * - notice difference between main and other in m.json
     */
    $jsonObject = get_json_object($agency_localDir);
    // $resizedDir = "{$_SERVER['DOCUMENT_ROOT']}/myApp/api/assets/testResize/";
    $resizedDir = "{$_SERVER['DOCUMENT_ROOT']}/api/assets/testResize/";
    // resize main
    resizeSingleMain($imgUrls[0], $jsonObject, $resizedDir, $resizedUrls[0]);
    // resize others
    $no_imgs = count($imgUrls);
    for ($i = 1; $i < $no_imgs; $i++) {
        resizeSingleOther($imgUrls[$i], $jsonObject, $resizedDir, $i, $resizedUrls[$i]);
    }
    // print_arr ($imgUrls);
    // print_arr ($resizedUrls);
}
Пример #2
0
function createAd($propertyInfo, $imgs, &$finalised)
{
    // download imgs
    $dir = "{$_SERVER['DOCUMENT_ROOT']}/api/assets/testDownload/";
    $imgUrls = array();
    downloadAll($imgs, $dir, $imgUrls);
    // print_arr ($imgUrls);
    // resize them
    $resizedUrls = array();
    resizeAll($imgs, $propertyInfo['agency_localDir'], $resizedUrls);
    // print_arr ($resizedUrls);
    $templateDir = array();
    $templateDirWeb = array();
    makeTemplateDir($propertyInfo, $templateDir, $templateDirWeb);
    // put templates into imgs
    $jsonObject = get_json_object($propertyInfo['agency_localDir']);
    $dest = "{$_SERVER['DOCUMENT_ROOT']}/api/assets/testFinal/";
    $finalised[0] = "/api/assets/testFinal/" . "0.jpg";
    $finalised[1] = "/api/assets/testFinal/" . "00.jpg";
    finaliseMainAdItem($propertyInfo, $jsonObject, $dest, $resizedUrls[0]);
    allocateLogo($resizedUrls, $jsonObject, $dest, $templateDir, $finalised);
    print_arr($finalised);
    foreach ($finalised as $oup) {
        echo "<img src='" . $oup . "' />" . "<br />" . "<br />";
    }
}