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


PHP PelJpeg::getBytes方法代码示例

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


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

示例1: addGpsInfo

/**
 * Add GPS information to an image basic metadata. Any old Exif data
 * is discarded.
 *
 * @param string the input filename.
 *
 * @param string the output filename. An updated copy of the input
 * image is saved here.
 *
 * @param string image description.
 *
 * @param string user comment.
 *
 * @param string camera model.
 *
 * @param float longitude expressed as a fractional number of degrees,
 * e.g. 12.345°. Negative values denotes degrees west of Greenwich.
 *
 * @param float latitude expressed as for longitude. Negative values
 * denote degrees south of equator.
 *
 * @param float the altitude, negative values express an altitude
 * below sea level.
 *
 * @param string the date and time.
 */
function addGpsInfo($input, $output, $description, $comment, $model, $longitude, $latitude, $altitude, $date_time)
{
    /* Load the given image into a PelJpeg object */
    $jpeg = new PelJpeg($input);
    /* Create and add empty Exif data to the image (this throws away any
     * old Exif data in the image). */
    $exif = new PelExif();
    $jpeg->setExif($exif);
    /* Create and add TIFF data to the Exif data (Exif data is actually
     * stored in a TIFF format). */
    $tiff = new PelTiff();
    $exif->setTiff($tiff);
    /* Create first Image File Directory and associate it with the TIFF
     * data. */
    $ifd0 = new PelIfd(PelIfd::IFD0);
    $tiff->setIfd($ifd0);
    /* Create a sub-IFD for holding GPS information. GPS data must be
     * below the first IFD. */
    $gps_ifd = new PelIfd(PelIfd::GPS);
    $ifd0->addSubIfd($gps_ifd);
    /* The USER_COMMENT tag must be put in a Exif sub-IFD under the
     * first IFD. */
    $exif_ifd = new PelIfd(PelIfd::EXIF);
    $exif_ifd->addEntry(new PelEntryUserComment($comment));
    $ifd0->addSubIfd($exif_ifd);
    $inter_ifd = new PelIfd(PelIfd::INTEROPERABILITY);
    $ifd0->addSubIfd($inter_ifd);
    $ifd0->addEntry(new PelEntryAscii(PelTag::MODEL, $model));
    $ifd0->addEntry(new PelEntryAscii(PelTag::DATE_TIME, $date_time));
    $ifd0->addEntry(new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description));
    $gps_ifd->addEntry(new PelEntryByte(PelTag::GPS_VERSION_ID, 2, 2, 0, 0));
    /* Use the convertDecimalToDMS function to convert the latitude from
     * something like 12.34° to 12° 20' 42" */
    list($hours, $minutes, $seconds) = convertDecimalToDMS($latitude);
    /* We interpret a negative latitude as being south. */
    $latitude_ref = $latitude < 0 ? 'S' : 'N';
    $gps_ifd->addEntry(new PelEntryAscii(PelTag::GPS_LATITUDE_REF, $latitude_ref));
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_LATITUDE, $hours, $minutes, $seconds));
    /* The longitude works like the latitude. */
    list($hours, $minutes, $seconds) = convertDecimalToDMS($longitude);
    $longitude_ref = $longitude < 0 ? 'W' : 'E';
    $gps_ifd->addEntry(new PelEntryAscii(PelTag::GPS_LONGITUDE_REF, $longitude_ref));
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_LONGITUDE, $hours, $minutes, $seconds));
    /* Add the altitude. The absolute value is stored here, the sign is
     * stored in the GPS_ALTITUDE_REF tag below. */
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_ALTITUDE, array(abs($altitude), 1)));
    /* The reference is set to 1 (true) if the altitude is below sea
     * level, or 0 (false) otherwise. */
    $gps_ifd->addEntry(new PelEntryByte(PelTag::GPS_ALTITUDE_REF, (int) ($altitude < 0)));
    /* Finally we store the data in the output file. */
    file_put_contents($output, $jpeg->getBytes());
}
开发者ID:ni-c,项目名称:pel,代码行数:78,代码来源:gps.php

