当前位置: 首页>>代码示例>>PHP>>正文


PHP BigTree::createThumbnail方法代码示例

本文整理汇总了PHP中BigTree::createThumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::createThumbnail方法的具体用法?PHP BigTree::createThumbnail怎么用?PHP BigTree::createThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigTree的用法示例。


在下文中一共展示了BigTree::createThumbnail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unlink

         $sizes = BigTree::getThumbnailSizes($first_copy, $thumb["width"], $thumb["height"]);
         if (!BigTree::imageManipulationMemoryAvailable($first_copy, $sizes[3], $sizes[4], $iwidth, $iheight)) {
             $error = "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.";
             unlink($first_copy);
         }
     }
 }
 if (!$error) {
     // Now let's make the thumbnails we need for the image manager
     $thumbs = array();
     $pinfo = BigTree::pathInfo($file_name);
     // Create a bunch of thumbnails
     foreach ($thumbnails_to_create as $key => $thumb) {
         if ($iwidth > $thumb["width"] || $iheight > $thumb["height"]) {
             $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
             BigTree::createThumbnail($first_copy, $temp_thumb, $thumb["width"], $thumb["height"]);
             if ($key == "bigtree_internal_list") {
                 list($twidth, $theight) = getimagesize($temp_thumb);
                 $margin = floor((100 - $theight) / 2);
             }
             if ($replacing) {
                 $file = $storage->replace($temp_thumb, $thumb["prefix"] . $pinfo["basename"], "files/resources/");
             } else {
                 $file = $storage->store($temp_thumb, $thumb["prefix"] . $pinfo["basename"], "files/resources/");
             }
             $thumbs[$key] = $file;
         }
     }
     // Upload the original to the proper place.
     if ($replacing) {
         $file = $storage->replace($first_copy, $file_name, "files/resources/");
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:upload.php

示例2: processImageUpload


//.........这里部分代码省略.........
         if (!$field["output"]) {
             if ($storage->DisabledFileError) {
                 $bigtree["errors"][] = array("field" => $field["title"], "error" => "Could not upload file. The file extension is not allowed.");
             } else {
                 $bigtree["errors"][] = array("field" => $field["title"], "error" => "Could not upload file. The destination is not writable.");
             }
             unlink($temp_copy);
             unlink($first_copy);
             // Failed, we keep the current value
             return false;
             // If we did upload it successfully, check on thumbs and crops.
         } else {
             // Get path info on the file.
             $pinfo = BigTree::pathInfo($field["output"]);
             // Handle Crops
             if (is_array($field["options"]["crops"])) {
                 foreach ($field["options"]["crops"] as $crop) {
                     if (is_array($crop)) {
                         // Make sure the crops have a width/height and it's numeric
                         if ($crop["width"] && $crop["height"] && is_numeric($crop["width"]) && is_numeric($crop["height"])) {
                             $cwidth = $crop["width"];
                             $cheight = $crop["height"];
                             // Check to make sure each dimension is greater then or equal to, but not both equal to the crop.
                             if ($iheight >= $cheight && $iwidth > $cwidth || $iwidth >= $cwidth && $iheight > $cheight) {
                                 // Make a square if for some reason someone only entered one dimension for a crop.
                                 if (!$cwidth) {
                                     $cwidth = $cheight;
                                 } elseif (!$cheight) {
                                     $cheight = $cwidth;
                                 }
                                 $bigtree["crops"][] = array("image" => $temp_copy, "directory" => $field["options"]["directory"], "retina" => $field["options"]["retina"], "name" => $pinfo["basename"], "width" => $cwidth, "height" => $cheight, "prefix" => $crop["prefix"], "thumbs" => $crop["thumbs"], "center_crops" => $crop["center_crops"], "grayscale" => $crop["grayscale"]);
                                 // If it's the same dimensions, let's see if they're looking for a prefix for whatever reason...
                             } elseif ($iheight == $cheight && $iwidth == $cwidth) {
                                 // See if we want thumbnails
                                 if (is_array($crop["thumbs"])) {
                                     foreach ($crop["thumbs"] as $thumb) {
                                         // Make sure the thumbnail has a width or height and it's numeric
                                         if ($thumb["width"] && is_numeric($thumb["width"]) || $thumb["height"] && is_numeric($thumb["height"])) {
                                             // Create a temporary thumbnail of the image on the server before moving it to it's destination.
                                             $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
                                             BigTree::createThumbnail($temp_copy, $temp_thumb, $thumb["width"], $thumb["height"], $field["options"]["retina"], $thumb["grayscale"]);
                                             // We use replace here instead of upload because we want to be 100% sure that this file name doesn't change.
                                             $storage->replace($temp_thumb, $thumb["prefix"] . $pinfo["basename"], $field["options"]["directory"]);
                                         }
                                     }
                                 }
                                 // See if we want center crops
                                 if (is_array($crop["center_crops"])) {
                                     foreach ($crop["center_crops"] as $center_crop) {
                                         // Make sure the crop has a width and height and it's numeric
                                         if ($center_crop["width"] && is_numeric($center_crop["width"]) && $center_crop["height"] && is_numeric($center_crop["height"])) {
                                             // Create a temporary crop of the image on the server before moving it to it's destination.
                                             $temp_crop = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
                                             BigTree::centerCrop($temp_copy, $temp_crop, $center_crop["width"], $center_crop["height"], $field["options"]["retina"], $center_crop["grayscale"]);
                                             // We use replace here instead of upload because we want to be 100% sure that this file name doesn't change.
                                             $storage->replace($temp_crop, $center_crop["prefix"] . $pinfo["basename"], $field["options"]["directory"]);
                                         }
                                     }
                                 }
                                 $storage->store($temp_copy, $crop["prefix"] . $pinfo["basename"], $field["options"]["directory"], false);
                             }
                         }
                     }
                 }
             }
             // Handle thumbnailing
             if (is_array($field["options"]["thumbs"])) {
                 foreach ($field["options"]["thumbs"] as $thumb) {
                     // Make sure the thumbnail has a width or height and it's numeric
                     if ($thumb["width"] && is_numeric($thumb["width"]) || $thumb["height"] && is_numeric($thumb["height"])) {
                         $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
                         BigTree::createThumbnail($temp_copy, $temp_thumb, $thumb["width"], $thumb["height"], $field["options"]["retina"], $thumb["grayscale"]);
                         // We use replace here instead of upload because we want to be 100% sure that this file name doesn't change.
                         $storage->replace($temp_thumb, $thumb["prefix"] . $pinfo["basename"], $field["options"]["directory"]);
                     }
                 }
             }
             // Handle center crops
             if (is_array($field["options"]["center_crops"])) {
                 foreach ($field["options"]["center_crops"] as $crop) {
                     // Make sure the crop has a width and height and it's numeric
                     if ($crop["width"] && is_numeric($crop["width"]) && $crop["height"] && is_numeric($crop["height"])) {
                         $temp_crop = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
                         BigTree::centerCrop($temp_copy, $temp_crop, $crop["width"], $crop["height"], $field["options"]["retina"], $crop["grayscale"]);
                         // We use replace here instead of upload because we want to be 100% sure that this file name doesn't change.
                         $storage->replace($temp_crop, $crop["prefix"] . $pinfo["basename"], $field["options"]["directory"]);
                     }
                 }
             }
             // If we don't have any crops, get rid of the temporary image we made.
             if (!count($bigtree["crops"])) {
                 unlink($temp_copy);
             }
         }
         // We failed, keep the current value.
     } else {
         return false;
     }
     return $field["output"];
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:101,代码来源:admin.php


注:本文中的BigTree::createThumbnail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。