本文整理汇总了PHP中file::get_image_properties方法的典型用法代码示例。如果您正苦于以下问题:PHP file::get_image_properties方法的具体用法?PHP file::get_image_properties怎么用?PHP file::get_image_properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::get_image_properties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_upload_data
/**
* get full information for an upload
*
* @param string $file
* @param array $file_data
* @return array
* @author Andy Bennett
*/
function get_upload_data($file, $file_data)
{
$filename = self::save($file);
if (APPENV == 'frontend') {
$upl_dir = str_replace('frontend', 'backend', Kohana::config('upload.directory'));
if (!copy($filename, $upl_dir . basename($filename))) {
Kohana::log('error', "COPY FAILED: copy({$filename}, {$upl_dir}.basename({$filename}))");
}
}
$pp = pathinfo($filename);
$ext = $pp['extension'];
$file_type = self::check_filetype($file_data['type'], $filename);
$d = Kohana::config('upload.directory');
$upload_data['file_name'] = $pp['basename'];
$upload_data['file_type'] = $file_type;
$upload_data['file_path'] = $d;
$upload_data['full_path'] = $filename;
$upload_data['raw_name'] = $pp['filename'];
$upload_data['orig_name'] = $file_data['name'];
$upload_data['file_ext'] = '.' . strtolower($ext);
$upload_data['file_size'] = $file_data['size'];
$upload_data['is_image'] = file::is_image($file_type);
$upload_data['date_added'] = date('Y-m-d H:i:s');
if ($upload_data['is_image']) {
$properties = file::get_image_properties($filename);
if (!empty($properties)) {
$upload_data = array_merge($upload_data, $properties);
}
}
return $upload_data;
}
示例2: get_upload_data
/**
* get full information for an upload
*
* @param string $file
* @param array $file_data
* @return array
* @author Andy Bennett
*/
function get_upload_data($file, $file_data, $save = true)
{
$filename = $save ? upload::save($file_data) : $file;
if (!strlen($filename)) {
throw new Exception("Empty filename", 1);
}
$pp = pathinfo($filename);
$ext = strtolower($pp['extension']);
$file_type = uploads::check_filetype($file_data['type'], $filename, $ext);
$d = Kohana::config('upload.directory');
$upload_data['file_name'] = $pp['basename'];
$upload_data['file_type'] = $file_type;
$upload_data['file_path'] = $d;
$upload_data['full_path'] = $filename;
$upload_data['raw_name'] = $pp['filename'];
$upload_data['orig_name'] = $file_data['name'];
$upload_data['file_ext'] = '.' . strtolower($ext);
$upload_data['file_size'] = $file_data['size'];
$upload_data['is_image'] = file::is_image($file_type);
$upload_data['is_video'] = 0;
$upload_data['is_audio'] = 0;
$upload_data['date_added'] = date('Y-m-d H:i:s');
$upload_data['preview'] = false;
$driver = uploads::get_driver($upload_data['is_image'], $file_type, $ext);
if ($driver !== false) {
// Load the driver
if (Kohana::auto_load($driver)) {
// Initialize the driver
$upload_driver = new $driver();
// Validate the driver
if (!$upload_driver instanceof Uploader_Driver) {
throw new Kohana_Exception('core.driver_implements', $driver, 'upload', 'Uploader_Driver');
}
$upload_driver->generate_preview($upload_data, $filename, $ext);
}
}
if ($upload_data['is_image']) {
$properties = file::get_image_properties($filename);
if (!empty($properties)) {
$upload_data = array_merge($upload_data, $properties);
}
}
return $upload_data;
}
示例3: save_preview
/**
* generate a preview image
*
* @param string $upload_data
* @return void
* @author Andy Bennett
*/
public function save_preview($upload_data, $filename)
{
$pp = pathinfo($filename);
$preview_data = $upload_data;
$preview_data['file_name'] = $pp['basename'];
$preview_data['file_type'] = 'image/jpeg';
$preview_data['full_path'] = $filename;
$preview_data['raw_name'] = $pp['filename'];
$preview_data['file_ext'] = '.jpg';
$preview_data['file_size'] = filesize($filename);
$preview_data['is_image'] = true;
$preview_data['is_audio'] = false;
$preview_data['is_video'] = false;
$preview_data['date_added'] = date('Y-m-d H:i:s');
$properties = file::get_image_properties($filename);
if (!empty($properties)) {
$preview_data = array_merge($preview_data, $properties);
}
return $preview_data;
}