예제 #1
0
파일: index.php 프로젝트: RoBorg/SpriteGen
                    break;
                case UPLOAD_ERR_EXTENSION:
                    $imageErrors[] = $name . ': File upload stopped by extension.';
                    break;
                default:
                    throw new Exception('Unexpected file error number "' . $_FILES['images']['error'][$i] . '"');
            }
        }
        if (empty($imageErrors)) {
            if (count($images) < 2) {
                $errors['images'] = 'Please select at least 2 image files';
            } else {
                $options = ['output_type' => empty($_POST['output_type']) ? 'png' : $_POST['output_type'], 'jpeg_quality' => !isset($_POST['jpeg_quality']) ? 75 : (int) $_POST['jpeg_quality'], 'css_prefix' => empty($_POST['css_prefix']) ? '' : $_POST['css_prefix'], 'padding' => empty($_POST['padding']) ? 0 : (int) $_POST['padding'], 'jpeg_reduce_artefacts' => !empty($_POST['jpeg_reduce_artefacts'])];
                $sprite = new CssSprite();
                try {
                    $sprite->run($images, $options);
                    $done = true;
                } catch (Exception $e) {
                    $errors['sprite'] = 'There was an error creating your sprite: ' . $e->getMessage();
                }
            }
        } else {
            $errors['images'] = implode(' ', $imageErrors);
        }
    }
}
if ($done) {
    $spriteDataUri = $sprite->getDataUri();
}
?>
<!DOCTYPE html>