• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP iptcembed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中iptcembed函数的典型用法代码示例。如果您正苦于以下问题:PHP iptcembed函数的具体用法?PHP iptcembed怎么用?PHP iptcembed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: writeMeta

 public function writeMeta($metaarray)
 {
     $foundtags = array();
     foreach ($metaarray as $row => $value) {
         foreach ($this->definitions as $currentDef => $tagValue) {
             if ($row == $currentDef) {
                 // keywords must be handled
                 // they are keywords as array and not string
                 if ($row == "keywords") {
                     $totalString = "";
                     foreach ($value as $currentKeyword) {
                         $totalString .= $currentKeyword;
                     }
                     $foundtags[$tagValue] = $totalString;
                 } else {
                     $foundtags[$tagValue] = $value;
                 }
             }
         }
     }
     $data = "";
     foreach ($foundtags as $tag => $string) {
         $tag = substr($tag, 2);
         $data .= $this->IPTCmakeTag(2, $tag, $string);
     }
     $newContent = iptcembed($data, $this->path . $this->filename);
     $file = fopen($this->path . $this->filename, "wb");
     fwrite($file, $newContent);
     fclose($file);
 }
开发者ID:OmniPics,项目名称:OmniPics,代码行数:30,代码来源:app.php


示例2: write

 private function write()
 {
     $mode = 0;
     $content = iptcembed($this->binary(), $this->file, $mode);
     $filename = $this->file;
     if (file_exists($this->file)) {
         unlink($this->file);
     }
     $fp = fopen($this->file, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:WrinklyNinja,项目名称:emelhamlet.co.uk,代码行数:12,代码来源:IPTC.php


示例3: write

 function write()
 {
     if (!function_exists('iptcembed')) {
         return false;
     }
     $mode = 0;
     $content = iptcembed($this->binary(), $this->file, $mode);
     $filename = $this->file;
     @unlink($filename);
     #delete if exists
     $fp = fopen($filename, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:afrog33k,项目名称:sdk.ralcr,代码行数:14,代码来源:iptc.php


示例4: starter

function starter()
{
    //getMeta("./samples/","1.jpg");
    getMeta("./", "img.jpg");
    $iptc = array("2#120" => "Hello world", "2#025" => "Your keywords will be placed here", "2#116" => "Thomas Darvik heter jeg");
    $data = "";
    foreach ($iptc as $tag => $string) {
        $tag = substr($tag, 2);
        $data .= IPTCmakeTag(2, $tag, $string);
    }
    $content = iptcembed($data, "./img.jpg");
    $file = fopen("./img.jpg", "wb");
    fwrite($file, $content);
    fclose($file);
    getMeta("./", "img.jpg");
}
开发者ID:OmniPics,项目名称:OmniPics,代码行数:16,代码来源:app4.php


示例5: create_iptc

 public function create_iptc($source, $destination, $data)
 {
     // clear image tags
     $this->remove_tags($source);
     $image = getimagesize($source, $info);
     $iptc_data = "";
     foreach ($this->iptc_header_array as $key => $value) {
         $tag = substr($key, 2);
         $iptc_data .= $this->iptc_make_tag(2, $tag, $value . $key . $data);
     }
     // embed data into image
     $content = iptcembed($iptc_data, $source);
     $fp = fopen($destination, "wb");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:brammittendorff,项目名称:facebook-and-the-problem-with-iptc,代码行数:16,代码来源:iptc.class.php


示例6: write

 function write()
 {
     global $UNC_GALLERY;
     if ($UNC_GALLERY['debug']) {
         XMPP_ERROR_trace(__FUNCTION__, func_get_args());
     }
     if (!function_exists('iptcembed')) {
         if ($UNC_GALLERY['debug']) {
             XMPP_ERROR_trace(__FUNCTION__, "iptcembed Does not exist!!");
         }
         return false;
     }
     $mode = 0;
     $content = iptcembed($this->binary(), $this->file, $mode);
     $filename = $this->file;
     @unlink($filename);
     #delete if exists
     $fp = fopen($filename, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:uncovery,项目名称:unc_gallery,代码行数:21,代码来源:unc_image.inc.php


示例7: copyIPTC

 /**
  * Copies IPTC data from the source image to the cached file
  *
  * @since 2.0
  * @param string $cacheFilePath
  * @return boolean
  */
 private function copyIPTC($cacheFilePath)
 {
     $data = '';
     $iptc = $this->getSource()->iptc;
     // Originating program
     $iptc['2#065'] = array('Smart Lencioni Image Resizer');
     // Program version
     $iptc['2#070'] = array(SLIR::VERSION);
     foreach ($iptc as $tag => $iptcData) {
         $tag = substr($tag, 2);
         $data .= $this->makeIPTCTag(2, $tag, $iptcData[0]);
     }
     // Embed the IPTC data
     return iptcembed($data, $cacheFilePath);
 }
开发者ID:thibmo,项目名称:hackthis.co.uk,代码行数:22,代码来源:slir.class.php


示例8: generate_image_clone


//.........这里部分代码省略.........
                 $original->resize($width, $height, $crop);
                 $original->set_quality($quality);
                 $original->save($clone_path);
             }
         } else {
             if ($method == 'nextgen') {
                 $destpath = $clone_path;
                 $thumbnail = new C_NggLegacy_Thumbnail($image_path, true);
                 if (!$thumbnail->error) {
                     if ($crop) {
                         $crop_area = $result['crop_area'];
                         $crop_x = $crop_area['x'];
                         $crop_y = $crop_area['y'];
                         $crop_width = $crop_area['width'];
                         $crop_height = $crop_area['height'];
                         $thumbnail->crop($crop_x, $crop_y, $crop_width, $crop_height);
                     }
                     $thumbnail->resize($width, $height);
                 } else {
                     $thumbnail = NULL;
                 }
             }
         }
         // We successfully generated the thumbnail
         if (is_string($destpath) && (@file_exists($destpath) || $thumbnail != null)) {
             if ($clone_format != null) {
                 if (isset($format_list[$clone_format])) {
                     $clone_format_extension = $format_list[$clone_format];
                     $clone_format_extension_str = null;
                     if ($clone_format_extension != null) {
                         $clone_format_extension_str = '.' . $clone_format_extension;
                     }
                     $destpath_info = M_I18n::mb_pathinfo($destpath);
                     $destpath_extension = $destpath_info['extension'];
                     if (strtolower($destpath_extension) != strtolower($clone_format_extension)) {
                         $destpath_dir = $destpath_info['dirname'];
                         $destpath_basename = $destpath_info['filename'];
                         $destpath_new = $destpath_dir . DIRECTORY_SEPARATOR . $destpath_basename . $clone_format_extension_str;
                         if (@file_exists($destpath) && rename($destpath, $destpath_new) || $thumbnail != null) {
                             $destpath = $destpath_new;
                         }
                     }
                 }
             }
             if (is_null($thumbnail)) {
                 $thumbnail = new C_NggLegacy_Thumbnail($destpath, true);
             } else {
                 $thumbnail->fileName = $destpath;
             }
             // This is quite odd, when watermark equals int(0) it seems all statements below ($watermark == 'image') and ($watermark == 'text') both evaluate as true
             // so we set it at null if it evaluates to any null-like value
             if ($watermark == null) {
                 $watermark = null;
             }
             if ($watermark == 1 || $watermark === true) {
                 if (in_array(strval($settings->wmType), array('image', 'text'))) {
                     $watermark = $settings->wmType;
                 } else {
                     $watermark = 'text';
                 }
             }
             $watermark = strval($watermark);
             if ($watermark == 'image') {
                 $thumbnail->watermarkImgPath = $settings['wmPath'];
                 $thumbnail->watermarkImage($settings['wmPos'], $settings['wmXpos'], $settings['wmYpos']);
             } else {
                 if ($watermark == 'text') {
                     $thumbnail->watermarkText = $settings['wmText'];
                     $thumbnail->watermarkCreateText($settings['wmColor'], $settings['wmFont'], $settings['wmSize'], $settings['wmOpaque']);
                     $thumbnail->watermarkImage($settings['wmPos'], $settings['wmXpos'], $settings['wmYpos']);
                 }
             }
             if ($rotation && in_array(abs($rotation), array(90, 180, 270))) {
                 $thumbnail->rotateImageAngle($rotation);
             }
             $flip = strtolower($flip);
             if ($flip && in_array($flip, array('h', 'v', 'hv'))) {
                 $flip_h = in_array($flip, array('h', 'hv'));
                 $flip_v = in_array($flip, array('v', 'hv'));
                 $thumbnail->flipImage($flip_h, $flip_v);
             }
             if ($reflection) {
                 $thumbnail->createReflection(40, 40, 50, FALSE, '#a4a4a4');
             }
             if ($clone_format != null && isset($format_list[$clone_format])) {
                 // Force format
                 $thumbnail->format = strtoupper($format_list[$clone_format]);
             }
             $thumbnail->save($destpath, $quality);
             // IF the original contained IPTC metadata we should attempt to copy it
             if (isset($detailed_size['APP13']) && function_exists('iptcembed')) {
                 $metadata = @iptcembed($detailed_size['APP13'], $destpath);
                 $fp = @fopen($destpath, 'wb');
                 @fwrite($fp, $metadata);
                 @fclose($fp);
             }
         }
     }
     return $thumbnail;
 }
开发者ID:radscheit,项目名称:unicorn,代码行数:101,代码来源:package.module.nextgen_data.php


示例9: ___resize


//.........这里部分代码省略.........
                 default:
                     // center or false, we do nothing
             }
         } else {
             if (is_array($this->cropping)) {
                 // @interrobang + @u-nikos
                 if (strpos($this->cropping[0], '%') === false) {
                     $pointX = (int) $this->cropping[0];
                 } else {
                     $pointX = $gdWidth * ((int) $this->cropping[0] / 100);
                 }
                 if (strpos($this->cropping[1], '%') === false) {
                     $pointY = (int) $this->cropping[1];
                 } else {
                     $pointY = $gdHeight * ((int) $this->cropping[1] / 100);
                 }
                 if ($pointX < $targetWidth / 2) {
                     $w1 = 0;
                 } else {
                     if ($pointX > $gdWidth - $targetWidth / 2) {
                         $w1 = $gdWidth - $targetWidth;
                     } else {
                         $w1 = $pointX - $targetWidth / 2;
                     }
                 }
                 if ($pointY < $targetHeight / 2) {
                     $h1 = 0;
                 } else {
                     if ($pointY > $gdHeight - $targetHeight / 2) {
                         $h1 = $gdHeight - $targetHeight;
                     } else {
                         $h1 = $pointY - $targetHeight / 2;
                     }
                 }
             }
         }
         imagecopyresampled($thumb2, $thumb, 0, 0, $w1, $h1, $targetWidth, $targetHeight, $targetWidth, $targetHeight);
         if ($this->sharpening && $this->sharpening != 'none') {
             $image = $this->imSharpen($thumb2, $this->sharpening);
         }
         // @horst
     }
     // write to file
     $result = false;
     switch ($this->imageType) {
         case IMAGETYPE_GIF:
             // correct gamma from linearized 1.0 back to 2.0
             imagegammacorrect($thumb2, 1.0, 2.0);
             $result = imagegif($thumb2, $dest);
             break;
         case IMAGETYPE_PNG:
             // convert 1-100 (worst-best) scale to 0-9 (best-worst) scale for PNG
             $quality = round(abs(($this->quality - 100) / 11.111111));
             $result = imagepng($thumb2, $dest, $quality);
             break;
         case IMAGETYPE_JPEG:
             // correct gamma from linearized 1.0 back to 2.0
             imagegammacorrect($thumb2, 1.0, 2.0);
             $result = imagejpeg($thumb2, $dest, $this->quality);
             break;
     }
     @imagedestroy($image);
     // @horst
     if (isset($thumb) && is_resource($thumb)) {
         @imagedestroy($thumb);
     }
     // @horst
     if (isset($thumb2) && is_resource($thumb2)) {
         @imagedestroy($thumb2);
     }
     // @horst
     if ($result === false) {
         if (is_file($dest)) {
             @unlink($dest);
         }
         return false;
     }
     unlink($source);
     rename($dest, $source);
     // @horst: if we've retrieved IPTC-Metadata from sourcefile, we write it back now
     if ($this->iptcRaw) {
         $content = iptcembed($this->iptcPrepareData(), $this->filename);
         if ($content !== false) {
             $dest = preg_replace('/\\.' . $this->extension . '$/', '_tmp.' . $this->extension, $this->filename);
             if (strlen($content) == @file_put_contents($dest, $content, LOCK_EX)) {
                 // on success we replace the file
                 unlink($this->filename);
                 rename($dest, $this->filename);
             } else {
                 // it was created a temp diskfile but not with all data in it
                 if (file_exists($dest)) {
                     @unlink($dest);
                 }
             }
         }
     }
     $this->loadImageInfo($this->filename);
     $this->modified = true;
     return true;
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:101,代码来源:ImageSizer.php


