function create_thumbnail($source, $new_file) { global $attach_config; $source = amod_realpath($source); $min_filesize = intval($attach_config['img_min_thumb_filesize']); $img_filesize = file_exists(amod_realpath($source)) ? filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { return FALSE; } $size = image_getdimension($source); if ($size[0] <= 0 && $size[1] <= 0) { return FALSE; } $new_size = get_img_size_format($size[0], $size[1]); $tmp_path = ''; $old_file = ''; if (intval($attach_config['allow_ftp_upload'])) { $old_file = $new_file; $tmp_path = explode('/', $source); $tmp_path[count($tmp_path) - 1] = ''; $tmp_path = implode('/', $tmp_path); if ($tmp_path == '') { $tmp_path = '/tmp'; } $value = trim($tmp_path); if ($value[strlen($value) - 1] == '/') { $value[strlen($value) - 1] = ' '; } $new_file = trim($value) . '/t00000'; } global $MAIN_CFG; if (!isset($MAIN_CFG['imaging']['type'])) { //$attach_config['use_gd2'] $MAIN_CFG['imaging']['type'] = empty($attach_config['img_imagick']) ? 'gd2' : 'im'; $MAIN_CFG['imaging']['impath'] = $attach_config['img_imagick']; $MAIN_CFG['imaging']['pbmpath'] = $attach_config['img_imagick']; } require_once 'includes/imaging/imaging.inc'; Graphic::resize($source, $new_size, $new_file, $size); if (!file_exists(amod_realpath($new_file))) { return FALSE; } if (intval($attach_config['allow_ftp_upload'])) { $result = ftp_file($new_file, $old_file, $this->type, TRUE); // True for disable error-mode if (!$result) { return FALSE; } } else { chmod($new_file, PHP_AS_NOBODY ? 0666 : 0644); } return TRUE; }