MicrostockGroup
Microstock Photography Forum - General => General Photography Discussion => Topic started by: cascoly on February 04, 2010, 16:56
-
Anyone know where i can find source code [java, asp] that reads the IPTC data?
Basically, when i present an image on a webpage, i want to also show its title, desc and keywords; no need to change anything
i've tried google searches, but all i can find are either standalone exif editors/managers, or expensive image management software toolkots that are massive overkill, so i'm looking for something basic and reasonably priced (< $30)
i'd like to avoid activex or other components that each visitor would have to explicitly set up
steve
-
PhotoMe ! and it's free :) google it ;)
-
try this it might lead you to what you want http://www.codeproject.com/KB/vb/exif_reader.aspx (http://www.codeproject.com/KB/vb/exif_reader.aspx)
-
try this it might lead you to what you want [url]http://www.codeproject.com/KB/vb/exif_reader.aspx[/url] ([url]http://www.codeproject.com/KB/vb/exif_reader.aspx[/url])
looks like it might be what i need - but i'm not using .NET!
after googling some more i did find
http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html (http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html)
i've gotten it to run on my website [click on the images to get exif data]
http://cascoly.com/exiftest.asp (http://cascoly.com/exiftest.asp) so the functions work, and now i just need to work on formatting
-
Anyone know where i can find source code [java, asp] that reads the IPTC data?
What you want to set up is a mini gallery. I'm using a stripped down open source Coppermine Gallery for it, and the IPTC display code is inside "displayimage.php". Of course it's free, and it's php.
-
[url]http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html[/url] ([url]http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html[/url])
It's a nice ajax app but it doesn't do IPTC, only EXIF.
-
Anyone know where i can find source code [java, asp] that reads the IPTC data?
What you want to set up is a mini gallery. I'm using a stripped down open source Coppermine Gallery for it, and the IPTC display code is inside "displayimage.php". Of course it's free, and it's php.
thanks, but i need something more programmable -- i'm using smugmug as my gallery, but i need to extract images on specific content pages - eg http://cascoly.com/trav/turkey/Istanbul.asp?lt=1 (http://cascoly.com/trav/turkey/Istanbul.asp?lt=1)
right now, all the image captions are hard coded on the page, but i'd like something that does it automatically.
ultimately, i want to automatically create alt text and other tags to improve page visibility, rather than doing it by hand...
steve
-
[url]http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html[/url] ([url]http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html[/url])
It's a nice ajax app but it doesn't do IPTC, only EXIF.
yep, but exif at least has the item desc, so i shoul be able to use it for now
s
-
that link you provided mentions he did a plugin in jquery i was just on that site - discovered it by following links on my search from your initial question,
check out the jquery site - lots of interesting stuff
http://jquery.com/ (http://jquery.com/)
-
Anyone know where i can find source code [java, asp] that reads the IPTC data?
Basically, when i present an image on a webpage, i want to also show its title, desc and keywords; no need to change anything
i've tried google searches, but all i can find are either standalone exif editors/managers, or expensive image management software toolkots that are massive overkill, so i'm looking for something basic and reasonably priced (< $30)
i'd like to avoid activex or other components that each visitor would have to explicitly set up
steve
The code below should do the trick if you're OK with PHP...
if (trim($_FILES['myfiles']['name'][$i])!="")
{
$newfile = 'your-image.jpg';
$size = getimagesize ($newfile, $IIM);
if(is_array($IIM))
{
$iptc = iptcparse($IIM["APP13"]);
if (is_array($iptc))
{
foreach (array_keys($iptc) as $s9)
{
$c9 = count ($iptc[$s9]);
for ($i9=0; $i9 <$c9; $i9++)
{
$output = $s9.' = '.$iptc[$s9][$i9];
$begin = substr($output,0,5);
$full = strlen($output);
$len = ($full - 8);
$word = substr($output,-$len);
if ($begin == '2#005')
{
$title = "$word";
}
if ($begin == '2#120')
{
$all_about = "$word";
}
if ($begin == '2#025')
{
if (($i9 < 1) or ($i9 > ($c9 - 1)))
{
$comma = '';
}
else
{
$comma = ', ';
}
$the_tags = "$the_tags" . "$comma" . "$word";
}
}
}
-
PHP has it built in (I think that's the stuff elvinstar is using). Pretty sure you need to turn it on in your php.ini though.
It also only reads strict exif and some bit from the iptc standards. If you'd like to get more than that I'd suggest getting the adobe XMP dev kit. It's complicated as heck, but it's a good kit :)
A 'correct' xmp output includes all 3 major standards, along with any other RDF inclusions.
http://www.adobe.com/devnet/xmp/ (http://www.adobe.com/devnet/xmp/)
Maybe overkill, but thought i'd let you know :)
-
thanks to both responders - at the moment i'd rather avoid php since most of my website is on a server that doesnt support it.
my current need is simple enough i should be able to cobble something from the javascript mentioned earlier
s
-
thanks to both responders - at the moment i'd rather avoid php since most of my website is on a server that doesnt support it.
Ah yes, free sites never have php. But if you're looking for a quick and dirty way to integrate your entire port in a simple HTML page by just a few added HTML lines, Featurepics has a nice solution. In fact, that's the only reason I stay on FP. You can see it at work here (http://bit.ly/D6GMq). Of course, you need to be on FP for that.
Here is the code: (you'll just need to change the contriutor number)
<p>
<IFRAME src='http://www.featurepics.com/Authors/top5Images.aspx?id=882&number=4&bgcolor=ffffff&type=g&order=random' width='533' height='132' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no' FRAMEBORDER='0'></IFRAME>
<IFRAME src='http://www.featurepics.com/Authors/top5Images.aspx?id=882&number=4&bgcolor=ffffff&type=g&order=random' width='533' height='132' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no' FRAMEBORDER='0'></IFRAME>
<IFRAME src='http://www.featurepics.com/Authors/top5Images.aspx?id=882&number=4&bgcolor=ffffff&type=g&order=random' width='533' height='132' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no' FRAMEBORDER='0'></IFRAME>
<IFRAME src='http://www.featurepics.com/Authors/top5Images.aspx?id=882&number=4&bgcolor=ffffff&type=g&order=random' width='533' height='132' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no' FRAMEBORDER='0'></IFRAME>
<IFRAME src='http://www.featurepics.com/Authors/top5Images.aspx?id=882&number=4&bgcolor=ffffff&type=g&order=random' width='533' height='132' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no' FRAMEBORDER='0'></IFRAME>
</p>
I have another sort of integration with Clustershot, but that asks much more work. It's purely based on CSS and JS/HTML with popups. I was experimenting here (http://flemishdreams.com/index.php?option=com_content&view=article&id=95&Itemid=88) with 3 types of solutions and a few images. The 2nd solution takes the least work.
-
Hi this function I wrote for a vb.net a couple of years ago application may help.
Pass in the image path and it will write all the IPTC data to an xml file 8)
I have stripped out the part that populates textboxes and splits the keywords but it should compile ok.
So I would pass img1001.jpj and img1001.xml
I am writing in PHP at the moment and WordPress, so maybe a plugin to turn nextgen into a stocksite.
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Public Function saveDataFromFile(ByVal FileName As String, ByVal toFileName As String) As Boolean
' Declare Variables
Dim imageStream As Stream = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim decoder As BitmapDecoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad)
Dim Mdata As BitmapMetadata = DirectCast(decoder.Frames(0).Metadata, BitmapMetadata)
Dim myXmlSettings As New XmlWriterSettings
myXmlSettings.Indent = True
myXmlSettings.NewLineOnAttributes = True
If Mdata.Count = 0 Then
MessageBox.Show("Error Saving Image " + System.IO.Path.GetFileNameWithoutExtension(FileName))
Return False
End If
' this will say if we are good to go
Dim goodToGo As Boolean = True
' Variables to use for calculating
Dim AddStr As String = "", TempStr As String = ""
' Create a new file
Using ImageWriter As XmlWriter = XmlWriter.Create(toFileName, myXmlSettings)
ImageWriter.WriteComment("www.photographerstripod.com ")
ImageWriter.WriteStartElement("Image")
' File Information
ImageWriter.WriteElementString("Path", FileName)
ImageWriter.WriteElementString("ThumbPath", imageThumbPath)
ImageWriter.WriteElementString("Name", System.IO.Path.GetFileNameWithoutExtension(FileName))
'Caption
TempStr = Trim(Replace(Mdata.Comment, Chr(0), ""))
AddStr = Trim(Replace(TempStr, vbLf, ""))
If AddStr.Length > 128 Then
goodToGo = False
End If
ImageWriter.WriteElementString("Comment", AddStr)
'Description
TempStr = Trim(Replace(Mdata.Subject, Chr(0), ""))
AddStr = Trim(Replace(TempStr, vbLf, ""))
If AddStr.Length > 2000 Then
goodToGo = False
End If
ImageWriter.WriteElementString("Subject", AddStr)
ImageWriter.WriteElementString("Date", Trim(Replace(Mdata.DateTaken, Chr(0), "")))
'Location
TempStr = Trim(Replace(Mdata.Location, Chr(0), ""))
AddStr = Trim(Replace(TempStr, vbLf, ""))
If AddStr.Length > 100 Then
goodToGo = False
End If
If AddStr <> "/" Then
ImageWriter.WriteElementString("Location", AddStr)
Else
ImageWriter.WriteElementString("Location", "")
End If
ImageWriter.WriteElementString("UniqueID", System.IO.Path.GetFileNameWithoutExtension(FileName))
' Keyword Section
Dim KeywordList As ObjectModel.ReadOnlyCollection(Of String) = Mdata.Keywords
ImageWriter.WriteStartElement("Keywords")
If Not KeywordList Is Nothing Then
' All Keywords from the Image
ImageWriter.WriteStartElement("AllKeywords")
For i = 0 To KeywordList.Count - 1
TempStr = Trim(Replace(KeywordList(i), Chr(0), ""))
AddStr = Trim(Replace(TempStr, vbLf, ""))
'None Quotes("") Brackets []
If InStr(AddStr, " ") <> 0 Then
If cmbSyntax.SelectedIndex = 1 Then
AddStr = """" + AddStr + """"
End If
If cmbSyntax.SelectedIndex = 2 Then
AddStr = "[" + AddStr + "]"
End If
End If
ImageWriter.WriteElementString("Word", AddStr)
Next
ImageWriter.WriteEndElement()
Else
ImageWriter.WriteStartElement("AllKeywords")
ImageWriter.WriteElementString("Word", "")
ImageWriter.WriteEndElement()
End If
ImageWriter.WriteEndElement()
ImageWriter.WriteElementString("Validated", goodToGo.ToString)
ImageWriter.WriteEndElement()
ImageWriter.Close()
End Using
Return True
End Function
-
thanks, adeptris - i was afraid the day would come when i needed to upgrade my asp site to .Net; at east this will give me a head start....
steve