PHP Classes

File: upload-04.php

Recommend this page to a friend!
  Classes of Krzysztof Kardasz   Nweb Image   upload-04.php   Download  
File: upload-04.php
Role: Example script
Content type: text/plain
Description: Example
Class: Nweb Image
Perform several image manipulation operations
Author: By
Last change:
Date: 16 years ago
Size: 2,024 bytes
 

Contents

Class file image Download
<?php
/**
 * Nweb Extension Script
 *
 * Example
 *
 * @category Nweb
 * @package Nweb_Scripts
 * @author Krzysztof Kardasz
 * @copyright Copyright (c) euo.pl
 */


   
include 'lib/Image.php';
    include
'lib/ImageException.php';

try {

   
// Upload zdjęcia poprzez Obiekt Image()
    // Możliwość uploadu tylko 1 zdjęcia podczas jeden instacji

   
$upload = new Image();

   
#Jeśli został załadowany obrazek POST
    # Koniecznie trzeba użyć ifa ;-)
   
if($upload->upload('obraz1')) {
       
#Zmniejszamy
       
$upload->ResizeToWidthHeight(800, 600);
       
#Filtr
       
$upload->GrayScale();
       
#Zapisanie
       
$upload->Save('uploads/','upload-04-obraz12');

       
# ImageFile(true) podaje nam prawdziwą ścieżke i nazwę pliku gdzie został zapisany
        # ImageFile(false) podaje nam nazwę pliku tymczasowego jeśli taki istnieje.

        #Otwieramy ponownie
       
$thumb = new Image($upload->ImageFile(true));
       
$thumb->open();
       
# Pomniejszamy
       
$thumb->ResizeToWidth(200);
       
# Tekst tworzymy na podstawie duzego zdjecia (rozmiar i rozdzielczosc)
       
$thumb->Text ($upload, array('MINIATURA', Image::Resolution . Image::Size), 'terminal6.gdf');
       
#Zapis miniatury
       
$thumb->Save(null,'thumb_upload-04-obraz1');
    }
}

catch (
ImageException $e)
{
    die(
$e->Message());
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>ImageUpload - 04</title>
</head>
<body>
<h3><?php echo (!empty($Messages)) ? $Messages : 'Upload zdjęć'; ?></h3>
<form enctype="multipart/form-data" action="" method="post">
<fieldset>
    <legend>Zdjęcia:</legend>
    <label>Obraz1</label> <input name="obraz1" type="file" /> <br />
</fieldset>
 <input type="submit" name="submit" value="Upload" />
</form>

</body>
</html>