示例2: addGPSdata

function addGPSdata($infile, $outfile, $GPS_lat, $GPS_lon, $GPS_alt)
{
    try {
        $image = new PelJpeg($infile);
    } catch (Exception $exc) {
        return -1;
    }
    if ($image instanceof PelJpeg) {
        if ($image->isValid(new PelDataWindow($image->getBytes()))) {
            $exif = $image->getExif();
            if ($exif == null) {
                $exif = new PelExif();
                $image->setExif($exif);
                $exif->setTiff(new PelTiff());
            }
            $tiff = $exif->getTiff();
            $ifd0 = $tiff->getIfd();
            if ($ifd0 == null) {
                $ifd0 = new PelIFD(PelIfd::IFD0);
                $tiff->setIfd($ifd0);
            }
            /* Tags erzeugen */
            $subifd = new PelIfd(PelIfd::GPS);
            $GPS_latref = $GPS_lat < 0 ? "S" : "N";
            $GPS_lonref = $GPS_lon < 0 ? "W" : "E";
            $GPS_altref = $GPS_alt < 0 ? 1 : 0;
            list($degrees, $minutes, $milliseconds) = dec2dms(abs($GPS_lat));
            $gpslat = new PelEntryRational(PelTag::GPS_LATITUDE, array($degrees, 1), array($minutes, 1), array($milliseconds, 1000));
            list($degrees, $minutes, $milliseconds) = dec2dms(abs($GPS_lon));
            $gpslon = new PelEntryRational(PelTag::GPS_LONGITUDE, array($degrees, 1), array($minutes, 1), array($milliseconds, 1000));
            echo $GPS_alt * 1000;
            $gpsalt = new PelEntryRational(PelTag::GPS_ALTITUDE, array(abs($GPS_alt * 1000), 1000));
            $gpslatref = new PelEntryAscii(PelTag::GPS_LATITUDE_REF, $GPS_latref);
            $gpslonref = new PelEntryAscii(PelTag::GPS_LONGITUDE_REF, $GPS_lonref);
            $gpsaltref = new PelEntryByte(PelTag::GPS_ALTITUDE_REF, $GPS_altref);
            $gpsversion = new PelEntryByte(PelTag::GPS_VERSION_ID, 2, 2, 0, 0);
            /* Daten eintragen.*/
            $subifd->addEntry($gpsversion);
            $subifd->addEntry($gpslat);
            $subifd->addEntry($gpslon);
            $subifd->addEntry($gpsalt);
            $subifd->addEntry($gpslatref);
            $subifd->addEntry($gpslonref);
            $subifd->addEntry($gpsaltref);
            $ifd0->addSubIfd($subifd);
            file_put_contents($outfile, $image->getBytes());
            return 0;
        }
    }
    return -1;
}
开发者ID:BackupTheBerlios,项目名称:pic2base-svn,代码行数:51,代码来源:exif.php

示例3: 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

示例4: tempnam

 static function rotate_item($item)
 {
     require_once MODPATH . 'autorotate/lib/pel/PelDataWindow.php';
     require_once MODPATH . 'autorotate/lib/pel/PelJpeg.php';
     require_once MODPATH . 'autorotate/lib/pel/PelTiff.php';
     // Only try to rotate photos based on EXIF
     if ($item->is_photo() && $item->mime_type == "image/jpeg") {
         require_once MODPATH . "exif/lib/exif.php";
         $exif_raw = read_exif_data_raw($item->file_path(), false);
         if (isset($exif_raw['ValidEXIFData'])) {
             $orientation = $exif_raw["IFD0"]["Orientation"];
             $degrees = 0;
             if ($orientation == '3: Upside-down') {
                 $degrees = 180;
             } else {
                 if ($orientation == '8: 90 deg CW') {
                     $degrees = -90;
                 } else {
                     if ($orientation == '6: 90 deg CCW') {
                         $degrees = 90;
                     }
                 }
             }
             if ($degrees) {
                 $tmpfile = tempnam(TMPPATH, "rotate");
                 gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees));
                 // Update EXIF info
                 $data = new PelDataWindow(file_get_contents($tmpfile));
                 if (PelJpeg::isValid($data)) {
                     $jpeg = $file = new PelJpeg();
                     $jpeg->load($data);
                     $exif = $jpeg->getExif();
                     if ($exif !== null) {
                         $tiff = $exif->getTiff();
                         $ifd0 = $tiff->getIfd();
                         $orientation = $ifd0->getEntry(PelTag::ORIENTATION);
                         $orientation->setValue(1);
                         file_put_contents($tmpfile, $file->getBytes());
                     }
                 }
                 $item->set_data_file($tmpfile);
                 $item->save();
                 unlink($tmpfile);
             }
         }
     }
     return;
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:48,代码来源:autorotate.php

