static function transform1($params) { $url = $params['image']; $data = $params['data']; $info = image::image_info($url); $path = $info['path']; if (!io::file_exists($path)) { throw new \Exception(resources::message('FILE_NOT_EXISTS', $path)); } if (meta::exists($info['id'])) { $meta = meta::get($info['id']); $spath = util::apath($meta['orig']); $data = isset($meta['data']) ? image::combine_transform($meta['data'], $data) : $data; } else { $spath = $path; } $id = util::id(); $name = $id . '.' . $info['ext']; $dpath = DRAFT_CONTENT_DIR . '/' . $name; image::transform_image($spath, $dpath, $data); meta::put($id, array('orig' => util::rpath($spath), 'oid' => $info['id'], 'path' => util::rpath($dpath), 'name' => $name, 'data' => $data, 'image' => true)); return array('status' => 0, 'url' => DRAFT_CONTENT_URL . '/' . $name); }
function test_image_info() { define('SC_ROOT', 'sc-test'); $this->assertEquals(array('id' => '1234', 'ext' => 'jpg', 'path' => 'sc-test' . '/' . 'sitecake-content/1234.jpg', 'name' => '1234.jpg'), image::image_info('sitecake-content/1234.jpg')); $this->assertEquals(array('id' => '123', 'ext' => 'jpg', 'path' => 'sc-test' . '/' . 'images/test/ui/123.4.jpg', 'name' => '123.4.jpg'), image::image_info('images/test/ui/123.4.jpg')); }