<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pario TechnoBlob &#187; jhead</title>
	<atom:link href="http://pario.no/tag/jhead/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 26 Apr 2012 08:18:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Rename files by wildcard pattern and correct the EXIF timestamp metadata</title>
		<link>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/</link>
		<comments>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:05:58 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[exiv2]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[JPG]]></category>
		<category><![CDATA[mmv]]></category>
		<category><![CDATA[NEF]]></category>
		<category><![CDATA[Nikon]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[Sony]]></category>

		<guid isPermaLink="false">http://pario.no/?p=467</guid>
		<description><![CDATA[This is a little script I&#8217;ve written to correct all my image files since the EXIF timestamp information is one hour out of sync. The filenames have been renamed to comply to the EXIF information and has to be renamed again because of the one hour scew. The filename can look something like this 20080102-1201_DSC_0910.JPG [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little script I&#8217;ve written to correct all my image files since the EXIF timestamp information is one hour out of sync. The filenames have been renamed to comply to the EXIF information and has to be renamed again because of the one hour scew. The filename can look something like this 20080102-1201_DSC_0910.JPG where the name is built up like YYYYMMDD-HHMM_Original_Filename.JPG<br />
<strong>Remember to backup your imagefiles before you continue. You have been warned!</strong></p>
<h2>Rename files using wildcard pattern</h2>
<p>This is the files we are going to rename</p>
<pre>
20080102-1201_DSC_0910.JPG
20080105-1923_DSC_1006.JPG
20080111-1220_DSC00189.JPG
20080122-0929_DSC00190.JPG</pre>
<p>The <strong>mmv</strong> command is a command that lets you move/copy/append/link multiple files by wildcard patterns. It can be installed in Debian (or Debian based distributions like Ubuntu) by issuing the command</p>
<pre>
# aptitude install mmv</pre>
<p>Now rename the files back to their original name</p>
<pre>
# mmv "*_DSC*" "DSC#2"</pre>
<p>The result after this operation looks like this</p>
<pre>
DSC_0910.JPG
DSC_1006.JPG
DSC_1179.JPG
DSC_1302.JPG
DSC_1587.JPG</pre>
<h2>Correct the EXIF timestamp using exiv2</h2>
<p>Next adjust the EXIF information stored in the image files to fix the one hour difference. This can be done using different EXIF tools like <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">exiftool</a>, but I will show you how it can be done using <a href="http://www.sentex.net/~mwandel/jhead/">jhead</a> and <a href="http://www.exiv2.org">exiv2</a>. The advantage with <strong>exiv2</strong> is that it can also handle Nikon NEF files while <strong>jhead</strong> only can prosess JPG. </p>
<p>The current timestamp can be determined as follows</p>
<pre>
# exiftool DSC_0910.JPG | grep "File Mo"</pre>
<p>The result in this case is</p>
<pre>
File Modification Date/Time : 2008:01:02 08:34:09</pre>
<h3>Adjust EXIF time info one hour forward using exiftool</h3>
<pre>
# exiftool -AllDates+=1 DSC_0910.JPG</pre>
<h3>Other tools that could have done the job</h3>
<h4>Adjust EXIF time info one hour forward using jhead</h4>
<pre>
# jhead -ta +1 DSC_0910.JPG</pre>
<p>Install the <strong>jhead</strong> package using aptitude as mentioned earlier for the mmv package</p>
<h4>Adjust EXIF time info one hour forward using exiv2</h4>
<pre>
# exiv2 ad -a 1 DSC_0910.JPG</pre>
<h2>Rename files back to YYYYMMDD-HHMM_Original_Filename.JPG</h2>
<p>It is now time to rename the files back to the YYYYMMDD-HHMM_Original_Filename.JPG format I used before this operation. This operation has been describe in a previous post named <a href="http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/">Rename image files according to EXIF date</a></p>
<pre>
exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls D*)</pre>
<h2>The script</h2>
<pre>
#!/bin/bash -x
# Needed software:
# exiftool
# exiv2
# mmv

# Script tested on Nikon D80 and Sony Cybershot DSC-W12 files

# Make a printout of how the files look like now
ls -l > repair_name_and_exif_before.txt

# Rename files to remove date formatting back to original name
mmv "*_DSC*" "DSC#2"

# Change EXIF info on JPG files (order is important)
exiftool -overwrite_original -AllDates+=1 D*.JPG
# Preserve date/time of original file when writing
exiftool -overwrite_original '-DateTimeOriginal>FileModifyDate' D*.JPG

# Change EXIF info on NEF files (order is important)
exiftool -overwrite_original -AllDates+=1 '-DateTimeOriginal>FileModifyDate' D*.NEF
# Preserve date/time of original file when writing
exiftool -overwrite_original '-DateTimeOriginal>FileModifyDate' D*.NEF

# Rename files back to date formatting (YYYYMMDD-HHMM_Filename) based on the new EXIF info
exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls D*)

