IPTC Infos after uploads are gone

HomeForums(E)2 Photo Gallery (The Open Source One)Sample of (E)2 Photo GalleryIPTC Infos after uploads are gone

Tagged: , ,

This topic has 8 voices, contains 16 replies, and was last updated by   694 days ago.

Viewing 2 posts - 16 through 17 (of 17 total)
Author Posts
Author Posts
March 18, 2009 at 2:32 pm #1294

E2

Add the IPTC info to your photos via Photoshop or any photo editing software that allows you to add IPTC/meta data to your images. If it’s there the script will read it into the gallery. It only grabs: Title, Description, copyright, author

June 28, 2010 at 5:58 am #1295

Hello!

I hope the author does not take offense, but a small intervention completed the source code. In addition, the JPEG files, if there are times it is written into the IPTC info of the uploaded file.
The amendment is a simple function of two and five series of additions is:
// Functions
function read_metadata( $file )
{ $metadata = array(); list($width, $height, $type, $attr) = getimagesize($file, $info);
if(isset($info['APP13']))
{ $iptc = iptcparse($info['APP13']);
if(!empty($iptc["2#005"][0]))
{ $src_title = $iptc['2#005'][0];
$src_title = str_replace(“r”, “
“, $src_title);
$src_title = addslashes($src_title);
} else
$src_title = ”;
$metadata[0] = $src_title;
if(!empty($iptc["2#030"][0]))
{ $src_date = $iptc['2#030'][0];
$src_date = str_replace(“r”, “
“, $src_date);
$src_date = addslashes($src_date);
} else
$src_date = ‘ ‘.date(‘Y-m-d’, time());
$metadata[1] = $src_date;
if(!empty($iptc["2#110"][0]))
{ $src_provider = $iptc['2#110'][0];
$src_provider = str_replace(“r”, “
“, $src_provider);
$src_provider = addslashes($src_provider);
} else
$src_provider = ”;
$metadata[2] = $src_provider;
if(!empty($iptc["2#080"][0]))
{ $src_author = $iptc['2#080'][0];
$src_author = str_replace(“r”, “
“, $src_author);
$src_author = addslashes($src_author);
} else
$src_author = ”;
$metadata[3] = $src_author;
if(!empty($iptc["2#116"][0]))
{ $src_copyright = $iptc['2#116'][0];
$src_copyright = str_replace(“r”, “
“, $src_copyright);
$src_copyright = addslashes($src_copyright);
} else
$src_copyright = ”;
$metadata[4] = $src_copyright;
if(!empty($iptc["2#120"][0]))
{ $src_description = $iptc['2#120'][0];
$src_description = str_replace(“r”, “
“, $src_description);
$src_description = addslashes($src_description);
} else
$src_description = ”;
$metadata[5] = $src_description;
if(!empty($iptc["2#040"][0]))
{ $src_instructions = $iptc['2#040'][0];
$src_instructions = str_replace(“r”, “
“, $src_instructions);
$src_instructions = addslashes($src_instructions);
} else
$src_instructions = ”;
$metadata[6] = $src_instructions;
}
else
{
$metadata[0] = ‘ ‘;
$metadata[1] = ‘ ‘.date(‘Y-m-d’, time());
$metadata[2] = ‘ ‘;
$metadata[3] = ‘ ‘;
$metadata[4] = ‘ ‘;
$metadata[5] = ‘ The file did not have the information!’;
$metadata[6] = ‘ ‘;
}
return $metadata;
}
function copy_metadata($image_new, $title, $date, $provider, $autor, $copyright, $description, $instructions)
{
$size = getimagesize ($image_new, $info);
$iptc_old["2#005"][0] = $title;
$iptc_old["2#030"][0] = $date;
$iptc_old["2#110"][0] = $provider;
$iptc_old["2#080"][0] = $autor;
$iptc_old["2#116"][0] = $copyright;
$iptc_old["2#120"][0] = $description;
$iptc_old["2#040"][0] = $instructions;
$iptc_new = “”;
foreach (array_keys($iptc_old) as $s)
{ $tag = str_replace(“2#”, “”, $s);
$c = count ($iptc_old[$s]);
for ($i=0; $i <$c; $i++)
{ $iptc_new .= iptc_maketag(2, $tag, $iptc_old[$s][$i]); }
}
$mode = 0;
$content = iptcembed($iptc_new, $image_new, $mode);
if ( ($size['mime']) === “image/jpeg” )
{ $fp = fopen($image_new, “w”);
fwrite($fp, $content);
fclose($fp);
}
}

// Addition of the big picture should be the case!
IF ($ handle-> Process)
{
// Existing lines
…….
// Addition
/* iptc info read */
$filejpeg = false;
if ($handle->file_src_mime===’image/jpeg’)
{ $filejpeg=true; $metadata=read_metadata($handle->file_src_pathname); }
/* iptc info write */
if ($filejpeg)
{ copy_metadata($handle->file_dst_pathname, $metadata[0], $metadata[1], $metadata[2], $metadata[3], $metadata[4], $metadata[5], $metadata[6]); }
}

I work well, I hope someone else can.

Viewing 2 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic.