Exemple #1
0
<?php

$error = null;
try {
    if (isset($_FILES['Image'])) {
        $ext = strtolower(pathinfo($_FILES['Image']['name'], PATHINFO_EXTENSION));
        if (!in_array($ext, array('png', 'jpg', 'bmp', 'jpeg', 'gif'))) {
            throw new Exception('Formato de imagem inválido');
        }
        require_once "./canvas.php";
        $canvas = new canvas();
        $canvas->carrega($_FILES['Image']['tmp_name']);
        $canvas->redimensiona(400, 400, 'crop');
        $canvas->marca('minas.png', 'topo', 'esquerda');
        $canvas->grava();
        exit;
    }
} catch (Exception $e) {
    $error = $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Mariana - Minas Gerais</title>
Exemple #2
0
    if ($realWidth < $maxWidth) {
        $imageWidth = $realWidth;
    } else {
        $imageWidth = $maxWidth;
    }
    // Manipula a foto principal
    $img = new canvas();
    $img->carrega($pasta . $fileName);
    $img->redimensiona($imageWidth, 0, $tipoCorte);
    $img->grava($pasta . $fileName, $qualidade);
    // Se solicitado, envia thumb manipulada
    if ($thumbs == "Sim") {
        $oThumb = new canvas();
        $oThumb->carrega($pasta . $fileName);
        $oThumb->redimensiona($thumbW, $thumbH, $thumbCorte);
        $oThumb->grava($pasta . "thumb-" . $fileName, $qualidade);
    }
    insert(array("cond", "foto"), array($cond, $fileName), "site_static_fotos");
}
?>

	<script>
		sweetRedir("Sucesso", "Fotos enviadas com sucesso.", "success", "<?php 
echo CP;
?>
/view/static/<?php 
echo $cond;
?>
", "Voltar");
	</script>