Exemplo n.º 1
0
 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);
 }