示例5: testThisDoesNotWorkAsExpected

 function testThisDoesNotWorkAsExpected()
 {
     $tmpfile = dirname(__FILE__) . '/images/bug1730993_tmp.jpg';
     $bigfile = dirname(__FILE__) . '/images/bug1730993_large.jpg';
     try {
         $jpeg = new PelJpeg($tmpfile);
         // the error occurs here
         $exif = $jpeg->getExif();
         if ($exif != null) {
             $jpeg1 = new PelJpeg($bigfile);
             $jpeg1->setExif($exif);
             file_put_contents($bigfile, $jpeg1->getBytes());
         }
     } catch (Exception $e) {
         $this->fail('Test should not throw an exception');
     }
 }
开发者ID:kbrack1,项目名称:UptoBox,代码行数:17,代码来源:bug1730993.php

示例6: testThisDoesNotWorkAsExpected

 function testThisDoesNotWorkAsExpected()
 {
     $filename = dirname(__FILE__) . '/images/bug3017880.jpg';
     try {
         $exif = null;
         $success = 1;
         // return true by default, as this function may not resave the file, but it's still success
         $resave_file = 0;
         $jpeg = new PelJpeg($filename);
         // should all exif data on photo be cleared (gd and iu will always strip it anyway, so only
         // force strip if you know the image you're branding is an original)
         //$jpeg->clearExif();
         if ($exif === null) {
             $exif = new PelExif();
             $jpeg->setExif($exif);
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         }
         $tiff = $exif->getTiff();
         $ifd0 = $tiff->getIfd();
         if ($ifd0 == null) {
             $ifd0 = new PelIfd(PelIfd::IFD0);
             $tiff->setIfd($ifd0);
         }
         $software_name = 'Example V2';
         $software = $ifd0->getEntry(PelTag::SOFTWARE);
         if ($software == null) {
             $software = new PelEntryAscii(PelTag::SOFTWARE, $software_name);
             $ifd0->addEntry($software);
             $resave_file = 1;
             echo 'null';
         } else {
             $software->setValue($software_name);
             $resave_file = 1;
             echo 'update';
         }
         if ($resave_file == 1 && !file_put_contents($filename, $jpeg->getBytes())) {
             // if it was okay to resave the file, but it did not save correctly
             $success = 0;
         }
     } catch (Exception $e) {
         $this->fail('Test should not throw an exception');
     }
 }
开发者ID:ni-c,项目名称:pel,代码行数:44,代码来源:bug3017880.php

示例7: testThisDoesNotWorkAsExpected

 function testThisDoesNotWorkAsExpected()
 {
     $scale = 0.75;
     $input_jpeg = new PelJpeg($this->file);
     $original = ImageCreateFromString($input_jpeg->getBytes());
     $original_w = ImagesX($original);
     $original_h = ImagesY($original);
     $scaled_w = $original_w * $scale;
     $scaled_h = $original_h * $scale;
     $scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
     ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
     $output_jpeg = new PelJpeg($scaled);
     $exif = $input_jpeg->getExif();
     if ($exif != null) {
         $output_jpeg->setExif($exif);
     }
     file_put_contents($this->file, $output_jpeg->getBytes());
     $jpeg = new PelJpeg($this->file);
     $exifin = $jpeg->getExif();
     $this->assertEqual($exif, $exifin);
 }