# Make a printout of how the files look like after conversion
ls -l > repair_name_and_exif_after.txt
</pre>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.sno.phy.queensu.ca\/~phil\/exiftool\/","http:\/\/www.sentex.net\/~mwandel\/jhead\/","http:\/\/www.exiv2.org"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDkvMDIvcmVuYW1lLWZpbGVzLWJ5LXdpbGRjYXJkLXBhdHRlcm4tYW5kLWNvcnJlY3QtdGhlLWV4aWYtdGltZXN0YW1wLW1ldGFkYXRhLzx3cHRiPlJlbmFtZSBmaWxlcyBieSB3aWxkY2FyZCBwYXR0ZXJuIGFuZCBjb3JyZWN0IHRoZSBFWElGIHRpbWVzdGFtcCBtZXRhZGF0YTx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/09/02/rename-files-by-wildcard-pattern-and-correct-the-exif-timestamp-metadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename image files according to EXIF date</title>
		<link>http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/</link>
		<comments>http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 07:05:46 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[D80]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[exiv2]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[ms-dos]]></category>
		<category><![CDATA[NEF]]></category>
		<category><![CDATA[Nikon]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/</guid>
		<description><![CDATA[This rename trick can be run in Windows, Linux and even Mac since the commandline program I&#8217;m going to use, exiv2, is available in all three platforms. Rename all image files in current folder to the format YYYYMMDDHHMM_Filename.EXT This has been tested on my Nikon D80 JPEG and NEF image files. Linux exiv2 -r'%Y%m%d-%H%M_:basename:' rename [...]]]></description>
			<content:encoded><![CDATA[<p>This rename trick can be run in Windows, Linux and even Mac since the commandline program I&#8217;m going to use, <a href="http://www.exiv2.org/">exiv2</a>, is available in all three platforms. Rename all image files in current folder to the format YYYYMMDDHHMM_Filename.EXT</p>
<p>This has been tested on my Nikon D80 JPEG and NEF image files.</p>
<p><strong>Linux</strong></p>
<pre>
exiv2 -r'%Y%m%d-%H%M_:basename:' rename $(ls)</pre>
<p><strong>Windows (from the command prompt)</strong></p>
<pre>
exiv2.exe -r %Y%m%d-%H%M_:basename: rename d*</pre>
<p><strong>Windows (in a MS-DOS batch file)</strong></p>
<pre>
exiv2.exe -r %%Y%%m%%d-%%H%%M_:basename: rename d*</pre>
<p>You have to add an extra % if you are going to use exiv2 in a Windows batch file, because % in batch files is treated as a variable and not as a switch to exiv2. </p>
<p>These examples require that you have access to the <strong>exiv2</strong> program from the current folder.</p>
<p><strong>Result</strong><br />
Now my image files have names like</p>
<pre>
20071022-1202_DSC_9727.JPG
20071022-1202_DSC_9727.NEF</pre>
<p><strong>Change in workflow</strong><br />
Since I rename all my files in the format YYYYMMDD-HHMM_Filename I&#8217;ve included it in my image &#8220;workflow&#8221; (a simple MS-DOS batch file) I wrote about in <a href="http://pario.no/2007/05/23/rotate-images-depending-on-the-exif-orientation-tag/">Rotate images depending on the EXIF orientation post</a>.</p>
<p>This has been tested successfully on the Windows exiv2 version 0.16</p>
<p><a href="http://pario.no/wp-content/uploads/2008/01/rotate.bat" title="rotate.bat">The new batch file can be downloaded here</a>.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.exiv2.org\/"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMDEvMTQvcmVuYW1lLWltYWdlLWZpbGVzLWFjY29yZGluZy10by1leGlmLWRhdGUvPHdwdGI%2BUmVuYW1lIGltYWdlIGZpbGVzIGFjY29yZGluZyB0byBFWElGIGRhdGU8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/01/14/rename-image-files-according-to-exif-date/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Resize and watermark images using Imagemagick</title>
		<link>http://pario.no/2007/12/30/resize-and-watermark-images-using-imagemagick/</link>
		<comments>http://pario.no/2007/12/30/resize-and-watermark-images-using-imagemagick/#comments</comments>
		<pubDate>Sun, 30 Dec 2007 16:33:31 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[jhead]]></category>

		<guid isPermaLink="false">http://pario.no/2007/12/30/373/</guid>
		<description><![CDATA[This is a modified version of my Resize of images in a folder with imagemagick post back in February. Only difference this time is that i strips out EXIF tags and the script has been cleaned up a bit. Click on the image to see the result in full size. #!/bin/bash # Description: # Script [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pario.no/wp-content/uploads/2008/01/dsc_9645_cropped_resized_320.JPG" title="Tina resized"><img src="http://pario.no/wp-content/uploads/2008/01/dsc_9645_cropped_resized_320.thumbnail.JPG" alt="Tina resized" /></a>This is a modified version of my <a href="http://pario.no/2007/02/02/resize-of-images-in-folder-with-imagemagick/">Resize of images in a folder with imagemagick</a> post back in February. Only difference this time is that i strips out EXIF tags and the script has been cleaned up a bit. Click on the image to see the result in full size.</p>
<pre>
#!/bin/bash

# Description:
# Script to resize JPG images to desired width defined in IMAGESIZE variable.
# EXIF tags is also removed from the result images.
# Software needed:
# jhead - http://www.sentex.net/~mwandel/jhead/
# imagemagick - http://www.imagemagick.org

IMAGESIZE="320 480"
for IMAGEFILE in $(ls|grep JPG)
do
        for I in $IMAGESIZE
        do
                # create directories if needed
                if [ ! -d $I ]
                then
                        mkdir $I
                fi

                # Strip EXIF tag information from source file
                jhead -purejpg $IMAGEFILE

                # Resize file
                base=`basename $IMAGEFILE .JPG`_Resized_$I.JPG
                convert $IMAGEFILE -resize $I $base

                # Watermark the file
                width=`identify -format %w $base`
                convert -background '#0008' -fill white -gravity center -size ${width}x15 \
                -font Verdana -pointsize 10 \
                caption:"Copyright © 2007 Pario.no" \
                +size $base +swap -gravity south -composite $I/$base;

                # delete resized file
                rm $base
        done

        # Delete source file (DO NOT USE YOUR ORIGINAL FILE!)
        rm $IMAGEFILE
done</pre>
<p>You can <a href="http://pario.no/wp-content/uploads/2007/12/resize.sh" title="resize.sh">download my resize, watermark bash script here.</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMTIvMzAvcmVzaXplLWFuZC13YXRlcm1hcmstaW1hZ2VzLXVzaW5nLWltYWdlbWFnaWNrLzx3cHRiPlJlc2l6ZSBhbmQgd2F0ZXJtYXJrIGltYWdlcyB1c2luZyBJbWFnZW1hZ2ljazx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/12/30/resize-and-watermark-images-using-imagemagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strip EXIF tags from JPG files</title>
		<link>http://pario.no/2007/11/18/strip-exif-tags-from-jpg-files/</link>
		<comments>http://pario.no/2007/11/18/strip-exif-tags-from-jpg-files/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 23:46:33 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[JPG]]></category>

		<guid isPermaLink="false">http://pario.no/2007/11/18/strip-exif-tags-from-jpg-file/</guid>
		<description><![CDATA[Sometimes it&#8217;s a good idea to remove the hidden data a JPG file contains, like when you publish picures on the Internet. An easy way to remove all EXIF-tags from your JPG files is to run the command using jhead jhead -purejpg *.jpg]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s a good idea to remove the hidden data a JPG file contains, like when you publish picures on the Internet.<br />
An easy way to remove all EXIF-tags from your JPG files is to run the command using <a href="http://www.sentex.ca/~mwandel/jhead/">jhead</a><br />
<code><br />
jhead -purejpg *.jpg</code></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.sentex.ca\/~mwandel\/jhead\/"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMTEvMTgvc3RyaXAtZXhpZi10YWdzLWZyb20tanBnLWZpbGVzLzx3cHRiPlN0cmlwIEVYSUYgdGFncyBmcm9tIEpQRyBmaWxlczx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/11/18/strip-exif-tags-from-jpg-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rotate images depending on the EXIF Orientation Tag</title>
		<link>http://pario.no/2007/05/23/rotate-images-depending-on-the-exif-orientation-tag/</link>
		<comments>http://pario.no/2007/05/23/rotate-images-depending-on-the-exif-orientation-tag/#comments</comments>
		<pubDate>Wed, 23 May 2007 21:18:16 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[EXIF]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[jpegtran]]></category>
		<category><![CDATA[orientation]]></category>

		<guid isPermaLink="false">http://hhj.no/wordpress/2007/05/23/rotere-bilder-ut-i-fra-exif-orientation-tag-i-windows/</guid>
		<description><![CDATA[Automatic rotation of JPG images (inclusive EXIF thumbnail) can be performed by using jhead.exe and jpegtran.exe in Windows. jhead -ft -autorot *.JPG All JPG-files in that folder will be rotated and file time (time and date of exposure) will be set according to the EXIF info. -autorot Using the &#8216;Orientation&#8217; tag of the Exif header, [...]]]></description>
			<content:encoded><![CDATA[<p>Automatic rotation of JPG images (inclusive EXIF thumbnail) can be performed by using <a href="http://www.sentex.net/~mwandel/jhead/jhead.exe">jhead.exe</a> and <a href="http://sylvana.net/jpegcrop/jpegtran/jpegtran.exe">jpegtran.exe</a> in Windows.</p>
<pre>jhead -ft -autorot *.JPG</pre>
<p>All JPG-files in that folder will be rotated and file time (time and date of exposure) will be set according to the EXIF info.<br />
<span id="more-220"></span></p>
<blockquote><p> <strong>-autorot</strong><br />
Using the &#8216;Orientation&#8217; tag of the Exif header, rotate the image so that it is upright. The program &#8216;jpegtran&#8217; is used to perform the rotation. This program is present in most Linux distributions. For Windows, you need to get a copy of it. After rotation, the orientation tag of the EXIF header is set to &#8217;1&#8242; (normal orientation). The Exif thumbnail is also rotated as of Jhead version 2.5. Other fields of the Exif header, including dimensions are untouched, but the JPEG height/width are adjusted.<br />
This feature is especially useful with newer digital cameras, which set the orientation field in the Exif header automatically using a built in orientation sensor in the camera.</p></blockquote>
<blockquote><p> <strong>-ft</strong><br />
Sets the file&#8217;s system time stamp to what is stored in the EXIF header.</p></blockquote>
<p>This is the way to fix the Orientation EXIF tag if a picture is rotated, but the EXIF Orientation tag doesn&#8217;t reflect this change.</p>
<pre>
jhead -ft -norot DSC_XXX.JPG</pre>
<blockquote><p> <strong>-norot</strong><br />
Clears the Exif header rotation tag without altering the image. You may find that your images have rotation tags in them from your camera, but you already rotated them with some lossless tool without clearing the rotation tag. Now your friendly browser rotates the images on you again because the image rotation tag still indicates the image should be rotated. Use this option to fix this problem. You may also want to regenerate the thumbnail using the -rgt option.</p></blockquote>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/www.sentex.net\/~mwandel\/jhead\/jhead.exe","http:\/\/sylvana.net\/jpegcrop\/jpegtran\/jpegtran.exe"];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDcvMDUvMjMvcm90YXRlLWltYWdlcy1kZXBlbmRpbmctb24tdGhlLWV4aWYtb3JpZW50YXRpb24tdGFnLzx3cHRiPlJvdGF0ZSBpbWFnZXMgZGVwZW5kaW5nIG9uIHRoZSBFWElGIE9yaWVudGF0aW9uIFRhZzx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2007/05/23/rotate-images-depending-on-the-exif-orientation-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

