https://agateau.com/tags/importer/feedPosts tagged importer2012-01-05T21:00:00+01:00Aurélien Gâteaupython-feedgenhttps://agateau.com/2009/gwenview-importerGwenview Importer2009-11-06T21:00:00+01:00<p>I have been quite quiet on Gwenview front lately, getting a job which does not involve two hours in a train everyday and becoming a father for the second time apparently does not help to find free time to hack (how surprising!)</p>
<p>Still I managed to get some work done on the start page and fixed a few bugs here and there. The main improvement though is the implementation of an importer for Gwenview, based on some <a href="http://agateau.com/2009/06/02/back-from-all-hands-uds-karmic/">previous experiment</a>.</p>
<p>Its aim is to require as little manipulation as possible to get your pictures and video imported from your camera. It integrates with Solid so starting the import is just a matter of plugging in your camera/inserting your memory card, and selecting "Download Photos with Gwenview" from the popup which opens. You are then presented with a thumbnail view like the following, where you can select the documents to import as well as the import destination (destination is remembered across imports and defaults to ~/Pictures or whatever xdg defines):</p>
<a href="https://agateau.com/2009/gwenview-importer/20091105-1-thumbnails.png"><img src="https://agateau.com/2009/gwenview-importer/thumb_20091105-1-thumbnails.png" title="20091105-1-thumbnails" height="216" width="300" alt="Thumbnails" class="aligncenter size-medium wp-image-279"/></a>
<p>Clicking "Import Selected" or "Import All" imports the documents to your destination folder. When it is done, the import asks you what to do with the documents on the device.</p>
<a href="https://agateau.com/2009/gwenview-importer/20091105-2-imported.png"><img src="https://agateau.com/2009/gwenview-importer/thumb_20091105-2-imported.png" title="20091105-2-imported" height="216" width="300" alt="Documents have been imported" class="aligncenter size-medium wp-image-280"/></a>
<p>Once you clicked either "Delete" or "Keep", you get this final page:</p>
<a href="https://agateau.com/2009/gwenview-importer/20091105-3-what-next.png"><img src="https://agateau.com/2009/gwenview-importer/thumb_20091105-3-what-next.png" title="20091105-3-what-next" height="216" width="300" alt="What's next?" class="aligncenter size-medium wp-image-281"/></a>
<p>Whenever possible, the importer tries to be smart. For example it automatically goes inside folders as long as they are alone in the hierarchy, so if your pictures are all in /DCIM/FOOBAR/, it will go into this folder directly instead of showing you a single DCIM folder, then a FOOBAR folder. On the other hand, it won't scan the whole device recursively, which could be quite painful if you just plugged a large external hard drive...</p>
<p>Another example is handling of already imported documents. Gwenview Importer will tell you if it skipped documents which have already been imported or if it renamed documents to avoid overwriting existing ones. For example if I select "Keep" in the "Delete or Keep" dialog and in a next import select the 3 imported documents as well as 2 new documents, I get this message (The wording can probably be improved, please send suggestions...):</p>
<a href="https://agateau.com/2009/gwenview-importer/20091105-4-imported2.png"><img src="https://agateau.com/2009/gwenview-importer/thumb_20091105-4-imported2.png" title="20091105-4-imported2" height="216" width="300" alt="Skipped some documents during import" class="aligncenter size-medium wp-image-282"/></a>
<p>Yet another point where the importer tries to be smart is on the name of the imported documents. Nothing is less useful than a series of pictures named PICT0001.JPG, PICT0002.JPG... so by default Gwenview Importer renames your pictures using the shooting date. This can be configured by clicking on the "Settings" button from the thumbnail page, which brings this configuration dialog:</p>
<a href="https://agateau.com/2009/gwenview-importer/20091105-5-settings.png"><img src="https://agateau.com/2009/gwenview-importer/thumb_20091105-5-settings.png" title="20091105-5-settings" height="216" width="300" alt="Settings" class="aligncenter size-medium wp-image-283"/></a>
<p>I spent quite some time working on this formating thing. I tried to make it easy to customize the rename format by:
</p><ul>
<li> providing a preview of the output,</li>
<li>using words instead of single letter variables (ie {date} instead of %d),</li>
<li>making the list of available variables with their description always visible,</li>
<li>making the variable names clickable, so that you can easily insert them</li>
</ul>
It's not as good as what <a href="http://www.layt.net/john/blog/odysseus/a_challenge">Mac OS X can do</a>, but I hope it is easy enough nevertheless. If I get the time to work a bit more on this (read: unlikely to happen :/), I think highlighting the variables in the line edit would be nice.
<p>That's all for now. Tell me what you think of this.</p>
2009-11-06T21:00:00+01:00https://agateau.com/2012/oups-my-burst-shots-are-all-shuffledOups, my burst shots are all shuffled!2012-01-05T21:00:00+01:00<a href="https://agateau.com/2012/oups-my-burst-shots-are-all-shuffled/2011-12-17_12-07-45.jpeg"><img src="https://agateau.com/2012/oups-my-burst-shots-are-all-shuffled/2011-12-17_12-07-45.jpeg" title="The dancer" height="300" width="225" alt="" class="alignright size-full wp-image-1033"/></a>
<p>At the end of December my wife and I were invited with other parents to my daughter last dance lesson of the year.</p>
<p>Of course, I brought my camera with me. I shot a little bit more than 160 pictures from the one hour lesson (if that sounds like a crazy number, then you probably don't have kids...).</p>
<p>Some of them were shot in burst mode, where the camera continuously takes a few pictures per second, increasing the chances the wannabe photographer gets at least one decent picture (and partially explaining the embarrassing large number of shots...)</p>
<b>Importing, aka, the mistake</b>
<p>Back home, I imported the pictures with Gwenview importer and started to comb through them to get rid of the cruft.</p>
<p>Burst mode is fun, but Gwenview importer does not play nice with it: by default it renames imported pictures using the shot date found in the image EXIF information. I like this feature because I find it more expressive to have a picture named "2011-12-17_12-47-47.jpg" than "pict0234.jpg". It has one big drawback though: the precision of time information stored in EXIF is one second. When one shoots in burst mode, more than one picture per second is produced... In such a situation, Gwenview importer inserts a "_n" suffix just before the extension dot, where "n" starts at "1" and is increased until the importer can create a file name which does not exist. It gets even a bit nastier when you realize Gwenview importer does not necessarily import pictures in file order, meaning the "n" values do not necessarily match the order in which the pictures were taken... not good.</p>
<b>Workarounds</b>
<p>I want to address this issue correctly in KDE SC 4.9, but meanwhile here are some workarounds.</p>
<p>If you haven't yet imported your burst-mode pictures, you can either disable image renaming altogether or change the "Rename Format" from "{date}_{time}.{ext.lower}" to "{date}_{time}_{name.lower}.{ext.lower}". This way imported images will still carry the original image name and will be properly ordered. File names will be a bit ugly, but at least you will be safe.</p>
<a href="https://agateau.com/2012/oups-my-burst-shots-are-all-shuffled/gwenview_importer_settings1.png"><img src="https://agateau.com/2012/oups-my-burst-shots-are-all-shuffled/gwenview_importer_settings1.png" title="Configuring Gwenview importer to append the original file name at the end of imported pictures" height="328" width="384" alt="Configuring Gwenview importer to append the original file name at the end of imported pictures" class="aligncenter size-full wp-image-1039"/></a>
<em>Configuring Gwenview importer to append the original file name at the end of imported pictures</em>
<p>If you have already imported the pictures it gets a bit more tricky. I looked at the EXIF information my camera recorded and noticed pictures have a "Exif.Panasonic.SequenceNumber" tag (yes, that sounds vendor-specific :/). This tag is set to 0 for normal pictures, but starts at 1 and goes up for burst-mode pictures. I thus put together "pict-exif-rename", a quick Python script using <a href="http://tilloy.net/dev/pyexiv2/">pyexiv2</a> to rename all images, appending a suffix based on the sequence number if it is greater than 0.</p>
<p>I pushed "pict-exif-rename" as a <a href="https://gist.github.com/1562329/681eb6c245a4592251827c68d9daa66cf17c6479#file_pict_exif_rename">github gist</a>, maybe you will find it useful.</p>
<p>It would be interesting to hear from different camera owners about the presence of the "Exif.Panasonic.SequenceNumber" tag (or an equivalent). You can quickly check its presence by running "exiv2 -Pkv a_picture.jpg | grep SequenceNumber". All pictures taken with my camera (Panasonic DMC-FS16) have this tag, it is set to 0 for non burst-mode pictures.</p>
2012-01-05T21:00:00+01:00