<?php $floatAngle = 90.0; $objImage = new class_image2(); $objImage->setUseCache(false); if (!$objImage->load("/files/images/samples/P9066809.JPG")) { echo "Could not load file.\n"; } $objImage->addOperation(new class_image_rotate($floatAngle, "#ffffffff")); $objImage->addOperation(new class_image_scale_and_crop(800, 1350)); if (!$objImage->save("/files/cache/P9066809_transformed.PNG", class_image2::FORMAT_PNG)) { echo "File not saved.\n"; }
/** * Tries to save the passed cropping. * The following params are needed: * action = saveCropping * folder = the files' location * file = the file to crop * systemid = the repo-id * intX * intY * intWidth * intHeight * @return string * @permissions edit */ protected function actionSaveCropping() { $strReturn = ""; $strFile = $this->getParam("file"); $objImage = new class_image2(); $objImage->setUseCache(false); $objImage->load($strFile); $objImage->addOperation(new class_image_crop($this->getParam("intX"), $this->getParam("intY"), $this->getParam("intWidth"), $this->getParam("intHeight"))); if ($objImage->save($strFile)) { class_logger::getInstance()->addLogRow("cropped file " . $strFile, class_logger::$levelInfo); $strReturn .= "<message>" . xmlSafeString($this->getLang("xml_cropping_success")) . "</message>"; } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * @param $strPath * @return void */ private function recursiveImageProcessing($strPath) { $objFilesystem = new class_filesystem(); $arrFilesFolders = $objFilesystem->getCompleteList($strPath, array(".jpg", ".jpeg", ".png", ".gif"), array(), array(".", "..", ".svn")); $this->intFilesTotal += $arrFilesFolders["nrFiles"]; foreach ($arrFilesFolders["folders"] as $strOneFolder) { $this->recursiveImageProcessing($strPath . "/" . $strOneFolder); } foreach ($arrFilesFolders["files"] as $arrOneFile) { $strImagePath = $strPath . "/" . $arrOneFile["filename"]; $objImage = new class_image2(); $objImage->setUseCache(false); $objImage->load($strImagePath); $objImage->addOperation(new class_image_scale($this->intMaxWidth, $this->intMaxHeight)); if ($objImage->save($strImagePath)) { $this->intFilesProcessed++; } } }