本文整理汇总了PHP中BigTree::createCrop方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::createCrop方法的具体用法?PHP BigTree::createCrop怎么用?PHP BigTree::createCrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::createCrop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processCrops
static function processCrops($crop_key)
{
$storage = new BigTreeStorage();
// Get and remove the crop data
$crops = BigTreeCMS::cacheGet("org.bigtreecms.crops", $crop_key);
BigTreeCMS::cacheDelete("org.bigtreecms.crops", $crop_key);
foreach ($crops as $key => $crop) {
$image_src = $crop["image"];
$target_width = $crop["width"];
$target_height = $crop["height"];
$x = $_POST["x"][$key];
$y = $_POST["y"][$key];
$width = $_POST["width"][$key];
$height = $_POST["height"][$key];
$thumbs = $crop["thumbs"];
$center_crops = $crop["center_crops"];
$pinfo = pathinfo($image_src);
// Create the crop and put it in a temporary location
$temp_crop = SITE_ROOT . "files/" . uniqid("temp-") . "." . $pinfo["extension"];
BigTree::createCrop($image_src, $temp_crop, $x, $y, $target_width, $target_height, $width, $height, $crop["retina"], $crop["grayscale"]);
// Make thumbnails for the crop
if (is_array($thumbs)) {
foreach ($thumbs as $thumb) {
if (is_array($thumb) && ($thumb["height"] || $thumb["width"])) {
// We're going to figure out what size the thumbs will be so we can re-crop the original image so we don't lose image quality.
list($type, $w, $h, $result_width, $result_height) = BigTree::getThumbnailSizes($temp_crop, $thumb["width"], $thumb["height"]);
$temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . "." . $pinfo["extension"];
BigTree::createCrop($image_src, $temp_thumb, $x, $y, $result_width, $result_height, $width, $height, $crop["retina"], $thumb["grayscale"]);
$storage->replace($temp_thumb, $thumb["prefix"] . $crop["name"], $crop["directory"]);
}
}
}
// Make center crops of the crop
if (is_array($center_crops)) {
foreach ($center_crops as $center_crop) {
if (is_array($center_crop) && $center_crop["height"] && $center_crop["width"]) {
$temp_center_crop = SITE_ROOT . "files/" . uniqid("temp-") . "." . $pinfo["extension"];
BigTree::centerCrop($temp_crop, $temp_center_crop, $center_crop["width"], $center_crop["height"], $crop["retina"], $center_crop["grayscale"]);
$storage->replace($temp_center_crop, $center_crop["prefix"] . $crop["name"], $crop["directory"]);
}
}
}
// Move crop into its resting place
$storage->replace($temp_crop, $crop["prefix"] . $crop["name"], $crop["directory"]);
}
// Remove all the temporary images
foreach ($crops as $crop) {
@unlink($crop["image"]);
}
}
示例2: processCrops
function processCrops($crops)
{
$storage = new BigTreeStorage();
foreach ($crops as $key => $crop) {
$image_src = $crop["image"];
$target_width = $crop["width"];
$target_height = $crop["height"];
$prefix = $crop["prefix"];
$x = $_POST["x"][$key];
$y = $_POST["y"][$key];
$width = $_POST["width"][$key];
$height = $_POST["height"][$key];
$thumbs = $crop["thumbs"];
$pinfo = pathinfo($image_src);
$temp_crop = SITE_ROOT . "files/" . uniqid("temp-") . "." . $pinfo["extension"];
BigTree::createCrop($image_src, $temp_crop, $x, $y, $target_width, $target_height, $width, $height, $crop["retina"], $crop["grayscale"]);
if (is_array($thumbs)) {
foreach ($thumbs as $thumb) {
if (is_array($thumb) && ($thumb["height"] || $thumb["width"])) {
// We're going to figure out what size the thumbs will be so we can re-crop the original image so we don't lose image quality.
list($type, $w, $h, $result_width, $result_height) = BigTree::getThumbnailSizes($temp_crop, $thumb["width"], $thumb["height"]);
$temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . "." . $pinfo["extension"];
BigTree::createCrop($image_src, $temp_thumb, $x, $y, $result_width, $result_height, $width, $height, $crop["retina"], $thumb["grayscale"]);
$storage->replace($temp_thumb, $thumb["prefix"] . $crop["name"], $crop["directory"]);
}
}
}
$storage->replace($temp_crop, $crop["prefix"] . $crop["name"], $crop["directory"]);
}
// Remove all the temporary images
foreach ($crops as $crop) {
@unlink($crop["image"]);
}
}