コード例 #1
0
ファイル: item_photo_edit.php プロジェクト: bash-t/admidio
     $gMessage->show($gL10n->get('PRO_PHOTO_NOT_CHOOSEN'));
 }
 //Dateiendung
 $image_properties = getimagesize($_FILES['userfile']['tmp_name'][0]);
 if ($image_properties['mime'] != 'image/jpeg' && $image_properties['mime'] != 'image/png') {
     $gMessage->show($gL10n->get('PRO_PHOTO_FORMAT_INVALID'));
 }
 //Auflösungskontrolle
 $image_dimensions = $image_properties[0] * $image_properties[1];
 if ($image_dimensions > admFuncProcessableImageSize()) {
     $gMessage->show($gL10n->get('PRO_PHOTO_RESOLUTION_TO_LARGE', round(admFuncProcessableImageSize() / 1000000, 2)));
 }
 // Foto auf entsprechende Groesse anpassen
 $user_image = new Image($_FILES['userfile']['tmp_name'][0]);
 $user_image->setImageType('jpeg');
 $user_image->scale(130, 170);
 //Ordnerspeicherung
 if ($gPreferences['profile_photo_storage'] == 1) {
     $user_image->copyToFile(null, SERVER_PATH . '/adm_my_files/item_photos/' . $getItemId . '_new.jpg');
 } else {
     //Foto in PHP-Temp-Ordner übertragen
     $user_image->copyToFile(null, $_FILES['userfile']['tmp_name'][0]);
     // Foto aus PHP-Temp-Ordner einlesen
     $user_image_data = fread(fopen($_FILES['userfile']['tmp_name'][0], 'r'), $_FILES['userfile']['size'][0]);
     // Zwischenspeichern des neuen Fotos in der Session
     $gCurrentSession->setValue('ses_binary', $user_image_data);
     $gCurrentSession->save();
 }
 //Image-Objekt löschen
 $user_image->delete();
 if ($getItemId == $gCurrentUser->getValue('inv_id')) {
コード例 #2
0
ファイル: index.php プロジェクト: gomezjsus/IAW
<?php

require 'Image.class.php';
$image = new Image('image.jpg');
// $image->type = IMAGETYPE_JPEG; // change the output type of the image, using PHP's constants
// $image->width = 400; // aspect resizes based on width
// $image->x = 400; // aspect resizes based on width
// $image->height = 300; // aspect resizes based on height
// $image->y = 300; // aspect resizes based on height
$image->scale(400, 300);
// scales the image but maintains the aspect ratio
// $image->scale(400, 300, array('force' => true)); // scales the image and forces the size, can lose the aspect ratio
// $image->cutout(600, 200); // cuts out a section of the image resizes to the minimum possible size unless options are specified
// $image->cutout(600, 200, array('scaleX' => 800, 'scaleY' => 600, 'offsetX' => 0, 'offsetY' => 0)); // cuts out the top left quarter of the image
// $image->whitespace(400, 300); // resizes the image and adds whitespace using the default colour
// $image->whitespace(400, 300, array('color' => '#f00')); // resizes the image and adds whitespace using a custom colour
// $image->whitespace(400, 300, array('image' => 'bg.jpg')); // resizes the image and adds whitespace using an image as the base
// $image->watermark('sample.png'); // watermarks the image using the specified watermark image
// $image->watermark('sample.png', array('repeatX' => false, 'repeatY' => false)); // watermarks the image using the specified watermark image, repeating the image vertically only
// $image->watermark('sample.png', array('repeatX' => false, 'repeatY' => true)); // watermarks the image using the specified watermark image, repeating the image vertically only
// $image->watermark('sample.png', array('repeatX' => true, 'repeatY' => false)); // watermarks the image using the specified watermark image, repeating the image horizontally only
// $image->watermark('sample.png', array('repeatX' => true, 'repeatY' => true)); // watermarks the image using the specified watermark image, repeating the watermark horizontally and vertically
// $image->watermark = 'sample.png'; // watermarks the image using the specified watermark image, using default options
// $filename = $image->write('thumb_image'); // write the image to the specified file, using the default extension
// $filename = $image->write('thumb_image.jpg', array('extension' => false)); // write the image to the specified file, but don't use the default extension
// $image->drawLine(array(0, 0), array($image->currentX, $image->currentY), array('size' => 4, 'color' => '#fff'));
// $image->drawBox(array(0, 230), array(400, 300), array('size' => 4, 'color' => '#000', 'transparency' => 60));
// $image->addText('Testing raw text input!', 30, ($image->currentY - 30), array('color' => '#fff', 'font' => 'ArialBlack', 'transparency' => 30));
$image->output();
// output the image to the browser (also sets the http header)
コード例 #3
0
     $gMessage->show($gL10n->get('PRO_PHOTO_NOT_CHOOSEN'));
 }
 // File ending
 $imageProperties = getimagesize($_FILES['userfile']['tmp_name'][0]);
 if ($imageProperties['mime'] !== 'image/jpeg' && $imageProperties['mime'] !== 'image/png') {
     $gMessage->show($gL10n->get('PRO_PHOTO_FORMAT_INVALID'));
 }
 // Auflösungskontrolle
 $imageDimensions = $imageProperties[0] * $imageProperties[1];
 if ($imageDimensions > admFuncProcessableImageSize()) {
     $gMessage->show($gL10n->get('PRO_PHOTO_RESOLUTION_TO_LARGE', round(admFuncProcessableImageSize() / 1000000, 2)));
 }
 // Foto auf entsprechende Groesse anpassen
 $userImage = new Image($_FILES['userfile']['tmp_name'][0]);
 $userImage->setImageType('jpeg');
 $userImage->scale(130, 170);
 // Ordnerspeicherung
 if ($gPreferences['profile_photo_storage'] == 1) {
     $userImage->copyToFile(null, SERVER_PATH . '/adm_my_files/user_profile_photos/' . $getUserId . '_new.jpg');
 } else {
     // Foto in PHP-Temp-Ordner übertragen
     $userImage->copyToFile(null, $_FILES['userfile']['tmp_name'][0]);
     // Foto aus PHP-Temp-Ordner einlesen
     $userImageData = fread(fopen($_FILES['userfile']['tmp_name'][0], 'r'), $_FILES['userfile']['size'][0]);
     // Zwischenspeichern des neuen Fotos in der Session
     $gCurrentSession->setValue('ses_binary', $userImageData);
     $gCurrentSession->save();
 }
 // Image-Objekt löschen
 $userImage->delete();
 if ($getUserId == $gCurrentUser->getValue('usr_id')) {
コード例 #4
0
ファイル: image.php プロジェクト: symphonycms/symphony-1.7
            if ($crop) {
                $image->scaleSpace($width, $height, $_REQUEST['bg']);
            } else {
                $image->scale($width, $height, $_REQUEST['bg']);
            }
            $image->renderOutputHeader($actual_name);
            $image->render($cacheFile);
            print file_get_contents($cacheFile);
        } else {
            if (!($image = new Image($cacheFile, $quality))) {
                die("<h1>Symphony Fatal Error</h1><p>Error opening cached image<hr /><em>" . $_SERVER['SERVER_SIGNATURE'] . "</em>");
            }
            $image->renderOutputHeader($actual_name);
            $image->render();
        }
    } else {
        if (!($image = new Image($file, $quality))) {
            die("<h1>Symphony Fatal Error</h1><p>Error creating Image in memory<hr /><em>" . $_SERVER['SERVER_SIGNATURE'] . "</em>");
        }
        if ($crop) {
            $image->scaleSpace($width, $height, $_REQUEST['bg']);
        } else {
            $image->scale($width, $height, $_REQUEST['bg']);
        }
        $image->renderOutputHeader($actual_name);
        $image->render();
    }
    $image->close();
    unset($image);
    exit;
}
コード例 #5
0
 } else {
     $image = new Image($content, false, $format);
     $content = null;
     // Explicitely free memory before getting cache
 }
 if ($image->is_empty()) {
     die;
 }
 $resize = false;
 // We resize if needed
 if (isset($_GET['x']) || isset($_GET['y'])) {
     $image->resize(isset($_GET['x']) ? (int) $_GET['x'] : 0, isset($_GET['y']) ? (int) $_GET['y'] : 0);
     $resize = true;
 } elseif (isset($_GET['scale'])) {
     // We scale if needed
     $image->scale($_GET['scale'] + 0);
     $resize = true;
 } elseif (isset($_GET['max'])) {
     // We reduce size if length or width is greater that $_GET['max'] if needed
     $image->resizemax($_GET['max'] + 0);
     $resize = true;
 } elseif (isset($_GET['thumbnail'])) {
     // We resize to a thumbnail size if needed
     if (is_numeric($_GET['thumbnail'])) {
         if (empty($info_thumb)) {
             $info_thumb = $filegallib->get_file($_GET['thumbnail']);
         }
         if (!empty($info_thumb['path'])) {
             $image = new Image($prefs['fgal_use_dir'] . $info_thumb['path'], true);
         } else {
             $image = new Image($info_thumb['data']);
コード例 #6
0
ファイル: photo_show.php プロジェクト: martinbrylski/admidio
        } else {
            header('content-type: image/jpg');
            echo readfile($ordner . '/thumbnails/' . $getPhotoNr . '.jpg');
        }
    } else {
        // kein Bild uebergeben, dann NoPix anzeigen
        $image = new Image(THEME_SERVER_PATH . '/images/nopix.jpg');
        $image->scaleLargerSide($gPreferences['photo_thumbs_scale']);
    }
} else {
    if (!file_exists($picpath)) {
        $picpath = THEME_SERVER_PATH . '/images/nopix.jpg';
    }
    // Bild einlesen und scalieren
    $image = new Image($picpath);
    $image->scale($getMaxWidth, $getMaxHeight);
}
if ($image !== null) {
    // Einfuegen des Textes bei Bildern, die in der Ausgabe groesser als 200px sind
    if ($getMaxWidth > 200 && $gPreferences['photo_image_text'] !== '') {
        $font_c = imagecolorallocate($image->imageResource, 255, 255, 255);
        $font_ttf = THEME_SERVER_PATH . '/font.ttf';
        $font_s = $getMaxWidth / $gPreferences['photo_image_text_size'];
        $font_x = $font_s;
        $font_y = $image->imageHeight - $font_s;
        $text = $gPreferences['photo_image_text'];
        imagettftext($image->imageResource, $font_s, 0, $font_x, $font_y, $font_c, $font_ttf, $text);
    }
    // Rueckgabe des neuen Bildes
    header('Content-Type: ' . $image->getMimeType());
    $image->copyToBrowser();
コード例 #7
0
ファイル: ecard_function.php プロジェクト: sistlind/admidio
 /**
  * Diese Funktion ruft die Mail Klasse auf und uebergibt ihr die zu sendenden Daten
  * @param $senderName
  * @param $senderEmail
  * @param $ecardHtmlData   geparste Daten vom Template
  * @param $recipientName   der Name des Empfaengers
  * @param $recipientEmail  die Email des Empfaengers
  * @param $photoServerPath der Pfad wo die Bilder in der Grußkarte am Server liegen
  */
 public function sendEcard($senderName, $senderEmail, $ecardHtmlData, $recipientName, $recipientEmail, $photoServerPath)
 {
     global $gPreferences;
     $img_photo_path = '';
     $returnCode = true;
     $email = new Email();
     $email->setSender($senderEmail, $senderName);
     $email->setSubject($this->newMessageReceivedString);
     $email->addRecipient($recipientEmail, $recipientName);
     // alle Bilder werden aus dem Template herausgeholt, damit diese als Anhang verschickt werden koennen
     if (preg_match_all("/(<img.*src=\")(.*)(\".*>)/Uim", $ecardHtmlData, $matchArray)) {
         //$matchArray[0] = $this->deleteDoubleEntries($matchArray[0]);
         //$matchArray[2] = $this->deleteDoubleEntries($matchArray[2]);
         $matchArray[0] = array_unique($matchArray[0]);
         $matchArray[2] = array_unique($matchArray[2]);
         for ($i = 0; $i < count($matchArray[0]); ++$i) {
             // anstelle der URL muss nun noch der Server-Pfad gesetzt werden
             $img_server_path = str_replace(THEME_PATH, THEME_SERVER_PATH, $matchArray[2][$i]);
             $img_server_path = str_replace($GLOBALS['g_root_path'], SERVER_PATH, $img_server_path);
             // wird das Bild aus photo_show.php generiert, dann den uebergebenen Pfad zum Bild einsetzen
             if (strpos($img_server_path, 'photo_show.php') !== false) {
                 $img_server_path = $photoServerPath;
             }
             // Bildnamen und Typ ermitteln
             $img_name = substr(strrchr($img_server_path, '/'), 1);
             $img_type = substr(strrchr($img_name, '.'), 1);
             // das zu versendende eigentliche Bild, muss noch auf das entsprechende Format angepasst werden
             if (strpos($matchArray[2][$i], 'photo_show.php') !== false) {
                 $img_name = 'picture.' . $img_type;
                 $img_name_intern = substr(md5(uniqid($img_name . time())), 0, 8) . '.' . $img_type;
                 $img_server_path = SERVER_PATH . '/adm_my_files/photos/' . $img_name_intern;
                 $img_photo_path = $img_server_path;
                 $image_sized = new Image($photoServerPath);
                 $image_sized->scale($gPreferences['ecard_card_picture_width'], $gPreferences['ecard_card_picture_height']);
                 $image_sized->copyToFile(null, $img_server_path);
             }
             // Bild als Anhang an die Mail haengen
             if ($img_name !== 'none.jpg' && $img_name !== '') {
                 $uid = md5(uniqid($img_name . time()));
                 try {
                     $email->AddEmbeddedImage($img_server_path, $uid, $img_name, $encoding = 'base64', 'image/' . $img_type);
                 } catch (phpmailerException $e) {
                     $returnCode = $e->errorMessage();
                 }
                 $ecardHtmlData = str_replace($matchArray[2][$i], 'cid:' . $uid, $ecardHtmlData);
             }
         }
     }
     $email->setText($ecardHtmlData);
     $email->sendDataAsHtml();
     if ($returnCode == true) {
         $returnCode = $email->sendEmail();
     }
     // nun noch das von der Groesse angepasste Bild loeschen
     unlink($img_photo_path);
     return $returnCode;
 }
コード例 #8
0
ファイル: Image.class.php プロジェクト: gomezjsus/IAW
 /**
  * whitespace
  * 
  * Returns a scaled version of the image with any white space on the base filled with an image or a colour, depending on options specified
  *
  * @param string $x 
  * @param string $y 
  * @param string $options 
  * @return void
  * @access public
  * @author Dom Hastings
  */
 public function whitespace($x, $y, $options = array())
 {
     // merge in the options
     $options = array_merge_recursive_distinct(is_array($this->options['whitespace']) ? $this->options['whitespace'] : array(), is_array($options) ? $options : array());
     // if we're using an image background
     if (!empty($options['image'])) {
         // load it
         $orig = new Image($options['image']);
         $orig->scale($x, $y, array('force' => true));
         $dest = $orig->resource();
         // else if it's just a colour
     } elseif (!empty($options['color'])) {
         // create the base image
         $dest = imagecreatetruecolor($x, $y);
         // extract the int values of the colour
         list($r, $g, $b) = $this->hexToRGB($options['color']);
         // allocate the colour
         $color = imagecolorallocatealpha($dest, $r, $g, $b, $options['transparency']);
         // fill it
         imagefill($dest, 0, 0, $color);
         // else, we aren't keeping any whitespace, so just scale it
     } else {
         return $this->scale($x, $y);
     }
     // if scaling options have been set
     if (!empty($options['scaleX']) || !empty($options['scaleY'])) {
         // use them
         $scaleX = $options['scaleX'];
         $scaleY = $options['scaleY'];
         $options = array('force' => true);
     } else {
         // otherwise assume the passed options
         $scaleX = $x;
         $scaleY = $y;
         $options = array();
     }
     // scale the image
     $source = $this->scale($scaleX, $scaleY, $options);
     // extract the new height and width
     $scaleX = $this->currentX;
     $scaleY = $this->currentY;
     // determine the offset
     if (!isset($options['offsetX']) || !isset($options['offsetY'])) {
         $offsetX = intval($x / 2 - $scaleX / 2);
         $offsetY = intval($y / 2 - $scaleY / 2);
     } else {
         $offsetX = $options['offsetX'];
         $offsetY = $options['offsetY'];
     }
     // overlay it
     if (!imagecopy($dest, $source, $offsetX, $offsetY, 0, 0, $scaleX, $scaleY)) {
         throw new Exception('Image::scale: Error whitespacing image');
     }
     $this->current = $dest;
     return $dest;
 }
コード例 #9
0
ファイル: scaleimage.php プロジェクト: ricecake/JohnVanOrange
<?php

require_once '../settings.inc';
require_once ROOT_DIR . '/classes/image.class.php';
$db = new DB('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
$image = new Image();
$sql = 'SELECT filename,uid FROM images WHERE display=1';
$results = $db->fetch($sql);
foreach ($results as $result) {
    set_time_limit(360);
    echo 'Preparing image ' . $result['filename'] . "\n";
    try {
        $thumb = @$image->scale(array('image' => $result['uid']));
        file_put_contents(ROOT_DIR . '/media/thumbs/' . $result['filename'], $thumb);
        echo 'Thumb created for ' . $result['filename'] . "\n";
    } catch (ImagickException $e) {
        $log = $result['filename'] . ' ' . $e->getMessage() . "\n";
        file_put_contents('thumb.log', $log, FILE_APPEND);
        echo 'Error saving thumb for ' . $result['filename'] . "\n";
    }
}
コード例 #10
0
ファイル: imageTest.php プロジェクト: craftsmancoding/image
 public function testDistort()
 {
     // prep
     $src = dirname(__FILE__) . '/assets/E.jpg';
     $dst = dirname(__FILE__) . '/assets/E.400x100.jpg';
     if (file_exists($dst)) {
         unlink($dst);
     }
     $this->assertFalse(file_exists($dst));
     $result = Image::scale($src, $dst, 400, 100);
     $this->assertTrue(file_exists($dst));
     $this->assertEquals($result, $dst);
     $info = getimagesize($result);
     $this->assertFalse(empty($info));
     $this->assertEquals($info[0], 400);
     $this->assertEquals($info[1], 100);
     if (file_exists($dst)) {
         unlink($dst);
     }
 }