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


PHP PelJpeg::load方法代码示例

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


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

示例1: testThisDoesNotWorkAsExpected

 function testThisDoesNotWorkAsExpected()
 {
     $subject = "Превед, медвед!";
     $data = new PelDataWindow(file_get_contents($this->file));
     if (PelJpeg::isValid($data)) {
         $jpeg = new PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if (null == $exif) {
             $exif = new PelExif();
             $jpeg->setExif($exif);
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         }
         $tiff = $exif->getTiff();
         $ifd0 = $tiff->getIfd();
         if (null == $ifd0) {
             $ifd0 = new PelIfd(PelIfd::IFD0);
             $tiff->setIfd($ifd0);
         }
     }
     $ifd0->addEntry(new PelEntryWindowsString(PelTag::XP_SUBJECT, $subject));
     file_put_contents($this->file, $jpeg->getBytes());
     $jpeg = new PelJpeg($this->file);
     $exif = $jpeg->getExif();
     $tiff = $exif->getTiff();
     $ifd0 = $tiff->getIfd();
     $written_subject = $ifd0->getEntry(PelTag::XP_SUBJECT);
     $this->assertEqual($subject, $written_subject->getValue());
 }
开发者ID:ni-c,项目名称:pel,代码行数:30,代码来源:gh-16.php

