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


PHP graphics::generate方法代码示例

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


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

示例1: item_created

 static function item_created($item)
 {
     // Only works on photos
     if (!$item->is_photo()) {
         return;
     }
     // Locate jhead
     if (!is_file($path = exec('which jhead'))) {
         // @todo throw an exception ?
         Kohana::log('error', 'jhead is not installed');
     }
     $binary = str_replace('\\', '/', realpath(dirname($path)));
     $binary .= '/jhead';
     $binary .= PHP_SHLIB_SUFFIX === 'dll' ? '.exe' : '';
     if (!is_file($binary)) {
         // @todo throw an exception ?
         Kohana::log('error', 'Unable to locate jhead binary');
     }
     // Invoke jhead
     if ($error = exec(escapeshellcmd($binary) . ' -q -autorot ' . $item->file_path())) {
         // @todo throw an exception ?
         Kohana::log('error', 'Error during execution of jhead');
     }
     // Update item
     $image_info = getimagesize($item->file_path());
     $item->width = $image_info[0];
     $item->height = $image_info[1];
     $item->resize_dirty = 1;
     $item->thumb_dirty = 1;
     $item->save();
     graphics::generate($item);
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:32,代码来源:jhead_event.php

示例2: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $result = graphics::find_dirty_images_query();
     $remaining = $result->count();
     $completed = $task->get("completed", 0);
     $i = 0;
     foreach ($result as $row) {
         $item = ORM::factory("item", $row->id);
         if ($item->loaded) {
             graphics::generate($item);
         }
         $completed++;
         $remaining--;
         if (++$i == 2) {
             break;
         }
     }
     $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
     if ($completed + $remaining > 0) {
         $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
     } else {
         $task->percent_complete = 100;
     }
     $task->set("completed", $completed);
     if ($remaining == 0) {
         $task->done = true;
         $task->state = "success";
         site_status::clear("graphics_dirty");
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:34,代码来源:core_task.php

示例3: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query()->select("id")->execute();
         $total_count = $task->get("total_count", $result->count());
         $mode = $task->get("mode", "init");
         if ($mode == "init") {
             $task->set("total_count", $total_count);
             $task->set("mode", "process");
             batch::start();
         }
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded()) {
                 try {
                     graphics::generate($item);
                     $completed++;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = (string) $e;
                     $ignored[$item->id] = 1;
                 }
             }
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
         if ($completed < $total_count) {
             $task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($task->percent_complete == 100) {
             $task->done = true;
             $task->state = "success";
             batch::stop();
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }
开发者ID:andyst,项目名称:gallery3,代码行数:64,代码来源:gallery_task.php

示例4: rebuild_dirty_images

 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query();
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $remaining = $result->count() - count($ignored);
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded) {
                 try {
                     graphics::generate($item);
                     $ignored[$item->id] = 1;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = $e->__toString();
                 }
             }
             $completed++;
             $remaining--;
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
         if ($completed + $remaining > 0) {
             $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($remaining == 0) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = $e->__toString();
     }
     if ($errors) {
         $task->log($errors);
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:57,代码来源:gallery_task.php

示例5: remove_album_cover

 static function remove_album_cover($album)
 {
     access::required("edit", $album);
     @unlink($album->thumb_path());
     model_cache::clear("item", $album->album_cover_item_id);
     $album->album_cover_item_id = null;
     $album->thumb_width = 0;
     $album->thumb_height = 0;
     $album->thumb_dirty = 1;
     $album->save();
     graphics::generate($album);
 }
开发者ID:xafr,项目名称:gallery3,代码行数:12,代码来源:item.php

示例6: create

 /**
  * Create a new photo.
  * @param integer $parent_id id of parent album
  * @param string  $filename path to the photo file on disk
  * @param string  $name the filename to use for this photo in the album
  * @param integer $title the title of the new photo
  * @param string  $description (optional) the longer description of this photo
  * @return Item_Model
  */
 static function create($parent, $filename, $name, $title, $description = null, $owner_id = null)
 {
     if (!$parent->loaded || $parent->type != "album") {
         throw new Exception("@todo INVALID_PARENT");
     }
     if (!is_file($filename)) {
         throw new Exception("@todo MISSING_IMAGE_FILE");
     }
     if (!($image_info = getimagesize($filename))) {
         throw new Exception("@todo INVALID_IMAGE_FILE");
     }
     // Force an extension onto the name
     $pi = pathinfo($name);
     if (empty($pi["extension"])) {
         $pi["extension"] = image_type_to_extension($image_info[2], false);
         $name .= "." . $pi["extension"];
     }
     $photo = ORM::factory("item");
     $photo->type = "photo";
     $photo->title = $title;
     $photo->description = $description;
     $photo->name = $name;
     $photo->owner_id = $owner_id;
     $photo->width = $image_info[0];
     $photo->height = $image_info[1];
     $photo->mime_type = empty($image_info['mime']) ? "application/unknown" : $image_info['mime'];
     $photo->thumb_dirty = 1;
     $photo->resize_dirty = 1;
     // Randomize the name if there's a conflict
     while (ORM::Factory("item")->where("parent_id", $parent->id)->where("name", $photo->name)->find()->id) {
         // @todo Improve this.  Random numbers are not user friendly
         $photo->name = rand() . "." . $pi["extension"];
     }
     // This saves the photo
     $photo->add_to_parent($parent);
     copy($filename, $photo->file_path());
     module::event("item_created", $photo);
     // Build our thumbnail/resizes
     graphics::generate($photo);
     // If the parent has no cover item, make this it.
     $parent = $photo->parent();
     if ($parent->album_cover_item_id == null) {
         $parent->album_cover_item_id = $photo->id;
         $parent->save();
         graphics::generate($parent);
     }
     return $photo;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:57,代码来源:photo.php

示例7: save

 public function save($source_id)
 {
     access::verify_csrf();
     $source = ORM::factory("item", $source_id);
     access::required("edit", $source);
     $target = ORM::factory("item", $this->input->post("target_id"));
     access::required("edit", $target);
     $source->move_to($target);
     // If the target has no cover item, make this it.
     if ($target->album_cover_item_id == null) {
         $target->album_cover_item_id = $source->type == "album" ? $source->album_cover_item_id : $source->id;
         $target->save();
         graphics::generate($target);
     }
     print json_encode(array("result" => "success", "location" => url::site("albums/{$target->id}")));
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:16,代码来源:move.php

示例8: item_created

 static function item_created($item)
 {
     access::add_item($item);
     if ($item->is_photo() || $item->is_movie()) {
         // Build our thumbnail/resizes.
         try {
             graphics::generate($item);
         } catch (Exception $e) {
             log::error("graphics", t("Couldn't create a thumbnail or resize for %item_title", array("item_title" => $item->title)), html::anchor($item->abs_url(), t("details")));
             Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
         }
         // If the parent has no cover item, make this it.
         $parent = $item->parent();
         if (access::can("edit", $parent) && $parent->album_cover_item_id == null) {
             item::make_album_cover($item);
         }
     }
 }
开发者ID:andyst,项目名称:gallery3,代码行数:18,代码来源:gallery_event.php

示例9: restore

 public function restore($id)
 {
     // Allow the user to restore the original photo.
     // Make sure the current user has suficient access to view and edit the item.
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     // Figure out where the original was stashed at.
     $original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
     // Make sure the current item is a photo and that an original exists.
     if ($item->is_photo() && file_exists($original_image)) {
         // Delete the modified version of the photo.
         @unlink($item->file_path());
         // Copy the original image back over, display an error message if the copy fails.
         if (@rename($original_image, $item->file_path())) {
             // Re-generate the items resize and thumbnail.
             $item_data = model_cache::get("item", $id);
             $item_data->resize_dirty = 1;
             $item_data->thumb_dirty = 1;
             $item_data->save();
             graphics::generate($item_data);
             // If the item is the thumbnail for the parent album,
             //   fix the parent's thumbnail as well.
             $parent = $item_data->parent();
             if ($parent->album_cover_item_id == $item_data->id) {
                 copy($item_data->thumb_path(), $parent->thumb_path());
                 $parent->thumb_width = $item_data->thumb_width;
                 $parent->thumb_height = $item_data->thumb_height;
                 $parent->save();
             }
             // Display a success message and redirect to the items page.
             message::success(t("Your original image has been restored."));
             url::redirect($item->url());
         } else {
             // Display an error message if the copy failed.
             message::error(t("Image restore failed!"));
             url::redirect($item->url());
         }
     } else {
         // Display an error message if there is not an original photo.
         message::error(t("Image restore failed!"));
         url::redirect($item->url());
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:44,代码来源:keeporiginal.php

示例10: make_album_cover

 public function make_album_cover($id)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $id);
     access::required("edit", $item);
     $parent = $item->parent();
     access::required("edit", $parent);
     if ($item->type == "photo") {
         $parent->album_cover_item_id = $item->id;
     } else {
         if ($item->type == "album") {
             $parent->album_cover_item_id = $item->album_cover_item_id;
         }
     }
     $parent->thumb_dirty = 1;
     $parent->save();
     graphics::generate($parent);
     print json_encode(array("result" => "success"));
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:19,代码来源:quick.php

示例11: save

 public function save($source_id)
 {
     access::verify_csrf();
     $source = ORM::factory("item", $source_id);
     $target = ORM::factory("item", Input::instance()->post("target_id"));
     access::required("view", $source);
     access::required("view", $target);
     access::required("edit", $target);
     model_cache::clear();
     $target->album_cover_item_id = $source->is_album() ? $source->album_cover_item_id : $source->id;
     $target->thumb_dirty = 1;
     $target->save();
     graphics::generate($target);
     $grand_parent = $target->parent();
     if ($grand_parent && access::can("edit", $grand_parent) && $grand_parent->album_cover_item_id == null) {
         item::make_album_cover($target);
     }
     $msg = t("Made <b>%title</b> album's cover for <b>%album</b>", array("title" => html::purify($source->title), "album" => html::purify($target->title)));
     message::success($msg);
     json::reply(array("result" => "success"));
 }
开发者ID:khitrenovich,项目名称:gallery3-contrib,代码行数:21,代码来源:browse.php

示例12: rotate

 public function rotate($id, $dir)
 {
     access::verify_csrf();
     $item = ORM::factory("item", $id);
     if (!$item->loaded) {
         return "";
     }
     $degrees = 0;
     switch ($dir) {
         case "ccw":
             $degrees = -90;
             break;
         case "cw":
             $degrees = 90;
             break;
     }
     if ($degrees) {
         graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees));
         list($item->width, $item->height) = getimagesize($item->file_path());
         $item->resize_dirty = 1;
         $item->thumb_dirty = 1;
         $item->save();
         graphics::generate($item);
         $parent = $item->parent();
         if ($parent->album_cover_item_id == $item->id) {
             copy($item->thumb_path(), $parent->thumb_path());
             $parent->thumb_width = $item->thumb_width;
             $parent->thumb_height = $item->thumb_height;
             $parent->save();
         }
     }
     if (Input::instance()->get("page_type") == "album") {
         print json_encode(array("src" => $item->thumb_url() . "?rnd=" . rand(), "width" => $item->thumb_width, "height" => $item->thumb_height));
     } else {
         print json_encode(array("src" => $item->resize_url() . "?rnd=" . rand(), "width" => $item->resize_width, "height" => $item->resize_height));
     }
 }
开发者ID:xafr,项目名称:gallery3,代码行数:37,代码来源:quick.php

示例13: 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) {
         gallery_graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees));
         list($item->width, $item->height) = getimagesize($item->file_path());
         $item->resize_dirty = 1;
         $item->thumb_dirty = 1;
         $item->save();
         graphics::generate($item);
         $parent = $item->parent();
         // @todo: this is an inadequate way to regenerate the parent's thumbnail after rotation.
         if ($parent->album_cover_item_id == $item->id) {
             copy($item->thumb_path(), $parent->thumb_path());
             $parent->thumb_width = $item->thumb_width;
             $parent->thumb_height = $item->thumb_height;
             $parent->save();
         }
     }
     if (Input::instance()->get("page_type") == "collection") {
         print json_encode(array("src" => $item->thumb_url() . "?rnd=" . rand(), "width" => $item->thumb_width, "height" => $item->thumb_height));
     } else {
         print json_encode(array("src" => $item->resize_url() . "?rnd=" . rand(), "width" => $item->resize_width, "height" => $item->resize_height));
     }
 }
开发者ID:andyst,项目名称:gallery3,代码行数:37,代码来源:quick.php

示例14: remove_album_cover

 static function remove_album_cover($album)
 {
     access::required("view", $album);
     access::required("edit", $album);
     model_cache::clear();
     $album->album_cover_item_id = null;
     $album->save();
     graphics::generate($album);
 }
开发者ID:qboy1987,项目名称:mooiyou,代码行数:9,代码来源:item.php

示例15: 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) {
         gallery_graphics::rotate($item->file_path(), $item->file_path(), array("degrees" => $degrees));
         list($item->width, $item->height) = getimagesize($item->file_path());
         $item->resize_dirty = 1;
         $item->thumb_dirty = 1;
         $item->save();
         graphics::generate($item);
         $parent = $item->parent();
         if ($parent->album_cover_item_id == $item->id) {
             copy($item->thumb_path(), $parent->thumb_path());
             $parent->thumb_width = $item->thumb_width;
             $parent->thumb_height = $item->thumb_height;
             $parent->save();
         }
     }
     print json_encode(self::child_json_encode($item));
 }
开发者ID:Weerwolf,项目名称:gallery3-contrib,代码行数:32,代码来源:json_album.php


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