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


PHP graphics::_update_item_dimensions方法代码示例

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


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

示例1: generate


//.........这里部分代码省略.........
                     clearstatcache();
                     if (@filesize($output_file) == 0) {
                         try {
                             movie::extract_frame($working_file, $output_file, $movie_options_wrapper->movie_options);
                             // If we're here, we know ffmpeg is installed and the movie is valid.  Because the
                             // user may not always have had ffmpeg installed, the movie's width, height, and
                             // mime type may need updating.  Let's use this opportunity to make sure they're
                             // correct.  It's not optimal to do it at this low level, but it's not trivial to find
                             // these cases quickly in an upgrade script.
                             list($width, $height, $mime_type) = movie::get_file_metadata($working_file);
                             // Only set them if they need updating to avoid marking them as "changed"
                             if ($item->width != $width || $item->height != $height || $item->mime_type != $mime_type) {
                                 $item->width = $width;
                                 $item->height = $height;
                                 $item->mime_type = $mime_type;
                             }
                         } catch (Exception $e) {
                             // Didn't work, likely because of MISSING_FFMPEG - use placeholder
                             graphics::_replace_image_with_placeholder($item, $target);
                             break;
                         }
                     }
                     $working_file = $output_file;
                 case "photo":
                     // Run the graphics rules (for both movies and photos)
                     foreach (self::_get_rules($target) as $rule) {
                         $args = array($working_file, $output_file, unserialize($rule->args), $item);
                         call_user_func_array($rule->operation, $args);
                         $working_file = $output_file;
                     }
                     break;
                 case "album":
                     if (!($cover = $item->album_cover())) {
                         // This album has no cover; copy its placeholder image.  Because of an old bug, it's
                         // possible that there's an album cover item id that points to an invalid item.  In that
                         // case, just null out the album cover item id.  It's not optimal to do that at this low
                         // level, but it's not trivial to find these cases quickly in an upgrade script and if we
                         // don't do this, the album may be permanently marked as "needs rebuilding"
                         //
                         // ref: http://sourceforge.net/apps/trac/gallery/ticket/1172
                         //      http://galleryproject.org/node/96926
                         if ($item->album_cover_item_id) {
                             $item->album_cover_item_id = null;
                             $item->save();
                         }
                         graphics::_replace_image_with_placeholder($item, $target);
                         break;
                     }
                     if ($cover->thumb_dirty) {
                         graphics::generate($cover);
                     }
                     if (!$cover->thumb_dirty) {
                         // Make the album cover from the cover item's thumb.  Run gallery_graphics::resize with
                         // null options and it will figure out if this is a direct copy or conversion to jpg.
                         $working_file = $cover->thumb_path();
                         gallery_graphics::resize($working_file, $output_file, null, $item);
                     }
                     break;
             }
         }
         if (!empty($ops["thumb"])) {
             if (file_exists($item->thumb_path())) {
                 $item->thumb_dirty = 0;
             } else {
                 Kohana_Log::add("error", "Failed to rebuild thumb image: {$item->title}");
                 graphics::_replace_image_with_placeholder($item, "thumb");
             }
         }
         if (!empty($ops["resize"])) {
             if (file_exists($item->resize_path())) {
                 $item->resize_dirty = 0;
             } else {
                 Kohana_Log::add("error", "Failed to rebuild resize image: {$item->title}");
                 graphics::_replace_image_with_placeholder($item, "resize");
             }
         }
         graphics::_update_item_dimensions($item);
         $item->save();
     } catch (Exception $e) {
         // Something went wrong rebuilding the image.  Replace with the placeholder images,
         // leave it dirty and move on.
         Kohana_Log::add("error", "Caught exception rebuilding images: {$item->title}\n" . $e->getMessage() . "\n" . $e->getTraceAsString());
         if ($item->is_photo()) {
             graphics::_replace_image_with_placeholder($item, "resize");
         }
         graphics::_replace_image_with_placeholder($item, "thumb");
         try {
             graphics::_update_item_dimensions($item);
         } catch (Exception $e) {
             // Looks like get_file_metadata couldn't identify our placeholders.  We should never get
             // here, but in the odd case we do, we need to do something.  Let's put in hardcoded values.
             if ($item->is_photo()) {
                 list($item->resize_width, $item->resize_height) = array(200, 200);
             }
             list($item->thumb_width, $item->thumb_height) = array(200, 200);
         }
         $item->save();
         throw $e;
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:101,代码来源:graphics.php


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