示例2: saveEdit

 public function saveEdit($file, $name, $options = array(), $quality = 100)
 {
     // Check for request forgeries
     WFToken::checkToken() or die('Access to this resource is restricted');
     // check for image editor access
     if ($this->checkAccess('image_editor', 1) === false) {
         JError::raiseError(403, 'Access to this resource is restricted');
     }
     $browser = $this->getBrowser();
     $filesystem = $browser->getFileSystem();
     // check file
     self::validateImagePath($file);
     // clean temp
     $this->cleanEditorTmp($file, false);
     // check new name
     self::validateImagePath($name);
     $upload = JRequest::getVar('file', '', 'files', 'array');
     // create a filesystem result object
     $result = new WFFileSystemResult();
     if (isset($upload) && isset($upload['tmp_name']) && is_uploaded_file($upload['tmp_name'])) {
         $tmp = $upload['tmp_name'];
         self::validateImageFile($tmp);
         $exif = null;
         // get exif data from orignal file
         if (preg_match('#\\.jp(eg|g)$#i', basename($file)) && basename($file) == basename($name)) {
             // load exif classes
             require_once dirname(__FILE__) . '/pel/PelJpeg.php';
             $src = WFUtility::makePath($filesystem->getBaseDir(), $file);
             $jpeg = new PelJpeg($src);
             $exif = $jpeg->getExif();
         }
         $result = $filesystem->upload('multipart', trim($tmp), dirname($file), basename($name));
         if ($result->state === true && $exif) {
             $pel = new PelDataWindow($result->path);
             if (PelJpeg::isValid($pel)) {
                 $jpeg = new PelJpeg();
                 $jpeg->load($pel);
                 $jpeg->setExif($exif);
                 //$jpeg->saveFile($result->path);
                 // write to file
                 JFile::write($result->path, $jpeg->getBytes());
             }
         }
         @unlink($tmp);
     } else {
         // set upload as false - JSON request
         $upload = false;
         $file = WFUtility::makePath($filesystem->getBaseDir(), $file);
         $dest = dirname($file) . '/' . basename($name);
         // get extension
         $ext = WFUtility::getExtension($dest);
         // load image class
         require_once dirname(__FILE__) . '/image/image.php';
         // create image
         $image = new WFImage($file, $this->getParam('prefer_imagick', true));
         foreach ($options as $filter) {
             if (isset($filter->task)) {
                 $args = isset($filter->args) ? (array) $filter->args : array();
                 switch ($filter->task) {
                     case 'resize':
                         $w = $args[0];
                         $h = $args[1];
                         $image->resize($w, $h);
                         break;
                     case 'crop':
                         $w = $args[0];
                         $h = $args[1];
                         $x = $args[2];
                         $y = $args[3];
                         $image->crop($w, $h, $x, $y);
                         break;
                     case 'rotate':
                         $image->rotate(array_shift($args));
                         break;
                     case 'flip':
                         $image->flip(array_shift($args));
                         break;
                     default:
                         $image->filter($filter->task, $args);
                         break;
                 }
             }
         }
         // get image data
         $data = $image->toString($ext);
         // write to file
         if ($data) {
             $result->state = (bool) @JFile::write($dest, $data);
         }
         // set path
         $result->path = $dest;
     }
     if ($result->state === true) {
         // check if its a valid image
         if (@getimagesize($result->path) === false) {
             JFile::delete($result->path);
             throw new InvalidArgumentException('Invalid image file');
         } else {
             $result->path = str_replace(WFUtility::cleanPath(JPATH_SITE), '', $result->path);
             $browser->setResult(WFUtility::cleanPath($result->path, '/'), 'files');
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:imgmanager.php

示例3: println

    println('Usage: %s [-d] <file> ...', $prog);
    println('Optional arguments:');
    println('  -d        turn debug output on.');
    println('Mandatory arguments:');
    println('  file ...  one or more file names.');
    exit(1);
}
/* We typically need lots of RAM to parse TIFF images since they tend
 * to be big and uncompressed. */
ini_set('memory_limit', '32M');
foreach ($argv as $file) {
    println('Reading file "%s".', $file);
    $data = new PelDataWindow(file_get_contents($file));
    if (PelJpeg::isValid($data)) {
        $jpeg = new PelJpeg();
        $jpeg->load($data);
        $app1 = $jpeg->getExif();
        if ($app1 == null) {
            println('Skipping %s because no APP1 section was found.', $file);
            continue;
        }
        $tiff = $app1->getTiff();
    } elseif (PelTiff::isValid($data)) {
        $tiff = new PelTiff($data);
    } else {
        println('Unrecognized image format! Skipping.');
        continue;
    }
    $ifd0 = $tiff->getIfd();
    $entry = $ifd0->getEntry(PelTag::DATE_TIME);
    if ($entry == null) {
开发者ID:kbrack1,项目名称:UptoBox,代码行数:31,代码来源:dirsort.php

示例4: exifOrientation

 public function exifOrientation($input_file, $output_file)
 {
     $data = new PelDataWindow(file_get_contents($input_file));
     if (PelJpeg::isValid($data)) {
         $jpeg = new PelJpeg();
         $jpeg->load($data);
         if ($jpeg != null) {
             $exif = $jpeg->getExif();
             if ($exif != null) {
                 $tiff = $exif->getTiff();
                 if ($tiff != null) {
                     $ifd0 = $tiff->getIfd();
                     if ($ifd0 != null) {
                         $orientation = $ifd0->getEntry(PelTag::ORIENTATION);
                         $orientation->setValue(0);
                         $sEXIF_description = "Picture rotated automatically.";
                         $description = $ifd0->getEntry(PelTag::IMAGE_DESCRIPTION);
                         if ($description == null) {
                             $description = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $sEXIF_description);
                             $ifd0->addEntry($description);
                         } else {
                             $sEXIF_description_old = $description->getValue();
                             $description->setValue($sEXIF_description);
                         }
                         file_put_contents($output_file, $jpeg->getBytes());
                     }
                 }
             }
         }
     }
 }
开发者ID:hevelmo,项目名称:templates,代码行数:31,代码来源:axZmH.class.php

示例5: saveEdit

 function saveEdit()
 {
     // check for image editor access
     if (!$this->checkAccess('image_editor', 1)) {
         JError::raiseError(403, 'RESTRICTED ACCESS');
     }
     $editor = $this->getImageEditor();
     $browser = $this->getBrowser();
     $args = func_get_args();
     // file src
     $file = array_shift($args);
     // check file
     WFUtility::checkPath($file);
     // file name
     $name = array_shift($args);
     // check name
     WFUtility::checkPath($name);
     // check for extension in destination name
     if (preg_match('#\\.(php|php(3|4|5)|phtml|pl|py|jsp|asp|htm|html|shtml|sh|cgi)\\b#i', $name)) {
         JError::raiseError(403, 'INVALID FILE NAME');
     }
     // edit data
     $props = array_shift($args);
     // exif data
     $exif = null;
     $data = JRequest::getVar('data', '', 'POST', 'STRING', JREQUEST_ALLOWRAW);
     if (preg_match('#data:image\\/(jpeg|jpg|png|bmp);base64#', $data)) {
         // replace spaces
         $data = str_replace(' ', '+', $data);
         // remove header
         $data = substr($data, strpos($data, ",") + 1);
         // decode data
         $data = base64_decode($data);
         $src = WFUtility::makePath(JPATH_SITE, $file);
         $dest = dirname($src) . DS . basename($name);
         // get exif data from orignal file
         if (preg_match('#\\.jp(eg|g)$#i', basename($file)) && basename($file) == basename($dest)) {
             // load exif classes
             require_once dirname(__FILE__) . DS . 'pel' . DS . 'PelJpeg.php';
             $jpeg = new PelJpeg($src);
             $exif = $jpeg->getExif();
         }
         if (!JFile::write($dest, $data)) {
             $browser->setResult(WFText::_('WF_IMGMANAGER_EXT_ERROR'), 'error');
         } else {
             $browser->setResult(basename($dest), 'files');
             if ($exif && basename($file) == basename($dest)) {
                 $pel = new PelDataWindow($data);
                 if (PelJpeg::isValid($pel)) {
                     $jpeg = new PelJpeg();
                     $jpeg->load($pel);
                     /*$dim = @getimagesize($dest);
                     		
                     					if ($dim) {
                     					$tiff 	= $exif->getTiff();
                     					$ifd0 	= $tiff->getIfd();
                     		
                     					$width 	= $ifd0->getEntry(PelTag::IMAGE_WIDTH);
                     					$height	= $ifd0->getEntry(PelTag::IMAGE_LENGTH);
                     		
                     					$width->setValue($dim[0]);
                     					$height->setValue($dim[1]);
                     					}*/
                     $jpeg->setExif($exif);
                     $jpeg->saveFile($dest);
                 }
             }
         }
     } else {
         $browser->setResult(WFText::_('WF_IMGMANAGER_EXT_ERROR'), 'error');
     }
     return $browser->getResult();
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:73,代码来源:imgmanager.php


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