当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::rotate方法代码示例

本文整理汇总了PHP中Image::rotate方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::rotate方法的具体用法?PHP Image::rotate怎么用?PHP Image::rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::rotate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rotate

 public function rotate($degrees)
 {
     $image = new Image($this->get_image_path());
     $image->rotate($degrees);
     $image->save($this->get_image_path());
     $this->generate_thumb();
 }
开发者ID:kfdm-archive,项目名称:dev.kfdm.net,代码行数:7,代码来源:image.php

示例2: image

 public function image()
 {
     $image = new Image('http://sinastorage.com/sandbox/test.jpg');
     $image->rotate(50);
     $s3 = new S3();
     $result = $s3->plainWrite('test.jpg', $image->getContent(), $image->getSize(), $image->getMimeType());
     Common::debug($result);
 }
开发者ID:guojianing,项目名称:dagger2,代码行数:8,代码来源:DefaultController.php

示例3: saveChanges

 function saveChanges()
 {
     $_POST->setType('filename', 'string');
     $_POST->setType('cropimgx', 'numeric');
     $_POST->setType('cropimgy', 'numeric');
     $_POST->setType('cropimgw', 'numeric');
     $_POST->setType('cropimgh', 'numeric');
     $_REQUEST->setType('mkcopy', 'string');
     if ($_REQUEST['filename']) {
         if ($_REQUEST['mkcopy']) {
             if ($_POST['filename'] != $this->basename && $_POST['filename']) {
                 if (!file_exists($this->dirname . '/' . $_POST['filename'])) {
                     $p = $this->dirname . '/' . $_POST['filename'];
                 } else {
                     Flash::queue(__('File exists. Please give another name or delete the conflicting file. Your changes were not saved.'), 'warning');
                     break;
                 }
             } else {
                 $nrofcopies = count(glob(substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy*'));
                 if ($nrofcopies == 0) {
                     $nrofcopies = '';
                 }
                 $p = substr($this->path, 0, -(strlen($this->extension) + 1)) . '_copy' . ($nrofcopies + 1) . substr($this->path, -(strlen($this->extension) + 1));
             }
             touch($p);
             $copy = File::open($p);
         } else {
             if ($_POST['filename'] != $this->basename) {
                 $this->rename($_POST['filename']);
             }
             $p = $this->path;
             $img = new Image($this->path);
             if ($_POST['cropimgw'] && $_POST['cropimgh']) {
                 $width = $img->width();
                 $s = $width / min($width, 400);
                 $img->crop(round($s * $_POST['cropimgx']), round($s * $_POST['cropimgy']), round($s * $_POST['cropimgw']), round($s * $_POST['cropimgh']));
             }
             if ($_REQUEST['imgrot']) {
                 $img->rotate($_REQUEST['imgrot']);
             }
             $img->save($p);
             Flash::queue(__('Your changes were saved'));
         }
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:45,代码来源:ImageEditor.php

示例4: design

 function design($images, $border = '', $effect = '', $saveDir = '', $copyLast = false, $output = 'data')
 {
     $id = isset($images[0]['design']) && $images[0]['design'] ? $images[0]['design'] : mt_rand();
     $color = strlen($images[0]['color']) == 7 ? substr($images[0]['color'], 1) : $images[0]['color'];
     $new_image = ($saveDir ? $saveDir : 'cache/') . 'Design-' . $id . '.png';
     $path = '';
     $directories = explode('/', dirname(str_replace('../', '', $new_image)));
     foreach ($directories as $directory) {
         $path = $path . '/' . $directory;
         if (!file_exists(DIR_IMAGE . $path)) {
             @mkdir(DIR_IMAGE . $path, 0777);
         }
     }
     $image = new Image(DIR_IMAGE . $images[0]['src']);
     $width = $images[0]['width'];
     $height = $images[0]['height'];
     $image->resize($width, $height, '', $color);
     if ($images[0]['rotation']) {
         $image->rotate($images[0]['rotation'] * -1);
         $rotate = $images[0]['rotation'];
     }
     // Look for image Mask, to trim stuff outside the target area.
     $imagesrc = substr($images[0]['src'], 0, -4) . '-' . $images[0]['rotation'] . substr($images[0]['src'], -4);
     if (file_exists(DIR_IMAGE . $imagesrc)) {
         $images[0]['width'] = $image->getInfo('width');
         $images[0]['height'] = $image->getInfo('height');
         $images[0]['mask'] = 1;
         $images[0]['src'] = $imagesrc;
         $images[0]['rotation'] = 0;
     }
     if ($copyLast || isset($images[0]['mask'])) {
         // Cover the top of the image with the base image
         $images[0]['left'] = $images[0]['top'] = 0;
         $images[] = $images[0];
     }
     unset($images[0]);
     foreach ($images as $i => $img) {
         $image_temp = new Image(DIR_IMAGE . $img['src']);
         $size = isset($img['size']) && $img['size'] ? $img['size'] / 100 : 1;
         if ($img['type'] != 'text') {
             if (isset($images[$i]['crop']) && strpos($images[$i]['crop'], '/')) {
                 $crop = explode('/', $images[$i]['crop']);
                 $ratio = isset($crop[4]) ? $image_temp->getInfo('width') > $image_temp->getInfo('height') ? $image_temp->getInfo('width') / $crop[4] : $image_temp->getInfo('height') / $crop[4] : 1;
                 $image_temp->crop($crop[0] * $ratio, $crop[1] * $ratio, $crop[2] * $ratio, $crop[3] * $ratio);
             }
             $image_temp->resize($img['width'] * $size, $img['height'] * $size, isset($img['mask']) ? '' : $effect);
             if ($img['rotation']) {
                 $image_temp->rotate($img['rotation'] * -1);
             }
         } else {
             $image_temp->text($img['src'], $img['font'], DESIGN_TEXT_DEFAULT_SIZE * $size, DESIGN_FONT_COLOR, '', $img['rotation'] * -1);
         }
         $imgLeft = isset($img['left']) ? (int) $img['left'] : 0;
         $imgTop = isset($img['top']) ? (int) $img['top'] : 0;
         $opacity = $img['type'] != 'mainProduct' ? 80 : 100;
         $image->merge($image_temp->getResource(), $imgLeft, $imgTop, $opacity);
     }
     /*if ($rotate) {
     		$image->rotate($rotate);
     		$cx = $image->getInfo('width')/2;
     		$cy = $image->getInfo('height')/2;
     		$image->crop($cx - ($width/2),$cy - ($height/2), $cx + ($width/2),$cy + ($height/2));
     		$image->rotate($rotate*-1);*/
     $width = $image->getInfo('width');
     $height = $image->getInfo('height');
     //}
     $image->resize($width, $height, $border, $color);
     if ($output == 'data') {
         return $image->getData(DIR_IMAGE . $new_image);
     } else {
         $image->save(DIR_IMAGE . $new_image);
         if ($this->request->server['HTTPS']) {
             return $this->config->get('config_ssl') . 'image/' . $new_image;
         } else {
             return $this->config->get('config_url') . 'image/' . $new_image;
         }
     }
 }
开发者ID:AvanOsch,项目名称:ImagEngine,代码行数:78,代码来源:image.php

示例5: uniqid

         if (!$image->resize($_POST['width'], $_POST['height'], !empty($_POST['constraint']) ? true : false)) {
             $error = IMG_SAVE_RESIZE_FAILED;
         }
         break;
     case "crop":
         if (!$image->crop($_POST['x'], $_POST['y'], $_POST['width'], $_POST['height'])) {
             $error = IMG_SAVE_CROP_FAILED;
         }
         break;
     case "flip":
         if (!$image->flip($_POST['flip_angle'])) {
             $error = IMG_SAVE_FLIP_FAILED;
         }
         break;
     case "rotate":
         if (!$image->rotate(intval($_POST['angle']))) {
             $error = IMG_SAVE_ROTATE_FAILED;
         }
         break;
     default:
         $error = IMG_SAVE_UNKNOWN_MODE;
 }
 if (empty($error)) {
     $sessionNewPath = $sessionDir . uniqid(md5(time())) . "." . getFileExt($_POST['path']);
     if (!@copy($originalImage, $sessionNewPath)) {
         //keep a copy under the session folder
         $error = IMG_SAVE_BACKUP_FAILED;
     } else {
         $isSaveAsRequest = !empty($_POST['new_name']) && !empty($_POST['save_to']) ? true : false;
         //save the modified image
         $sessionImageInfo = array('name' => basename($sessionNewPath), 'restorable' => 1);
开发者ID:naneri,项目名称:Osclass,代码行数:31,代码来源:ajax_image_save.php

示例6: changeImage

function changeImage(&$im, $data)
{
    $image = new Image();
    foreach ($data as $action => $val) {
        switch ($action) {
            case 'rotate':
                $image->rotate($im, $val);
                break;
            case 'size':
                $image->resize($im, $val);
                break;
            case 'filter':
                $image->filter($im, $val);
                break;
        }
    }
}
开发者ID:Amadeus1998,项目名称:pictshare,代码行数:17,代码来源:core.php

示例7: uniqid

         if (!$image->resize($_POST['width'], $_POST['height'], !empty($_POST['constraint']) ? true : false)) {
             $error = IMG_SAVE_RESIZE_FAILED;
         }
         break;
     case "crop":
         if (!$image->cropToDimensions($_POST['x'], $_POST['y'], (int) $_POST['x'] + (int) $_POST['width'], (int) $_POST['y'] + (int) $_POST['height'])) {
             $error = IMG_SAVE_CROP_FAILED;
         }
         break;
     case "flip":
         if (!$image->flip($_POST['flip_angle'])) {
             $error = IMG_SAVE_FLIP_FAILED;
         }
         break;
     case "rotate":
         if (!$image->rotate((int) $_POST['angle'])) {
             $error = IMG_SAVE_ROTATE_FAILED;
         }
         break;
     default:
         $error = IMG_SAVE_UNKNOWN_MODE;
 }
 if (empty($error)) {
     $sessionNewPath = $session->getSessionDir() . uniqid(md5(time())) . "." . getFileExt($_POST['path']);
     if (!@copy($_POST['path'], $sessionNewPath)) {
         $error = IMG_SAVE_BACKUP_FAILED;
     } else {
         addSessionHistory($_POST['path'], $sessionNewPath);
         if ($image->saveImage($_POST['path'])) {
             $imageInfo = $image->getFinalImageInfo();
             $info .= ",width:" . $imageInfo['width'] . "\n";
开发者ID:greench,项目名称:prestashop,代码行数:31,代码来源:ajax_editor_reset.php

示例8: TablePhotos

        $photo_album->setValue('pho_quantity', $photo_album->getValue('pho_quantity') - 1);
        $photo_album->save();
    }
}
// Foto um 90° drehen
if ($getJob === 'rotate') {
    // nur bei gueltigen Uebergaben weiterarbeiten
    if ($getDirection !== '') {
        // Aufruf des ggf. uebergebenen Albums
        $photo_album = new TablePhotos($gDb, $getPhotoId);
        // Thumbnail loeschen
        deleteThumbnail($photo_album, $getPhotoNr);
        // Ordnerpfad zusammensetzen
        $photo_path = SERVER_PATH . '/adm_my_files/photos/' . $photo_album->getValue('pho_begin', 'Y-m-d') . '_' . $photo_album->getValue('pho_id') . '/' . $getPhotoNr . '.jpg';
        // Bild drehen
        $image = new Image($photo_path);
        $image->rotate($getDirection);
        $image->delete();
    }
} elseif ($getJob === 'delete') {
    // das entsprechende Bild wird physikalisch und in der DB geloescht
    deletePhoto($getPhotoId, $getPhotoNr);
    // Neu laden der Albumdaten
    $photo_album = new TablePhotos($gDb);
    if ($getPhotoId > 0) {
        $photo_album->readDataById($getPhotoId);
    }
    $_SESSION['photo_album'] = $photo_album;
    // Loeschen erfolgreich -> Rueckgabe fuer XMLHttpRequest
    echo 'done';
}
开发者ID:martinbrylski,项目名称:admidio,代码行数:31,代码来源:photo_function.php

示例9: Image

<?php

include '../class.Images.php';
//Create a new object, send relative or absolut path to your image
$image = new Image('../test/image1.png');
//We can rotate the image
$image->rotate(90);
//and we can resize and crop it to have a nice thumbnail
$image->resize(150, 150, 'crop');
//lets see what we have!
$image->display();
开发者ID:hd132624,项目名称:class.Images.php,代码行数:11,代码来源:example1.php

示例10: image_special

 public function image_special($APP)
 {
     $FILE = $APP->get('POST.f');
     $PREVIEW = $APP->get('POST.p');
     $SPECIALE = $APP->get('POST.e');
     $HEIGHT = $APP->get('POST.h');
     $WIDTH = $APP->get('POST.w');
     $PATH_PARTS = pathinfo($APP->get('UPLOADS') . $FILE);
     $APP->set('FILE_EXTENSION', strtolower($PATH_PARTS['extension']));
     $APP->set('FILE_FILENAME', $PATH_PARTS['filename']);
     $PROCESS_FILTER = '';
     if ($APP->get('FILE_EXTENSION') == 'jpg') {
         $PROCESS_FILTER = 'jpeg';
     } else {
         if ($APP->get('FILE_EXTENSION') == 'gif') {
             $PROCESS_FILTER = 'gif';
         } else {
             if ($APP->get('FILE_EXTENSION') == 'png') {
                 $PROCESS_FILTER = 'png';
             } else {
                 if ($APP->get('FILE_EXTENSION') == 'wbmp') {
                     $PROCESS_FILTER = 'wbmp';
                 }
             }
         }
     }
     if ($APP->get('FILE_EXTENSION') == 'png' || $APP->get('FILE_EXTENSION') == 'jpg' || $APP->get('FILE_EXTENSION') == 'jpeg' || $APP->get('FILE_EXTENSION') == 'gif' || $APP->get('FILE_EXTENSION') == 'wbmp') {
         $img = new Image($FILE, false, $APP->get('UPLOADS'));
         $IMAGE_WIDTH = 0;
         $IMAGE_HEIGHT = 0;
         $IMAGE_WIDTH = $img->width();
         $IMAGE_HEIGHT = $img->height();
         if ($HEIGHT && $WIDTH && $HEIGHT != $IMAGE_HEIGHT && $WIDTH != $IMAGE_WIDTH) {
             $img->resize($WIDTH, $HEIGHT, false, false);
         }
         switch ($SPECIALE) {
             case 'invert':
                 $img->invert();
                 break;
             case 'grayscale':
                 $img->grayscale();
                 break;
             case 'emboss':
                 $img->emboss();
                 break;
             case 'sepia':
                 $img->sepia();
                 break;
             case 'pixelate':
                 $img->pixelate(10);
                 break;
             case 'rotate90':
                 $img->rotate(-90);
                 break;
             case 'rotate180':
                 $img->rotate(-180);
                 break;
             case 'rotate270':
                 $img->rotate(-270);
                 break;
             case 'hflip':
                 $img->hflip();
                 break;
             case 'vflip':
                 $img->vflip();
                 break;
             case 'origin':
                 echo $APP->get('CONSTRUCTR_BASE_URL') . '/UPLOADS/' . $FILE;
                 die;
                 break;
         }
         $img->save();
         $TS = time();
         @file_put_contents($APP->get('UPLOADS') . 'TMP/' . $TS . '.png', $img->dump($PROCESS_FILTER));
         echo $APP->get('CONSTRUCTR_BASE_URL') . '/UPLOADS/TMP/' . $TS . '.png';
     }
 }
开发者ID:phaziz,项目名称:ConstructrCMS-3,代码行数:77,代码来源:ConstructrUploads.php

示例11: rotate

 /**
  * wrapper to rotate() method of class.Images.php
  **/
 public function rotate($source, $destination, $degrees = 90)
 {
     $dest_path = pathinfo($destination, PATHINFO_DIRNAME);
     $dest_file = pathinfo($destination, PATHINFO_FILENAME);
     $image = new Image($source);
     $image->setPathToTempFiles(CAT_PATH . '/temp');
     $image->rotate(90, 100);
     return $image->save($dest_file, $dest_path);
 }
开发者ID:ircoco,项目名称:BlackCatCMS,代码行数:12,代码来源:Image.php

示例12: getConvertedImage

 /**
  * Get a modified image from cache (or create it if it's not available in the cache)
  * @param integer $width The wished width of the image
  * @param integer $height The wished height of the image
  * @return array An array with valid [width,height]
  */
 function getConvertedImage($width, $height, $rot, $tr, $tg, $tb, $return_blob = false)
 {
     global $CONFIG;
     list($width, $height) = $this->getValidImageDimensions($width, $height);
     $cpDir = $this->rootDir();
     if (!is_dir($cpDir . '/.cache')) {
         mkdir($cpDir . '/.cache', 0700);
     }
     $cacheDir = realpath($cpDir . '/.cache');
     $cacheName = $this->ID . '_' . $width . 'x' . $height . '_' . $tr . 'r' . $tg . 'g' . $tb . 'b' . '_' . 'r' . $rot . '_' . filemtime($this->path) . '.' . $this->extension;
     $cachePath = $cacheDir . DIRECTORY_SEPARATOR . $cacheName;
     if (!is_file($cachePath)) {
         if (function_exists("gd_info")) {
             $olderFiles = glob($cacheDir . $this->ID . '_' . $width . 'x' . $height . '_' . $tr . 'r' . $tg . 'g' . $tb . 'b' . '_' . 'r' . $rot . '_*');
             $copies = glob($cacheDir . $this->ID . '_*');
             $max = $CONFIG->Files->Imagecopies;
             if (!is_numeric($max)) {
                 $CONFIG->Files->Imagecopies = $max = 5;
             }
             if (count($copies) >= $max) {
                 shuffle($copies);
                 $olderFiles += array_slice($copies, $max - 1);
             }
             foreach ($olderFiles as $oldFile) {
                 unlink($oldFile);
             }
             /**
              * Create modified image
              **/
             $img = new Image($this->path);
             if ($img->width > $width || $img->height > $height) {
                 $img->resize($width, $height);
             }
             if ($tr !== false || $tg !== false || $tb !== false) {
                 $img->tint($tr, $tg, $tb);
             }
             if ($rot != false) {
                 $img->rotate($rot);
             }
             $img->save($cachePath);
         } else {
             $cachePath = $this->path;
         }
     } elseif ($return_blob) {
         $img = new Image($cachePath);
     }
     if ($return_blob) {
         return array($cachePath, $img->blob());
     }
     return $cachePath;
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:57,代码来源:File.php

示例13: testRotateCCW

 public function testRotateCCW()
 {
     // prep
     $src = dirname(__FILE__) . '/assets/rotate90.jpg';
     $info_before = getimagesize($src);
     $result = Image::rotate($src, 90, false);
     $this->assertTrue(file_exists($src));
     $this->assertEquals($result, $src);
     $info_after = getimagesize($result);
     $this->assertNotEquals($info_before[3], $info_after[3]);
 }
开发者ID:craftsmancoding,项目名称:image,代码行数:11,代码来源:imageTest.php


注:本文中的Image::rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。