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


PHP PelJpeg::setExif方法代码示例

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


在下文中一共展示了PelJpeg::setExif方法的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: 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

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

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

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

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

示例7: 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());
     $jpeg->saveFile('test-output.jpg');
     $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:ni-c,项目名称:pel,代码行数:38,代码来源:read-write.php

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

示例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)
 {
     // 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

示例10: attach_exif

 public static function attach_exif($jpegfile, $option)
 {
     require_once FS_ROOT . 'include/PEL/PelJpeg.php';
     $jpeg = new PelJpeg($jpegfile);
     $exif = new PelExif();
     $jpeg->setExif($exif);
     $tiff = new PelTiff();
     $exif->setTiff($tiff);
     $ifd0 = new PelIfd(PelIfd::IFD0);
     $tiff->setIfd($ifd0);
     if (isset($option['orientation']) && $option['orientation'] > 0) {
         $ifd0->addEntry(new PelEntryShort(PelTag::ORIENTATION, intval($option['orientation'])));
     }
     //         $exif_ifd = new PelIfd(PelIfd::EXIF);
     //         $exif_ifd->addEntry(new PelEntryUserComment('Hello World!'));
     //         $ifd0->addSubIfd($exif_ifd);
     file_put_contents($jpegfile, $jpeg->getBytes());
 }
开发者ID:momoim,项目名称:momo-api,代码行数:18,代码来源:Core.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: println

    println('  input   the input filename, a JPEG image.');
    println('  output  filename for saving the changed image.');
    println('  scale   scale factor, say 0.5 to resize to half the ' . 'original size.');
    exit(1);
}
/* The input file is now loaded into a PelJpeg object. */
println('Reading file "%s".', $input);
$input_jpeg = new PelJpeg($input);
/* The input image is already loaded, so we can reuse the bytes stored
 * in $input_jpeg when creating the Image resource. */
$original = ImageCreateFromString($input_jpeg->getBytes());
$original_w = ImagesX($original);
$original_h = ImagesY($original);
$scaled_w = $original_w * $scale;
$scaled_h = $original_h * $scale;
/* Now create the scaled image. */
$scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
/* We want the raw JPEG data from $scaled. Luckily, one can create a
 * PelJpeg object from an image resource directly: */
$output_jpeg = new PelJpeg($scaled);
/* Retrieve the original Exif data in $jpeg (if any). */
$exif = $input_jpeg->getExif();
/* If no Exif data was present, then $exif is null. */
if ($exif != null) {
    $output_jpeg->setExif($exif);
}
/* We can now save the scaled image. */
println('Writing file "%s".', $output);
file_put_contents($output, $output_jpeg->getBytes());
/* The End. */
开发者ID:Peter2121,项目名称:leonardoxc,代码行数:31,代码来源:resize.php

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

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

示例15: dirname

 /**
  * @param     $from_file
  * @param     $to_file
  */
 function copy_exif($from_file, $to_file)
 {
     $size = @getimagesize($to_file);
     if ($size) {
         require_once dirname(__FILE__) . '/pel/autoload.php';
         try {
             Pel::setJPEGQuality(100);
             /*
              * We want the raw JPEG data from $scaled. Luckily, one can create a
              * PelJpeg object from an image resource directly:
              */
             $input_jpeg = new PelJpeg($from_file);
             /* Retrieve the original Exif data in $jpeg (if any). */
             $input_exif = $input_jpeg->getExif();
             /* If no Exif data was present, then $input_exif is null. */
             if ($input_exif != null) {
                 $input_tiff = $input_exif->getTiff();
                 if ($input_tiff == null) {
                     return;
                 }
                 $input_ifd0 = $input_tiff->getIfd();
                 if ($input_ifd0 == null) {
                     return;
                 }
                 $input_exif_ifd = $input_ifd0->getSubIfd(PelIfd::EXIF);
                 $input_inter_ifd = $input_ifd0->getSubIfd(PelIfd::INTEROPERABILITY);
                 $orientation = $input_ifd0->getEntry(PelTag::ORIENTATION);
                 if ($orientation != null) {
                     $orientation->setValue(1);
                 }
                 if (!empty($input_ifd0)) {
                     /*$x_resolution = $input_ifd0->getEntry( PelTag::X_RESOLUTION );
                       $y_resolution = $input_ifd0->getEntry( PelTag::Y_RESOLUTION );
                       if ( $x_resolution != null && $y_resolution != null ) {
                           //$x_res = $x_resolution->getValue();
                           //$y_res = $y_resolution->getValue();
                           $x_resolution->setValue( $y_res );
                           $y_resolution->setValue( $x_res );
                       }*/
                     $image_width = $input_ifd0->getEntry(PelTag::IMAGE_WIDTH);
                     $image_length = $input_ifd0->getEntry(PelTag::IMAGE_LENGTH);
                     if ($image_width != null && $image_length != null) {
                         $image_width->setValue($size[0]);
                         $image_length->setValue($size[1]);
                     }
                 }
                 if (!empty($input_exif_ifd)) {
                     $x_dimention = $input_exif_ifd->getEntry(PelTag::PIXEL_X_DIMENSION);
                     $y_dimention = $input_exif_ifd->getEntry(PelTag::PIXEL_Y_DIMENSION);
                     if ($x_dimention != null && $y_dimention != null) {
                         $x_dimention->setValue($size[0]);
                         $y_dimention->setValue($size[1]);
                     }
                 }
                 if (!empty($input_inter_ifd)) {
                     $rel_image_width = $input_inter_ifd->getEntry(PelTag::RELATED_IMAGE_WIDTH);
                     $rel_image_length = $input_inter_ifd->getEntry(PelTag::RELATED_IMAGE_LENGTH);
                     if ($rel_image_width != null && $rel_image_length != null) {
                         $rel_image_width->setValue($size[0]);
                         $rel_image_length->setValue($size[1]);
                     }
                 }
                 $output_jpeg = new PelJpeg($to_file);
                 $output_jpeg->setExif($input_exif);
                 /* We can now save the image with input_exif. */
                 $output_jpeg->saveFile($to_file);
             }
         } catch (PelException $e) {
         }
     }
 }
开发者ID:pasyuk,项目名称:grand-media,代码行数:75,代码来源:core.php


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