public function process($imageResource = null, $imageUrl = null) { // Check if post has a suitable image try { $imageUrl = (new ImageExtractor($this->post->url))->get(399); } catch (\Exception $e) { $imageUrl = (new ImageExtractor($this->post->url, $this->post->content))->get(399); } if ($imageUrl) { $imageResource = \ImageHandler::make($imageUrl); // store it (new StoreImage($this->post))->process($imageResource, $imageUrl); // cache it (new CacheImage($this->post))->process($imageResource); } }
<?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // $Id$ /** * 用web 404的方式即时生成缺少的文件,仅适后台上传信用件 * author guoll * */ include_once 'init.php'; $request_uri = $_SERVER['REQUEST_URI']; $thr = ImageHandler::make($request_uri); $thr->display(); //if(defined('_PS_DEBUG') && _PS_DEBUG === TRUE) file_put_contents('thumb_404.log', $thr->debug_out(true)); class ImageHandler { const CACHE_IMAGE_ROOT = '/sproot/web/upload/upfile/'; const UPLOAD_ROOT = '/sproot/web/upload/upfile/'; const MAX_QUALITY = 92; private $_uri; private $_image_id; private $_src_file; // 原图 private $_real_uri; private $_real_file; private $_imagick; private $_ext; private $_section; /** * function description *