MicrostockGroup Sponsors


Author Topic: extracting EXIF/IPTC data online?  (Read 11656 times)

0 Members and 1 Guest are viewing this topic.

« on: February 04, 2010, 16:56 »
0
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


« Reply #1 on: February 04, 2010, 17:17 »
0
PhotoMe !  and it's free :)  google it ;)

« Reply #2 on: February 04, 2010, 17:22 »
0
try this it might lead you to what you want http://www.codeproject.com/KB/vb/exif_reader.aspx

« Reply #3 on: February 04, 2010, 18:13 »
0
try this it might lead you to what you want http://www.codeproject.com/KB/vb/exif_reader.aspx


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

i've gotten it to run on my website [click on the images to get exif data]

http://cascoly.com/exiftest.asp  so the functions work, and now i just need to work on formatting

« Reply #4 on: February 04, 2010, 18:17 »
0
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.

« Reply #5 on: February 04, 2010, 18:35 »
0

« Reply #6 on: February 04, 2010, 18:35 »
0
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

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

« Reply #7 on: February 04, 2010, 18:37 »
0
http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html

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

« Reply #8 on: February 04, 2010, 20:53 »
0
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/

« Reply #9 on: February 04, 2010, 21:06 »
0
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...

Code: [Select]
      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";
}
    }
       }

« Reply #10 on: February 11, 2010, 11:30 »
0
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/
Maybe overkill, but thought i'd let you know :)

« Reply #11 on: February 11, 2010, 16:37 »
0
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

« Reply #12 on: February 11, 2010, 17:49 »
0
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. Of course, you need to be on FP for that.

Here is the code: (you'll just need to change the contriutor number)
Code: [Select]
<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 with 3 types of solutions and a few images. The 2nd solution takes the least work.

« Reply #13 on: February 11, 2010, 18:28 »
0
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.

Code: [Select]
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Windows.Media
Imports System.Windows.Media.Imaging

Code: [Select]
 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

« Last Edit: February 11, 2010, 18:42 by Adeptris »

« Reply #14 on: February 12, 2010, 12:41 »
0
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


 

Related Topics

  Subject / Started by Replies Last post
4 Replies
5971 Views
Last post April 05, 2006, 12:38
by S.
6 Replies
6565 Views
Last post February 01, 2007, 23:48
by epixx
3 Replies
3347 Views
Last post July 01, 2009, 07:39
by DWL
26 Replies
6307 Views
Last post May 04, 2013, 08:08
by cascoly
4 Replies
2619 Views
Last post December 10, 2017, 02:05
by Chichikov

Sponsors

Mega Bundle of 5,900+ Professional Lightroom Presets

Microstock Poll Results

Sponsors