示例10: cacheImage


//.........这里部分代码省略.........
                        $watermark_image = getWatermarkPath($watermark_image);
                        if (!file_exists($watermark_image)) {
                            $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                        }
                    }
                }
            }
        }
        if ($watermark_image) {
            $offset_h = getOption('watermark_h_offset') / 100;
            $offset_w = getOption('watermark_w_offset') / 100;
            $watermark = zp_imageGet($watermark_image);
            $watermark_width = zp_imageWidth($watermark);
            $watermark_height = zp_imageHeight($watermark);
            $imw = zp_imageWidth($newim);
            $imh = zp_imageHeight($newim);
            $nw = sqrt($imw * $imh * $percent * ($watermark_width / $watermark_height));
            $nh = $nw * ($watermark_height / $watermark_width);
            $percent = getOption('watermark_scale') / 100;
            $r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
            if (!getOption('watermark_allow_upscale')) {
                $r = min(1, $r);
            }
            $nw = round($watermark_width * $r);
            $nh = round($watermark_height * $r);
            if ($nw != $watermark_width || $nh != $watermark_height) {
                $watermark = zp_imageResizeAlpha($watermark, $nw, $nh);
            }
            // Position Overlay in Bottom Right
            $dest_x = max(0, floor(($imw - $nw) * $offset_w));
            $dest_y = max(0, floor(($imh - $nh) * $offset_h));
            if (DEBUG_IMAGE) {
                debugLog("Watermark:" . basename($imgfile) . ": \$offset_h={$offset_h}, \$offset_w={$offset_w}, \$watermark_height={$watermark_height}, \$watermark_width={$watermark_width}, \$imw={$imw}, \$imh={$imh}, \$percent={$percent}, \$r={$r}, \$nw={$nw}, \$nh={$nh}, \$dest_x={$dest_x}, \$dest_y={$dest_y}");
            }
            zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh);
            zp_imageKill($watermark);
        }
        // Create the cached file (with lots of compatibility)...
        mkdir_recursive(dirname($newfile));
        if (zp_imageOutput($newim, getSuffix($newfile), $newfile, $quality)) {
            //	successful save of cached image
            if (getOption('ImbedIPTC') && getSuffix($newfilename) == 'jpg') {
                // the imbed function works only with JPEG images
                $iptc_data = zp_imageIPTC($imgfile);
                if (empty($iptc_data)) {
                    global $_zp_extra_filetypes;
                    //	because we are doing the require in a function!
                    if (!$_zp_extra_filetypes) {
                        $_zp_extra_filetypes = array();
                    }
                    require_once dirname(__FILE__) . '/functions.php';
                    //	it is ok to increase memory footprint now since the image processing is complete
                    $gallery = new Gallery();
                    $iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47), '2#115' => $gallery->getTitle());
                    $imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
                    $imagename = basename($imgfile);
                    $albumname = dirname($imgfile);
                    $image = newImage(new Album(new Gallery(), $albumname), $imagename);
                    $copyright = $image->getCopyright();
                    if (empty($copyright)) {
                        $copyright = getOption('default_copyright');
                    }
                    if (!empty($copyright)) {
                        $iptc['2#116'] = $copyright;
                    }
                    $credit = $image->getCredit();
                    if (!empty($credit)) {
                        $iptc['2#110'] = $credit;
                    }
                    foreach ($iptc as $tag => $string) {
                        $tag_parts = explode('#', $tag);
                        $iptc_data .= iptc_make_tag($tag_parts[0], $tag_parts[1], $string);
                    }
                } else {
                    if (GRAPHICS_LIBRARY == 'Imagick' && IMAGICK_RETAIN_PROFILES) {
                        //	Imageick has preserved the metadata
                        $iptc_data = false;
                    }
                }
                if ($iptc_data) {
                    $content = iptcembed($iptc_data, $newfile);
                    $fw = fopen($newfile, 'w');
                    fwrite($fw, $content);
                    fclose($fw);
                    clearstatcache();
                }
            }
            if (DEBUG_IMAGE) {
                debugLog('Finished:' . basename($imgfile));
            }
        } else {
            if (DEBUG_IMAGE) {
                debugLog('cacheImage: failed to create ' . $newfile);
            }
        }
        @chmod($newfile, 0666 & CHMOD_VALUE);
        zp_imageKill($newim);
        zp_imageKill($im);
    }
}
开发者ID:hatone,项目名称:zenphoto-1.4.1.4,代码行数:101,代码来源:functions-image.php