开发者ID:ni-c,项目名称:pel,代码行数:21,代码来源:gh-21.php

示例8: testWriteRead

 function testWriteRead()
 {
     Pel::setStrictParsing(true);
     $ifd = new PelIfd(PelIfd::IFD0);
     $this->assertTrue($ifd->isLastIfd());
     foreach ($this->entries as $entry) {
         $ifd->addEntry($entry);
     }
     $tiff = new PelTiff();
     $this->assertNull($tiff->getIfd());
     $tiff->setIfd($ifd);
     $this->assertNotNull($tiff->getIfd());
     $exif = new PelExif();
     $this->assertNull($exif->getTiff());
     $exif->setTiff($tiff);
     $this->assertNotNull($exif->getTiff());
     $jpeg = new PelJpeg(dirname(__FILE__) . '/no-exif.jpg');
     $this->assertNull($jpeg->getExif());
     $jpeg->setExif($exif);
     $this->assertNotNull($jpeg->getExif());
     file_put_contents('test-output.jpg', $jpeg->getBytes());
     $this->assertTrue(file_exists('test-output.jpg'));
     $this->assertTrue(filesize('test-output.jpg') > 0);
     /* Now read the file and see if the entries are still there. */
     $jpeg = new PelJpeg('test-output.jpg');
     $exif = $jpeg->getExif();
     $this->assertIsA($exif, 'PelExif');
     $tiff = $exif->getTiff();
     $this->assertIsA($tiff, 'PelTiff');
     $ifd = $tiff->getIfd();
     $this->assertIsA($ifd, 'PelIfd');
     $this->assertEqual($ifd->getType(), PelIfd::IFD0);
     $this->assertTrue($ifd->isLastIfd());
     foreach ($this->entries as $entry) {
         $this->assertEqual($ifd->getEntry($entry->getTag())->getValue(), $entry->getValue());
     }
     unlink('test-output.jpg');
 }
开发者ID:BackupTheBerlios,项目名称:pic2base-svn,代码行数:38,代码来源:read-write.php

示例9: copyEXIF

 /**
  * Copy the source image's EXIF information to the new file in the cache
  *
  * @since 2.0
  * @uses PEL
  * @param string $cacheFilePath
  * @return mixed string contents of image on success, false on failure
  */
 private function copyEXIF($cacheFilePath)
 {
     $pelJpegLib = dirname(__FILE__) . '/../pel/src/PelJpeg.php';
     // Linking to pel library will break MIT license
     // Make the EXIF copy optional
     if (file_exists($pelJpegLib)) {
         // Make sure to suppress strict warning thrown by PEL
         require_once $pelJpegLib;
         $jpeg = new PelJpeg($this->getSource()->getFullPath());
         $exif = $jpeg->getExif();
         if ($exif !== null) {
             $jpeg = new PelJpeg($cacheFilePath);
             $jpeg->setExif($exif);
             $imageData = $jpeg->getBytes();
             if (!file_put_contents($cacheFilePath, $imageData)) {
                 return false;
             }
             return $imageData;
         }
     }
     return file_get_contents($cacheFilePath);
 }
开发者ID:afonsoduarte,项目名称:europa,代码行数:30,代码来源:slir.class.php

示例10: copyEXIF

 /**
  * Copy the source image's EXIF information to the new file in the cache
  *
  * @since 2.0
  * @uses PEL
  * @param string $cacheFilePath
  * @return mixed string contents of image on success, FALSE on failure
  */
 private function copyEXIF($cacheFilePath)
 {
     // Make sure to suppress strict warning thrown by PEL
     @(require_once dirname(__FILE__) . '/pel-0.9.2/src/PelJpeg.php');
     $jpeg = new PelJpeg($this->source->fullPath());
     $exif = $jpeg->getExif();
     if ($exif) {
         $jpeg = new PelJpeg($cacheFilePath);
         $jpeg->setExif($exif);
         $imageData = $jpeg->getBytes();
         if (!file_put_contents($cacheFilePath, $imageData)) {
             return FALSE;
         }
         return $imageData;
     }
     // if
     return file_get_contents($cacheFilePath);
 }
开发者ID:robertbrook,项目名称:stacey,代码行数:26,代码来源:slir.class.php

示例11: copyEXIF

 /**
  * Copy the source image's EXIF information to the new file in the cache
  *
  * @since 2.0
  * @uses PEL
  * @param string $cacheFilePath
  * @return mixed string contents of image on success, false on failure
  */
 private function copyEXIF($cacheFilePath)
 {
     // Make sure to suppress strict warning thrown by PEL
     require_once dirname(__FILE__) . '/../pel/src/PelJpeg.php';
     $jpeg = new PelJpeg($this->getSource()->getFullPath());
     $exif = $jpeg->getExif();
     if ($exif !== null) {
         $jpeg = new PelJpeg($cacheFilePath);
         $jpeg->setExif($exif);
         $imageData = $jpeg->getBytes();
         if (!file_put_contents($cacheFilePath, $imageData)) {
             return false;
         }
         return $imageData;
     }
     // if
     return file_get_contents($cacheFilePath);
 }
开发者ID:thibmo,项目名称:hackthis.co.uk,代码行数:26,代码来源:slir.class.php

示例12: resize

 /**
  * This method calculates the image and delivers it to the client.
  *
  * @param $folder
  * @param $file
  * @param $width
  * @param $height
  * @param $mode
  */
 public function resize($folder, $file, $width = -1, $height = -1, $mode = 'nocrop')
 {
     $jpeg_orientation_translation = array(1 => 0, 2 => 0, 3 => 180, 4 => 0, 5 => 0, 6 => -90, 7 => 0, 8 => 90);
     /**
      * @var JApplicationSite $app
      */
     $app = JFactory::getApplication();
     $params = $app->getParams();
     if (strcmp($mode, 'full') == 0) {
         $mode = 'nocrop';
         $width = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH;
         $height = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH;
     }
     if ($height > $width) {
         $width = $height;
     }
     $sizeSet = new EventgalleryHelpersSizeset();
     $saveAsSize = $sizeSet->getMatchingSize($width);
     $file = STR_REPLACE("\\.\\.", "", $file);
     $folder = STR_REPLACE("\\.\\.", "", $folder);
     $width = STR_REPLACE("\\.\\.", "", $width);
     $mode = STR_REPLACE("\\.\\.", "", $mode);
     $file = STR_REPLACE("/", "", $file);
     $folder = STR_REPLACE("/", "", $folder);
     $width = STR_REPLACE("/", "", $width);
     $mode = STR_REPLACE("/", "", $mode);
     $file = STR_REPLACE("\\", "", $file);
     $folder = STR_REPLACE("\\", "", $folder);
     $width = STR_REPLACE("\\", "", $width);
     $mode = STR_REPLACE("\\", "", $mode);
     $basedir = COM_EVENTGALLERY_IMAGE_FOLDER_PATH;
     $sourcedir = $basedir . $folder;
     $cachebasedir = COM_EVENTGALLERY_IMAGE_CACHE_PATH;
     $cachedir = $cachebasedir . $folder;
     $cachedir_thumbs = $cachebasedir . $folder;
     if (!is_dir(JPATH_CACHE)) {
         //mkdir($cachebasedir, 0777);
         mkdir(JPATH_CACHE);
     }
     if (!is_dir($cachebasedir)) {
         //mkdir($cachebasedir, 0777);
         mkdir($cachebasedir);
     }
     if (!is_dir($cachedir)) {
         //mkdir($cachedir, 0777);
         mkdir($cachedir);
     }
     if (!is_dir($cachedir_thumbs)) {
         //mkdir($cachedir_thumbs, 0777);
         mkdir($cachedir_thumbs);
     }
     $image_file = $sourcedir . DIRECTORY_SEPARATOR . $file;
     $image_thumb_file = $cachedir_thumbs . DIRECTORY_SEPARATOR . $mode . $saveAsSize . $file;
     //$last_modified = gmdate('D, d M Y H:i:s T', filemtime ($image_file));
     $last_modified = gmdate('D, d M Y H:i:s T', mktime(0, 0, 0, 1, 1, 2100));
     #echo "<br>".$image_thumb_file."<br>";
     $debug = false;
     if ($debug || !file_exists($image_thumb_file)) {
         $ext = pathinfo($image_file, PATHINFO_EXTENSION);
         $input_jpeg = null;
         $exif = null;
         if (strtolower($ext) == "gif") {
             if (!($im_original = imagecreatefromgif($image_file))) {
                 echo "Error opening {$image_file}!";
                 exit;
             }
         } else {
             if (strtolower($ext) == "jpg" || strtolower($ext) == "jpeg") {
                 // try to use PEL first. If things fail, use the php internal method to get the JPEG
                 try {
                     $input_jpeg = new PelJpeg($image_file);
                     /* Retrieve the original Exif data in $jpeg (if any). */
                     $exif = $input_jpeg->getExif();
                     /* The input image is already loaded, so we can reuse the bytes stored
                      * in $input_jpeg when creating the Image resource. */
                     if (!($im_original = ImageCreateFromString($input_jpeg->getBytes()))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
                 } catch (Exception $e) {
                     if (!($im_original = imagecreatefromjpeg($image_file))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
                 }
             } else {
                 if (strtolower($ext) == "png") {
                     if (!($im_original = imagecreatefrompng($image_file))) {
                         echo "Error opening {$image_file}!";
                         exit;
                     }
//.........这里部分代码省略.........
开发者ID:sansandeep143,项目名称:av,代码行数:101,代码来源:Resizeimage.php

示例13: addExif

function addExif($filename, $exifdata)
{
    try {
        $jpeg = new PelJpeg($filename);
        if (!($exif = $jpeg->getExif())) {
            // Create and add empty Exif data to the image (this throws away any old Exif data in the image).
            $exif = new PelExif();
            $jpeg->setExif($exif);
        }
        if (!($tiff = $exif->getTiff())) {
            // Create and add TIFF data to the Exif data (Exif data is actually stored in a TIFF format).
            $tiff = new PelTiff();
            $exif->setTiff($tiff);
        }
        if (!($ifd0 = $tiff->getIfd())) {
            // Create first Image File Directory and associate it with the TIFF data.
            $ifd0 = new PelIfd(PelIfd::IFD0);
            $tiff->setIfd($ifd0);
        }
        if (!($exif_ifd = $ifd0->getSubIfd(PelIfd::EXIF))) {
            // Create first Image File Directory and associate it with the TIFF data.
            $exif_ifd = new PelIfd(PelIfd::EXIF);
            $ifd0->addSubIfd($exif_ifd);
        }
        if (!($ifd1 = $ifd0->getNextIfd())) {
            // thumbnail does not exist
            $ifd1 = new PelIfd(1);
            $ifd0->setNextIfd($ifd1);
            $original = ImageCreateFromString($jpeg->getBytes());
            # create image resource of original
            $thumb = makeThumb($original);
            // start writing output to buffer
            ob_start();
            // outputs thumb resource contents to buffer
            ImageJpeg($thumb);
            // create PelDataWindow from buffer thumb contents (and end output to buffer)
            $window = new PelDataWindow(ob_get_clean());
            if ($window) {
                $ifd1->setThumbnail($window);
                # set window data as thumbnail in ifd1
            }
            imagedestroy($original);
            imagedestroy($thumb);
        }
        foreach ($exifdata as $PelTag => $val) {
            if ($PelTag == PelTag::USER_COMMENT) {
                if (!($entry = $exif_ifd->getEntry($PelTag))) {
                    $exif_ifd->addEntry(new PelEntryUserComment($val));
                } else {
                    $entry->setValue($val);
                }
            } else {
                if (!($entry = $ifd0->getEntry($PelTag))) {
                    $ifd0->addEntry(new PelEntryAscii($PelTag, $val));
                } else {
                    $entry->setValue($val);
                }
            }
        }
        $jpeg->saveFile($filename);
        return true;
    } catch (Exception $e) {
        // Handle exception
        echo $e;
    }
}
开发者ID:debruine,项目名称:webmorph,代码行数:66,代码来源:fileSave.php

示例14: addGpsInfo

/**
 * Add GPS information to an image basic metadata. Any old Exif data
 * is discarded.
 *
 * @param string the input filename.
 *
 * @param string the output filename. An updated copy of the input
 * image is saved here.
 *
 * @param string image description.
 *
 * @param string user comment.
 *
 * @param string camera model.
 *
 * @param float longitude expressed as a fractional number of degrees,
 * e.g. 12.345°. Negative values denotes degrees west of Greenwich.
 *
 * @param float latitude expressed as for longitude. Negative values
 * denote degrees south of equator.
 *
 * @param float the altitude, negative values express an altitude
 * below sea level.
 *
 * @param string the date and time.
 */
function addGpsInfo($input, $description, $comment, $artist, $make, $model, $longitude, $latitude)
{
    /* Load the given image into a PelJpeg object */
    $jpeg = new PelJpeg($input);
    /* Create and add empty Exif data to the image (this throws away any
     * old Exif data in the image). */
    $exif = new PelExif();
    $jpeg->setExif($exif);
    /* Create and add TIFF data to the Exif data (Exif data is actually
     * stored in a TIFF format). */
    $tiff = new PelTiff();
    $exif->setTiff($tiff);
    /* Create first Image File Directory and associate it with the TIFF
     * data. */
    $ifd0 = new PelIfd(PelIfd::IFD0);
    $tiff->setIfd($ifd0);
    /* Create a sub-IFD for holding GPS information. GPS data must be
     * below the first IFD. */
    $gps_ifd = new PelIfd(PelIfd::GPS);
    $ifd0->addSubIfd($gps_ifd);
    /* The USER_COMMENT tag must be put in a Exif sub-IFD under the
     * first IFD. */
    $exif_ifd = new PelIfd(PelIfd::EXIF);
    $exif_ifd->addEntry(new PelEntryUserComment($comment));
    $ifd0->addSubIfd($exif_ifd);
    $inter_ifd = new PelIfd(PelIfd::INTEROPERABILITY);
    $ifd0->addSubIfd($inter_ifd);
    $ifd0->addEntry(new PelEntryAscii(PelTag::ARTIST, $artist));
    $ifd0->addEntry(new PelEntryAscii(PelTag::MAKE, $make));
    $ifd0->addEntry(new PelEntryAscii(PelTag::MODEL, $model));
    $ifd0->addEntry(new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description));
    $gps_ifd->addEntry(new PelEntryByte(PelTag::GPS_VERSION_ID, 2, 2, 0, 0));
    // Negative numbers indicate different reference then the usual N/E
    if ($longitude < 0) {
        $longitude_ref = 'W';
    } else {
        $longitude_ref = 'E';
    }
    if ($latitude < 0) {
        $latitude_ref = 'S';
    } else {
        $latitude_ref = 'N';
    }
    list($h, $m, $s) = convertDecimalToDMS($latitude);
    $gps_ifd->addEntry(new PelEntryAscii(PelTag::GPS_LATITUDE_REF, $latitude_ref));
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_LATITUDE, $h, $m, $s));
    list($h, $m, $s) = convertDecimalToDMS($longitude);
    $gps_ifd->addEntry(new PelEntryAscii(PelTag::GPS_LONGITUDE_REF, $longitude_ref));
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_LONGITUDE, $h, $m, $s));
    $gps_ifd->addEntry(new PelEntryRational(PelTag::GPS_ALTITUDE, array(0, 0)));
    $gps_ifd->addEntry(new PelEntryByte(PelTag::GPS_ALTITUDE_REF, 0));
    //print($gps_ifd);
    file_put_contents($input, $jpeg->getBytes());
}
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:80,代码来源:gps.php

示例15: proceedList


//.........这里部分代码省略.........
                         $tempPicDir = $zoom['config']['picDir'];
                     }
                     $aryEXIF = array();
                     $aryEXIF = exif_read_data($tempPicDir . $v);
                     if (isset($aryEXIF["Orientation"]) && ($aryEXIF["Orientation"] == 6 || $aryEXIF["Orientation"] == 8 || $aryEXIF["Orientation"] == 3)) {
                         $angle = 0;
                         if ($aryEXIF["Orientation"] == 6) {
                             $angle = 270;
                         } elseif ($aryEXIF["Orientation"] == 8) {
                             $angle = 90;
                         } elseif ($aryEXIF["Orientation"] == 3) {
                             $angle = 180;
                         }
                         if ($angle != 0) {
                             if (is_writable($tempPicDir . $v)) {
                                 $this->removeAxZm($zoom, $v, array('In' => true, 'Th' => true, 'tC' => true, 'mO' => true, 'Ti' => true, 'gP' => true), false);
                                 if ($pelLib) {
                                     $sourceExifFile = new PelJpeg($tempPicDir . $v);
                                     $sourceExifInfo = $sourceExifFile->getExif();
                                 }
                                 if ($zoom['config']['im']) {
                                     $arrAngle = array('270' => '90', '90' => '-90', '180' => '180');
                                     $convertString = $this->whichConvert($zoom['config']['imPath']) . " '" . $tempPicDir . $v . "' -rotate '" . $arrAngle[$angle] . "' '" . $tempPicDir . $v . "'";
                                     $convertString = $this->imQuotes($zoom, $convertString);
                                     exec($convertString);
                                 } else {
                                     $rotatedImage = $this->rotateImage($tempPicDir . $v, $angle);
                                     imagejpeg($rotatedImage, $tempPicDir . $v, 100);
                                 }
                                 if ($pelLib) {
                                     $outputExifFile = new PelJpeg($tempPicDir . $v);
                                     if ($sourceExifInfo != null) {
                                         $outputExifFile->setExif($sourceExifInfo);
                                         file_put_contents($tempPicDir . $v, $outputExifFile->getBytes());
                                     }
                                     $this->exifOrientation($tempPicDir . $v, $tempPicDir . $v);
                                 }
                                 $pic_list_data[$k]['imgSize'] = $this->axZm->imageSize($tempPicDir . $v, $zoom['config']['im'], false);
                             } else {
                                 if ($zoom['config']['errors']) {
                                     echo 'alert("' . $tempPicDir . $v . ' is not writable by PHP.");';
                                 }
                             }
                         }
                     }
                 }
                 $zoom['config']['pic_list_data'] = $pic_list_data;
             }
             $this->readTime['exifAutoRotation'] = $this->endTimeDiff($startTime);
         }
         if ($zoom['config']['cTimeCompare'] && !isset($_GET['setHW']) && !isset($_GET['str']) && !isset($_GET['qq'])) {
             $this->cTimeCompare($zoom);
         }
         if (isset($_GET['zoomID']) && !isset($_GET['qq'])) {
             if (isset($pic_list_data[$_GET['zoomID']]['path'])) {
                 $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add');
             }
             $zoom['config']['orgImgName'] = $pic_list_array[$_GET['zoomID']];
             if ($pic_list_data[$_GET['zoomID']]['imgSize']) {
                 $zoom['config']['orgImgSize'] = $pic_list_data[$_GET['zoomID']]['imgSize'];
             } else {
                 $zoom['config']['orgImgSize'] = $this->axZm->imageSize($zoom['config']['picDir'] . $zoom['config']['orgImgName'], $zoom['config']['im'], false);
             }
             $zoom['config']['smallImgName'] = $this->composeFileName($pic_list_array[$_GET['zoomID']], $zoom['config']['picDim'], '_', $this->pngMod($zoom));
             $imageSlicer = $zoom['config']['imageSlicer'];
             if (!is_array($imageSlicer)) {
开发者ID:hevelmo,项目名称:templates,代码行数:67,代码来源:axZmH.class.php


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