本文整理汇总了PHP中iptcembed函数的典型用法代码示例。如果您正苦于以下问题:PHP iptcembed函数的具体用法?PHP iptcembed怎么用?PHP iptcembed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iptcembed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例12: output
/**
* Embed IPTC data block and output to standard output
*
* @access public
*/
function output()
{
$sIPTCBlock = $this->_getIPTCBlock();
@iptcembed($sIPTCBlock, $this->_sFilename, 2);
}
示例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));
示例14: write
function write()
{
$data = iptcembed($this->getBinary(), $this->_filename);
$fp = fopen($this->_filename, 'wb');
fwrite($fp, $data);
fclose($fp);
}
示例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);
}