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


PHP system::temp_filename方法代码示例

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


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

示例1: temp_filename_test

 public function temp_filename_test()
 {
     $filename = system::temp_filename("file", "ext");
     $this->assert_true(file_exists($filename), "File not created");
     unlink($filename);
     $this->assert_pattern($filename, "|/file.*\\.ext\$|");
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:7,代码来源:System_Helper_Test.php

示例2: rotate

 public function rotate($id, $dir)
 {
     access::verify_csrf();
     $item = model_cache::get("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     $degrees = 0;
     switch ($dir) {
         case "ccw":
             $degrees = -90;
             break;
         case "cw":
             $degrees = 90;
             break;
     }
     if ($degrees) {
         $tmpfile = system::temp_filename("rotate", pathinfo($item->file_path(), PATHINFO_EXTENSION));
         gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item);
         $item->set_data_file($tmpfile);
         $item->save();
     }
     if (Input::instance()->get("page_type") == "collection") {
         json::reply(array("src" => $item->thumb_url(), "width" => $item->thumb_width, "height" => $item->thumb_height));
     } else {
         json::reply(array("src" => $item->resize_url(), "width" => $item->resize_width, "height" => $item->resize_height));
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:27,代码来源:quick.php

示例3: item_created

 static function item_created($item)
 {
     if ($item->is_photo()) {
         $input_file = $item->file_path();
         $output_file = system::temp_filename("rawphoto-", "jpg");
         $success = rawphoto_graphics::convert($input_file, $output_file);
         if ($success) {
             $item->set_data_file($output_file);
             $item->save();
             unlink($output_file);
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:13,代码来源:rawphoto_event.php

示例4: movie_get_file_metadata

 /**
  * Get PDF file metadata (height and width)
  * (ref: movie::get_file_metadata())
  */
 static function movie_get_file_metadata($file_path, $metadata)
 {
     if (strtolower(pathinfo($file_path, PATHINFO_EXTENSION)) == "pdf" && ($path = pdf::find_gs())) {
         // Parsing gs output properly can be a pain.  So, let's go for a reliable albeit inefficient
         // approach: re-extract the frame (into tmp) and get its image size.
         $temp_file = system::temp_filename("pdf_", "jpg");
         pdf_event::movie_extract_frame($file_path, $temp_file, null, null);
         list($metadata->height, $metadata->width) = photo::get_file_metadata($temp_file);
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:14,代码来源:pdf_event.php

示例5: composite

 /**
  * Overlay an image on top of the input file.
  *
  * Valid options are: file, position, transparency, padding
  *
  * Valid positions: northwest, north, northeast,
  *                  west, center, east,
  *                  southwest, south, southeast
  *
  * padding is in pixels
  *
  * @param string     $input_file
  * @param string     $output_file
  * @param array      $options
  * @param Item_Model $item (optional)
  */
 static function composite($input_file, $output_file, $options, $item = null)
 {
     try {
         graphics::init_toolkit();
         $temp_file = system::temp_filename("composite_", pathinfo($output_file, PATHINFO_EXTENSION));
         module::event("graphics_composite", $input_file, $temp_file, $options, $item);
         if (@filesize($temp_file) > 0) {
             // A graphics_composite event made an image - move it to output_file and use it.
             @rename($temp_file, $output_file);
         } else {
             // No events made an image - proceed with standard process.
             list($width, $height) = photo::get_file_metadata($input_file);
             list($w_width, $w_height) = photo::get_file_metadata($options["file"]);
             $pad = isset($options["padding"]) ? $options["padding"] : 10;
             $top = $pad;
             $left = $pad;
             $y_center = max($height / 2 - $w_height / 2, $pad);
             $x_center = max($width / 2 - $w_width / 2, $pad);
             $bottom = max($height - $w_height - $pad, $pad);
             $right = max($width - $w_width - $pad, $pad);
             switch ($options["position"]) {
                 case "northwest":
                     $x = $left;
                     $y = $top;
                     break;
                 case "north":
                     $x = $x_center;
                     $y = $top;
                     break;
                 case "northeast":
                     $x = $right;
                     $y = $top;
                     break;
                 case "west":
                     $x = $left;
                     $y = $y_center;
                     break;
                 case "center":
                     $x = $x_center;
                     $y = $y_center;
                     break;
                 case "east":
                     $x = $right;
                     $y = $y_center;
                     break;
                 case "southwest":
                     $x = $left;
                     $y = $bottom;
                     break;
                 case "south":
                     $x = $x_center;
                     $y = $bottom;
                     break;
                 case "southeast":
                     $x = $right;
                     $y = $bottom;
                     break;
             }
             Image::factory($input_file)->composite($options["file"], $x, $y, $options["transparency"])->quality(module::get_var("gallery", "image_quality"))->save($output_file);
         }
         module::event("graphics_composite_completed", $input_file, $output_file, $options, $item);
     } catch (ErrorException $e) {
         // Unlike rotate and resize, composite catches its exceptions here.  This is because
         // composite is typically called for watermarks.  If during thumb/resize generation
         // the watermark fails, we'd still like the image resized, just without its watermark.
         // If the exception isn't caught here, graphics::generate will replace it with a
         // placeholder.
         Kohana_Log::add("error", $e->getMessage());
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:86,代码来源:gallery_graphics.php


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