示例11: write

 function write()
 {
     //        echo 'Writing file...<br />';
     if (!function_exists('iptcembed')) {
         return false;
     }
     $mode = 0;
     //        var_dump($this->binary());
     //        var_dump($this->path);
     $content = iptcembed($this->binary(), $this->path, $mode);
     $filename = $this->file;
     @unlink($filename);
     #delete if exists
     $fp = fopen($filename, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:iiispikeriii,项目名称:iptc-editor,代码行数:17,代码来源:iptc.php


示例12: output

 /**
  * Embed IPTC data block and output to standard output
  *
  * @access public
  */
 function output()
 {
     $sIPTCBlock = $this->_getIPTCBlock();
     @iptcembed($sIPTCBlock, $this->_sFilename, 2);
 }
开发者ID:austinvernsonger,项目名称:scalar,代码行数:10,代码来源:Image_IPTC.php


示例13: base64_encode

<?php

$jpg = base64_encode(file_get_contents(__DIR__ . "/iptc-data.jpg"));
$s = iptcembed("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "data://text/plain;base64," . $jpg);
var_dump(strlen($s));
开发者ID:RavuAlHemio,项目名称:hhvm,代码行数:5,代码来源:iptcembed-stream.php


示例14: write

 function write()
 {
     $data = iptcembed($this->getBinary(), $this->_filename);
     $fp = fopen($this->_filename, 'wb');
     fwrite($fp, $data);
     fclose($fp);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:7,代码来源:tags.php


示例15: write

 public function write()
 {
     $mode = 0;
     $content = iptcembed($this->binary(), $this->_file, $mode);
     $filename = $this->_file;
     @unlink($filename);
     #delete if exists
     $fp = fopen($filename, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
开发者ID:BGCX261,项目名称:zieli-svn-to-git,代码行数:11,代码来源:Iptc.php


示例16: writeIptcIntoFile

 public function writeIptcIntoFile($targetFilename, $iptcRaw)
 {
     $content = iptcembed($this->iptcPrepareData($iptcRaw), $targetFilename);
     if ($content !== false) {
         $dest = $targetFilename . '.tmp';
         if (strlen($content) == @file_put_contents($dest, $content, LOCK_EX)) {
             // on success we replace the file
             unlink($targetFilename);
             rename($dest, $targetFilename);
         } else {
             // it was created a temp diskfile but not with all data in it
             if (file_exists($dest)) {
                 @unlink($dest);
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:borantula,项目名称:CroppableImage,代码行数:19,代码来源:CroppableImageKeepCoords.class.php


示例17: force_download

 function force_download()
 {
     //$ori_path = "../pdfs/";
     //$book = "cubaan";
     //$ori  = $ori_path.'ori/'.$book.'.pdf';
     //$cover_ori  = $ori_path.'covers/'.$book.'.jpg';
     if ($this->pdf == '') {
         echo 'Please set pdf path as in $this->pdfest->set_pdf_path("path/to/file.pdf")';
         exit;
     }
     if ($this->cover == '') {
         echo 'Please set cover path as in $this->pdfest->set_cover_path("path/to/cover.jpg")';
         exit;
     }
     if ($this->email == '') {
         echo 'Please set owner email as in $this->pdfest->set_owner_email("[email protected]")';
         exit;
     }
     if ($this->hp == '') {
         echo 'Please set owner hp as in $this->pdfest->set_owner_hp("012345678")';
         exit;
     }
     $ori = $this->pdf;
     $cover_ori = $this->cover;
     $pat = explode('/', $cover_ori);
     $cov = $this->hp . '-' . $pat[count($pat) - 1];
     $pat[count($pat) - 1] = $cov;
     //var_dump($cov);
     $cover_path = implode('/', $pat);
     //var_dump($cover_path);
     $email = $this->email;
     $hp = $this->hp;
     $hash = sha1($email . $hp);
     //$cover_path = $ori_path.'temp/'.$hp.'.'.$book.'.jpg';
     // Path to jpeg file
     $path = $cover_ori;
     // We need to check if theres any IPTC data in the jpeg image. If there is then
     // bail out because we cannot embed any image that already has some IPTC data!
     $image = getimagesize($path, $info);
     if (isset($info['APP13'])) {
         die('Error: IPTC data found in source image, cannot continue');
     }
     // Set the IPTC tags
     $iptc = array('2#120' => 'Cover For ' . $this->title, '2#116' => 'Copyright 2012, PTS Akademia (' . md5($email . '/' . $hp) . ')');
     // Convert the IPTC tags into binary code
     $data = '';
     foreach ($iptc as $tag => $string) {
         $tag = substr($tag, 2);
         $data .= $this->iptc_make_tag(2, $tag, $string);
     }
     // Embed the IPTC data
     $content = iptcembed($data, $path);
     // Write the new image data out to the file.
     $fp = fopen($cover_path, "wb");
     fwrite($fp, $content);
     fclose($fp);
     /*****************
     				Siap Cover
     				///buat PDF
     			******************/
     $pagecount = $this->setSourceFile($ori);
     $this->SetTitle($this->title);
     //$this->SetAuthor('Izwan Wahab');
     $this->SetCreator('PTS Akademia');
     //$this->SetSubject('Subjek atau Kategori Buku Ini');
     $this->SetKeywords($hash);
     //add coverpage
     $this->addPage();
     $this->Image($cover_path, 0, 0, 150);
     for ($n = 1; $n <= $pagecount; $n++) {
         $tplidx = $this->ImportPage($n);
         //
         $this->addPage();
         $this->useTemplate($tplidx);
     }
     //$this->SetTopMargin(400);
     if ($this->pass != null) {
         $this->SetProtection(array(), $this->pass, $this->owner_pass);
     } else {
         $this->SetProtection(array(), NULL, $this->owner_pass);
     }
     //tak kasi print
     $this->Output($this->title . '-' . $hp . '-' . date('d.m.Y.H.i.s') . '.pdf', 'D');
 }
开发者ID:robotys,项目名称:sacl,代码行数:84,代码来源:pdfest.php


示例18: ___resize


//.........这里部分代码省略.........
             $thumb = imagecreatetruecolor($gdWidth, $gdHeight);
             $this->prepareImageLayer($thumb, $image);
             imagecopyresampled($thumb, $image, 0, 0, 0, 0, $gdWidth, $gdHeight, $this->image['width'], $this->image['height']);
         } else {
             // we have to scale up or down and to _crop_
             if (self::checkMemoryForImage(array($gdWidth, $gdHeight, 3)) === false) {
                 throw new WireException(basename($source) . " - not enough memory to resize to the intermediate image");
             }
             $thumb2 = imagecreatetruecolor($gdWidth, $gdHeight);
             $this->prepareImageLayer($thumb2, $image);
             imagecopyresampled($thumb2, $image, 0, 0, 0, 0, $gdWidth, $gdHeight, $this->image['width'], $this->image['height']);
             if (self::checkMemoryForImage(array($targetWidth, $targetHeight, 3)) === false) {
                 throw new WireException(basename($source) . " - not enough memory to crop to the final image");
             }
             $thumb = imagecreatetruecolor($targetWidth, $targetHeight);
             $this->prepareImageLayer($thumb, $image);
             imagecopyresampled($thumb, $thumb2, 0, 0, $x1, $y1, $targetWidth, $targetHeight, $targetWidth, $targetHeight);
             imagedestroy($thumb2);
         }
     }
     // optionally apply sharpening to the final thumb
     if ($this->sharpening && $this->sharpening != 'none') {
         // @horst
         if (IMAGETYPE_PNG != $this->imageType || !$this->hasAlphaChannel()) {
             // is needed for the USM sharpening function to calculate the best sharpening params
             $this->usmValue = $this->calculateUSMfactor($targetWidth, $targetHeight);
             $thumb = $this->imSharpen($thumb, $this->sharpening);
         }
     }
     // write to file
     $result = false;
     switch ($this->imageType) {
         case IMAGETYPE_GIF:
             // correct gamma from linearized 1.0 back to 2.0
             $this->gammaCorrection($thumb, false);
             $result = imagegif($thumb, $dest);
             break;
         case IMAGETYPE_PNG:
             if (!$this->hasAlphaChannel()) {
                 $this->gammaCorrection($thumb, false);
             }
             // always use highest compression level for PNG (9) per @horst
             $result = imagepng($thumb, $dest, 9);
             break;
         case IMAGETYPE_JPEG:
             // correct gamma from linearized 1.0 back to 2.0
             $this->gammaCorrection($thumb, false);
             $result = imagejpeg($thumb, $dest, $this->quality);
             break;
     }
     if (isset($image) && is_resource($image)) {
         @imagedestroy($image);
     }
     // @horst
     if (isset($thumb) && is_resource($thumb)) {
         @imagedestroy($thumb);
     }
     if (isset($thumb2) && is_resource($thumb2)) {
         @imagedestroy($thumb2);
     }
     if (isset($image)) {
         $image = null;
     }
     if (isset($thumb)) {
         $thumb = null;
     }
     if (isset($thumb2)) {
         $thumb2 = null;
     }
     if ($result === false) {
         if (is_file($dest)) {
             @unlink($dest);
         }
         return false;
     }
     unlink($source);
     // $source is equal to $this->filename
     rename($dest, $source);
     // $dest is the intermediate filename ({basename}_tmp{.ext})
     // @horst: if we've retrieved IPTC-Metadata from sourcefile, we write it back now
     if ($this->iptcRaw) {
         $content = iptcembed($this->iptcPrepareData(), $this->filename);
         if ($content !== false) {
             $dest = preg_replace('/\\.' . $this->extension . '$/', '_tmp.' . $this->extension, $this->filename);
             if (strlen($content) == @file_put_contents($dest, $content, LOCK_EX)) {
                 // on success we replace the file
                 unlink($this->filename);
                 rename($dest, $this->filename);
             } else {
                 // it was created a temp diskfile but not with all data in it
                 if (file_exists($dest)) {
                     @unlink($dest);
                 }
             }
         }
     }
     $this->loadImageInfo($this->filename, true);
     $this->modified = true;
     return true;
 }
开发者ID:ruudalberts,项目名称:ProcessWire,代码行数:101,代码来源:ImageSizer.php


示例19: write

 /**
  * create the new image file already 
  * with the new "IPTC" recorded
  *
  * @access public
  * @return boolean
  */
 public function write()
 {
     //@see http://php.net/manual/pt_BR/function.iptcembed.php
     $content = iptcembed($this->binary(), $this->_filename, 0);
     if ($content === false) {
         throw new Iptc_Exception('Failed to save IPTC data into file');
     }
     @unlink($this->_filename);
     return file_put_contents($this->_filename, $content) !== false;
 }
开发者ID:balooval,项目名称:git_galerie,代码行数:17,代码来源:Iptc.php


示例20: cacheImage


//.........这里部分代码省略.........
            $watermark_width = zp_imageWidth($watermark);
            $watermark_height = zp_imageHeight($watermark);
            $imw = zp_imageWidth($newim);
            $imh = zp_imageHeight($newim);
            $nw = sqrt($imw * $imh * $percent * ($watermark_width / $watermark_height));
            $nh = $nw * ($watermark_height / $watermark_width);
            $r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
            if (!getOption('watermark_allow_upscale')) {
                $r = min(1, $r);
            }
            $nw = round($watermark_width * $r);
            $nh = round($watermark_height * $r);
            if ($nw != $watermark_width || $nh != $watermark_height) {
                $watermark = zp_imageResizeAlpha($watermark, $nw, $nh);
                if (!$watermark) {
                    imageError('404 Not Found', sprintf(gettext('Watermark %s not resizeable.'), $watermark_image), 'err-failimage.png');
                }
            }
            // Position Overlay in Bottom Right
            $dest_x = max(0, floor(($imw - $nw) * $offset_w));
            $dest_y = max(0, floor(($imh - $nh) * $offset_h));
            if (DEBUG_IMAGE) {
                debugLog("Watermark:" . basename($imgfile) . ": \$offset_h={$offset_h}, \$offset_w={$offset_w}, \$watermark_height={$watermark_height}, \$watermark_width={$watermark_width}, \$imw={$imw}, \$imh={$imh}, \$percent={$percent}, \$r={$r}, \$nw={$nw}, \$nh={$nh}, \$dest_x={$dest_x}, \$dest_y={$dest_y}");
            }
            if (!zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh)) {
                imageError('404 Not Found', sprintf(gettext('Image %s not renderable (copycanvas).'), filesystemToInternal($imgfile)), 'err-failimage.png');
            }
            zp_imageKill($watermark);
        }
        // Create the cached file (with lots of compatibility)...
        @chmod($newfile, 0777);
        if (zp_imageOutput($newim, getSuffix($newfile), $newfile, $quality)) {
            //	successful save of cached image
            if (getOption('ImbedIPTC') && getSuffix($newfilename) == 'jpg' && GRAPHICS_LIBRARY != 'Imagick') {
                // the imbed function works only with JPEG images
                global $_zp_images_classes;
                //	because we are doing the require in a function!
                require_once dirname(__FILE__) . '/functions.php';
                //	it is ok to increase memory footprint now since the image processing is complete
                $iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47), '2#115' => $_zp_gallery->getTitle());
                $iptc_data = zp_imageIPTC($imgfile);
                if ($iptc_data) {
                    $iptc_data = iptcparse($iptc_data);
                    if ($iptc_data) {
                        $iptc = array_merge($iptc_data, $iptc);
                    }
                }
                $imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
                $imagename = basename($imgfile);
                $albumname = dirname($imgfile);
                $image = newImage(newAlbum($albumname), $imagename);
                $copyright = $image->getCopyright();
                if (empty($copyright)) {
                    $copyright = getOption('default_copyright');
                }
                if (!empty($copyright)) {
                    $iptc['2#116'] = $copyright;
                }
                $credit = $image->getCredit();
                if (!empty($credit)) {
                    $iptc['2#110'] = $credit;
                }
                $iptc_result = '';
                foreach ($iptc as $tag => $string) {
                    $tag_parts = explode('#', $tag);
                    if (is_array($string)) {
                        foreach ($string as $element) {
                            $iptc_result .= iptc_make_tag($tag_parts[0], $tag_parts[1], $element);
                        }
                    } else {
                        $iptc_result .= iptc_make_tag($tag_parts[0], $tag_parts[1], $string);
                    }
                }
                $content = iptcembed($iptc_result, $newfile);
                $fw = fopen($newfile, 'w');
                fwrite($fw, $content);
                fclose($fw);
                clearstatcache();
            }
            @chmod($newfile, FILE_MOD);
            if (DEBUG_IMAGE) {
                debugLog('Finished:' . basename($imgfile));
            }
        } else {
            if (DEBUG_IMAGE) {
                debugLog('cacheImage: failed to create ' . $newfile);
            }
            imageError('404 Not Found', sprintf(gettext('cacheImage: failed to create %s'), $newfile), 'err-failimage.png');
        }
        @chmod($newfile, FILE_MOD);
        zp_imageKill($newim);
        zp_imageKill($im);
    } catch (Exception $e) {
        debugLog('cacheImage(' . $newfilename . ') exception: ' . $e->getMessage());
        imageError('404 Not Found', sprintf(gettext('cacheImage(%1$s) exception: %2$s'), $newfilename, $e->getMessage()), 'err-failimage.png');
        return false;
    }
    clearstatcache();
    return true;
}
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:101,代码来源:functions-image.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP iptcparse函数代码示例发布时间:2022-05-15
下一篇:
PHP ipsec_idinfo_to_text函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap