<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: jpeg code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 05:34:45 GMT</pubDate>
    <description>DZone Snippets: jpeg code</description>
    <item>
      <title>Convert Canon RAW ( .CRW) to jpeg</title>
      <link>http://snippets.dzone.com/posts/show/5702</link>
      <description>This is adapted from http://www.howtofixcomputers.com/forums/digital-photo/my-humble-contribution-wrapper-script-dcraw-linux-4360.html to enable (I think) higher quality interpolation in dcraw and higher quality JPEGs.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DCRAW="dcraw -w -c "&lt;br /&gt;while [ $# -ge 1 ]&lt;br /&gt;do&lt;br /&gt;OJPEG=$(echo $1| perl -pe 's/\.crw$//i' | tr 'A-Z' 'a-z')'.jpeg'&lt;br /&gt;echo "${DCRAW} $1 | cjpeg &gt; ${OJPEG}"&lt;br /&gt;${DCRAW} -q 3 $1 | cjpeg -quality 95 &gt; ${OJPEG} || echo " *PROBLEM*"&lt;br /&gt;# transfer EXIF data from the original raw file&lt;br /&gt;exiftool -overwrite_original -TagsFromFile "$1" "${OJPEG}" &gt;/dev/null&lt;br /&gt;# preserve timestamps as much as possible&lt;br /&gt;# touch -r "$1" "${OJPEG}"&lt;br /&gt;dcraw -z "${OJPEG}"&lt;br /&gt;shift&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 27 Jun 2008 07:01:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5702</guid>
      <author>sandos (John B&#228;ckstrand)</author>
    </item>
    <item>
      <title>Read &amp; Write JPEG COM and EXIF metadata</title>
      <link>http://snippets.dzone.com/posts/show/1021</link>
      <description>This snippet is similar to my &lt;a href=http://bigbold.com/snippets/posts/show/768&gt;previous one&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import jpeg&lt;br /&gt;&lt;br /&gt;#read/write JPEG comments (aka the COM area)&lt;br /&gt;jpeg.getComments(file)&lt;br /&gt;jpeg.setComments(txt, file)&lt;br /&gt;&lt;br /&gt;#read/write some EXIF data&lt;br /&gt;e = jpeg.getExif(file)   #an Exif object&lt;br /&gt;e2 = jpeg.getExif2(file) #an Exif extension segment as Exif instance too&lt;br /&gt;&lt;br /&gt;#quick getter&lt;br /&gt;d = e.dict()&lt;br /&gt;print d['image description']&lt;br /&gt;e.display()  #function to print all tags and their value, type, etc.&lt;br /&gt;&lt;br /&gt;#some tags with an explicit interface, some are writable&lt;br /&gt;print e.description&lt;br /&gt;e.description = "my nice picture"&lt;br /&gt;&lt;br /&gt;#generic read function&lt;br /&gt;print e.get(0x010e)  #value for a tag number you know&lt;br /&gt;print e.get(0x010e, value=False) #get the tag as a Tag instance&lt;br /&gt;&lt;br /&gt;#generic write function&lt;br /&gt;e.set(0x010e, "my nice picture", e.ifd0, 2)&lt;br /&gt;    #e.ifd0, e.exif, e.gps or e.interop, represents the IFD the tag belongs to&lt;br /&gt;    #and 2 represents the fact that the tag is of ASCII type&lt;br /&gt;    #see www.exif.org specifications for details&lt;br /&gt;&lt;br /&gt;#iterate&lt;br /&gt;for tag in e:&lt;br /&gt;   print tag.getValue() #value parsed&lt;br /&gt;   print tag.value      #value raw&lt;br /&gt;   tag.setValue(100)    #change it&lt;br /&gt;&lt;br /&gt;#save the changed Exif segment back into the image file&lt;br /&gt;jpeg.setExif(e, file) &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See more details, and download the module &lt;a href=http://www.emilas.com/jpeg/&gt;here&lt;/a&gt;.</description>
      <pubDate>Tue, 27 Dec 2005 20:07:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1021</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Reading and writing image metadata</title>
      <link>http://snippets.dzone.com/posts/show/768</link>
      <description>The IPTCInfo module allows you to add/edit metadata &lt;br /&gt;to your image. You can download it from &lt;a href=http://cheeseshop.python.org/pypi/IPTCInfo/&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Reading&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from iptcinfo import IPTCInfo&lt;br /&gt;info = IPTCInfo('test.jpg')&lt;br /&gt;print info.keywords, info.supplementalCategories, info.contacts&lt;br /&gt;caption = info.data['caption/abstract']&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Add/Edit&lt;br /&gt;&lt;code&gt;&lt;br /&gt;info = IPTCInfo('test.jpg')&lt;br /&gt;info.data['caption/abstract'] = 'Witty caption here'&lt;br /&gt;info.data['supplemental category'] = ['portrait']&lt;br /&gt;info.save()&lt;br /&gt;info.saveAs('test_out.jpg')  # keep original safe&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Thu, 29 Sep 2005 22:09:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/768</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Installing libjpeg on OS X</title>
      <link>http://snippets.dzone.com/posts/show/38</link>
      <description>Get http://www.ijg.org/files/jpegsrc.v6b.tar.gz, and then:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;tar zxvf jpegsrc.v6b.tar.gz&lt;br /&gt;cd jpeg-6b&lt;br /&gt;cp /usr/share/libtool/config.sub .&lt;br /&gt;cp /usr/share/libtool/config.guess .&lt;br /&gt;./configure --enable-shared --enable-static&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;sudo ranlib /usr/local/lib/libjpeg.a&lt;/code&gt;</description>
      <pubDate>Tue, 05 Apr 2005 20:21:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/38</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
  </channel>
</rss>
