<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Dark Views &#187; HP</title>
	<atom:link href="http://blog.pdark.de/tag/hp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pdark.de</link>
	<description>Opinions and views about computers, writing SciFi and everything else.</description>
	<lastBuildDate>Wed, 08 Feb 2012 06:43:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.pdark.de' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/7741f06d762e6a53700b2915f21e3d77?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Dark Views &#187; HP</title>
		<link>http://blog.pdark.de</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.pdark.de/osd.xml" title="Dark Views" />
	<atom:link rel='hub' href='http://blog.pdark.de/?pushpress=hub'/>
		<item>
		<title>PyScan 0.6</title>
		<link>http://blog.pdark.de/2009/10/10/pyscan-0-6/</link>
		<comments>http://blog.pdark.de/2009/10/10/pyscan-0-6/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 15:50:52 +0000</pubDate>
		<dc:creator>digulla</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[hplip]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PyQt4]]></category>
		<category><![CDATA[PyScan]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SANE]]></category>
		<category><![CDATA[Scanner]]></category>

		<guid isPermaLink="false">http://blog.pdark.de/?p=717</guid>
		<description><![CDATA[I&#8217;ve done some more work on PyScan. Most work is under the hood but I&#8217;ve got a system to load and save projects and a bug was fixed: If you pressed the Scan button too quickly with 0.4, the last image could have been overwritten. PyScan is now based on hplip 3.9.8. PyScan 0.6.tar.gz (16KB, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=717&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done some more work on PyScan. Most work is under the hood but I&#8217;ve got a system to load and save projects and a bug was fixed: If you pressed the Scan button too quickly with 0.4, the last image could have been overwritten. PyScan is now based on <a href="http://hplipopensource.com/hplip-web/index.html">hplip 3.9.8</a>.</p>
<p><a href="http://www.pdark.de/PyScan-0.6.tar.gz">PyScan 0.6.tar.gz</a> (16KB, MD5 Sum: 2b5e23099be438ceceb69ec23d64cec6)</p>
<p>See the <a href="http://blog.pdark.de/2009/04/18/pyscan-a-little-helper-for-the-hp-cm1312nfi-mfp-scanner/">original post</a> for features and the system requirements.</p>
<br /> Tagged: HP, hplip, Linux, PyQt4, PyScan, Python, SANE, Scanner <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkviews.wordpress.com/717/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkviews.wordpress.com/717/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkviews.wordpress.com/717/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=717&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pdark.de/2009/10/10/pyscan-0-6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8a4d6f03a8879432d8563aefbf48e787?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">digulla</media:title>
		</media:content>
	</item>
		<item>
		<title>PyScan: A Little Helper For The HP CM1312nfi MFP Scanner</title>
		<link>http://blog.pdark.de/2009/04/18/pyscan-a-little-helper-for-the-hp-cm1312nfi-mfp-scanner/</link>
		<comments>http://blog.pdark.de/2009/04/18/pyscan-a-little-helper-for-the-hp-cm1312nfi-mfp-scanner/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 21:20:09 +0000</pubDate>
		<dc:creator>digulla</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PIL]]></category>
		<category><![CDATA[PyQt4]]></category>
		<category><![CDATA[PyScan]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SANE]]></category>
		<category><![CDATA[Scanner]]></category>

		<guid isPermaLink="false">http://blog.pdark.de/?p=586</guid>
		<description><![CDATA[Update: Find the latest version (0.6) here. I recently bought a HP CM1312nfi MFP scanner (multi function device with scanner and color laser printer). After scanning some 1&#8217;000 pages, I&#8217;m still satisfied with the device. The document feeder (ADF) sometimes tries to eat the paper after spitting it out and the colors could be a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=586&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Update: <a href="http://blog.pdark.de/2009/10/10/pyscan-0-6/">Find the latest version (0.6) here</a>.</p>
<p>I recently bought a<a title="Permanent Link to hpaio: unable to read device-id" rel="bookmark" href="http://blog.pdark.de/2009/03/21/hpaio-unable-to-read-device-id/"> HP CM1312nfi MFP scanner</a> (multi function device with scanner and color laser printer). After scanning some 1&#8217;000 pages, I&#8217;m still satisfied with the device. The document feeder (ADF) sometimes tries to eat the paper after spitting it out and the colors could be a little more brilliant but overall, a good deal for the price.</p>
<p>What bothered me was that the &#8220;Start scan&#8221; button <a href="https://bugs.launchpad.net/hplip/+bug/256541">doesn&#8217;t work on Linux</a>. But someone posted a script in the bug report which can poll the button by reading the URL <strong>http://$ip/hp/device/notifications.xml</strong> (replace &#8220;$ip&#8221; with the IP address or DNS name of the scanner). This returns some XML with two interesting elements: <strong>StartScan</strong> and <strong>ADFLoaded</strong>. The first one becomes 1 when someone presses the &#8220;Start scan&#8221; button on the scanner and the second one tells us whether there is some paper in the ADF.</p>
<p>With that and some source code, it was simple to create a little tool that works quite like <a href="http://www.xsane.org/">xsane</a> but fixes a couple of things that annoyed me for a long time:</p>
<ol>
<li>The UI of xsane is dead while it scans</li>
<li>There is no online preview of the scan; you have to open the file in some extra tool to verify that the scan looks OK</li>
<li>xsane doesn&#8217;t know about scan &#8220;projects&#8221;</li>
<li>xsane doesn&#8217;t start to scan when I press the button on the scanner</li>
</ol>
<p>As with all OSS software, this thing can seriously ruin your day, so be a bit careful. One of the biggest problems is the file size: To be able to edit files without loss of quality, TIFF format is the default. Each full page scan takes 26MB, 100 pages need 2.6GB!</p>
<p>Plans for 0.5: Allow to edit projects in the UI, select them, save and load them. Right now, you must define your projects via the command line or by editing the source code.</p>
<p>Download: <a href="http://www.pdark.de/PyScan-0.4.tar.gz">PyScan-0.4.tar.gz</a> (12KB, <a href="http://www.pdark.de/PyScan-0.4.md5">MD5 checksum</a>)</p>
<p>Dependencies (see README.txt for download links):</p>
<ul>
<li>Python 2.6</li>
<li>PyQt4 4.4.3</li>
<li>Python Imaging Library 1.1.6</li>
<li>Python Imaging SANE 1.1.6 (needs included patch; see README.txt for instructions).</li>
</ul>
<h3>Features</h3>
<ul>
<li>Code to load images in a background thread, generate thumbnails (compatible to Konqueror/Dolphin) and display them in a list view</li>
<li>Display a (big) image with various manual and automatic zoom levels and modes (fit to window, percent) with zoom and pan</li>
<li>Online preview of scan in progress</li>
</ul>
<h3>Hideous details of the source</h3>
<p>Again and again, I&#8217;m astonished how simple some tasks are in Python and Qt &#8230; if you&#8217;re willing to accept some &#8220;non-OO-ness&#8221; of the solution. I&#8217;ll explain some things I did here to give you an idea what&#8217;s going on.</p>
<h3>Online preview</h3>
<p>PyScan has an online preview of the currently active scan. If you look at the documentation, the Python Imaging SANE interface offers no way to do that. After looking at the source, I found that the SANE interface simply reads bytes from the SANE scanner module and copies these into a PIL image which was created on the Python side.</p>
<p>So my solution is to be notified that a scan is in progress and then copy said image every second (all 26MB) into a string. That string is then used to build a QImage which is turned into a QPixmap which is then displayed in the right pixmap view. See pilImage2QImage() for the details.</p>
<h3>Background threads</h3>
<p>I also moved all expensive code into threads: Loading big TIFF images, scaling them down to thumbnails, saving the images, etc. All threads have a method to add work to their input queues and they send Qt signals when they&#8217;re done. Continuing the scanning when there is paper in the ADF tray was a bit of a problem, through.</p>
<p>Since the saving of the images is happening in a background thread, the code could start the next scan before the saving was completed. This wasn&#8217;t such a big problem except that the &#8220;scan next image&#8221; code looks for files on the disk to determine the next filename. This would lead to overwrites. So I had to synchronize this somehow. My simple hack was to set a boolean &#8220;waiting&#8221; in the scanner thread which indicates that the scanner has more paper to process and waits for the save thread to complete. When the UI gets the &#8220;image saved&#8221; signal, it triggers the scanner to continue.</p>
<h3>Generating thumbnails</h3>
<p>The last hack in the code is the generation of the thumbnails. The main issue here was that I need the thumbnails for the gallery view really deep down in the Qt render code. Wasting time at that level is really a no-no but at first glance, the API offers no way to defer loading of the images and then later update the items in the list view when the data is available. Keep in mind what I need to do:</p>
<ol>
<li>Load a 26MB file from disk</li>
<li>Scale it with antialiasing</li>
<li>&#8230; for hundreds, possibly thousands of files!</li>
</ol>
<p>My solution: In the render code, I create a <strong>LazyPixmap</strong>. This is just dumb object to save the filename and a placeholder pixmap which is used into the real thumbnail becomes available. The <strong>LazyPixmap</strong> will schedule a job for the <strong>LoaderThread</strong>.</p>
<p>In my first code, I tried to create a <strong>QPixmap</strong> in the <strong>LoaderThread</strong> but that doesn&#8217;t work: Only the UI thread is allowed to create a <strong>QPixmap</strong>. Duh. But luckily, Qt offers the <strong>QImage</strong> class which works even without a UI and which offers basically the same API as <strong>QPixmap</strong>. So the <strong>LoaderThread</strong> can load the image from disk and scale it down (to save memory and avoid heavy computation in the UI thread) right before emitting a &#8220;loaded&#8221; signal.</p>
<p>There are two places where a <strong>LazyPixmap</strong> is used: In the <strong>PixmapWidget</strong> (which can display and zoom a <strong>QPixmap</strong>) and in the <strong>ThumbnailDelegate</strong> which draws the thumbnails for the filenames in the <strong>GalleryModel</strong>.</p>
<p>In the case of the <strong>PixmapWidget</strong>, the signal will be handled in <strong>lazyLoaded()</strong>. Here, we convert the <strong>QImage</strong> into a <strong>QPixmap</strong> (in <strong>lpm.getPixmap()</strong>) and assign that pixmap, recalculate the zoom factor, realign the view, etc.</p>
<p>The <strong>GalleryModel, </strong>I have the problem that I need to tell Qt somehow that the pixmap has changed but the API offers nothing except rendering the whole widget by calling <strong>update()</strong>. This will render at most (on a huge screen) 30 pixmaps. Happens one time per visible pixmap, causes no flicker. Probably not worth to waste another second on it.</p>
<p>If you look at the code, you&#8217;ll see that a class called <strong>KDEThumbnailCache</strong> is used. This class accesses the same thumbnails als konqueror (KDE3) or Dolphin (KDE4). This means once the images are scaled down (either by my code or Dolphin), all tools can quickly load the small, precalculated thumbnails instead of having to scale the 26MB files <em>again</em>.</p>
<h3>Conclusion</h3>
<p>Well, that&#8217;s it for a small walk through the code. Feel free to give feedback if you like PyScan (or not) or when you have patches.</p>
<br /> Tagged: HP, Linux, PIL, PyQt4, PyScan, Python, SANE, Scanner <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkviews.wordpress.com/586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkviews.wordpress.com/586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkviews.wordpress.com/586/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=586&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pdark.de/2009/04/18/pyscan-a-little-helper-for-the-hp-cm1312nfi-mfp-scanner/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8a4d6f03a8879432d8563aefbf48e787?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">digulla</media:title>
		</media:content>
	</item>
		<item>
		<title>hpaio: unable to read device-id</title>
		<link>http://blog.pdark.de/2009/03/21/hpaio-unable-to-read-device-id/</link>
		<comments>http://blog.pdark.de/2009/03/21/hpaio-unable-to-read-device-id/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 13:00:06 +0000</pubDate>
		<dc:creator>digulla</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SANE]]></category>
		<category><![CDATA[Scanner]]></category>

		<guid isPermaLink="false">http://blog.pdark.de/?p=571</guid>
		<description><![CDATA[I recently bought a multi-function device printer scanner (HP Color LaserJet CM1312nfi MFP). Setup on openSUSE 11.1 was pretty painless with the hplip package (version 3.9.2) from packman. The original openSUSE package would core dump. Duh. Today, I had a strange error all of a sudden: scan/sane/soapht.c 486: unable to open device hp:/net/HP_Color_LaserJet_CM1312nfi_MFP?ip=xxx.xxx.xxx.xxx io/hpmud/jd.c 84: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=571&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently bought a multi-function device printer scanner (<a href="http://h10010.www1.hp.com/wwpc/us/en/sm/WF05a/18972-18972-238444-12004-3328086-3558902.html?jumpid=oc_R1002_USENC-001_HP%20Color%20LaserJet%20CM1312nfi%20Multifunction%20Printer&amp;lang=en&amp;cc=us">HP Color LaserJet CM1312nfi MFP</a>). Setup on <a href="http://en.opensuse.org/">openSUSE 11.1</a> was pretty painless with the <a href="http://packman.links2linux.de/package/hplip">hplip package</a> (version 3.9.2) from <a href="http://packman.links2linux.de/">packman</a>. The original openSUSE package would core dump. Duh.</p>
<p>Today, I had a strange error all of a sudden:</p>
<pre>scan/sane/soapht.c 486: unable to open device hp:/net/HP_Color_LaserJet_CM1312nfi_MFP?ip=xxx.xxx.xxx.xxx
io/hpmud/jd.c 84: unable to read device-id</pre>
<p>Of course, I hadn&#8217;t changed anything in my setup &#8230; until I remembered that, for security reasons, I had disabled SMNP in the web interface of the printer. Guess what, after enabling &#8220;SNMP-Lese-Schreib-Zugriff aktivieren&#8221; (&#8220;Activate SNMP-Read-Write access&#8221;), the error went away.</p>
<p>For the record: Most functions of the device are accessible from Linux:</p>
<ul>
<li>Color printing</li>
<li>Scanner</li>
<li>Automatic document feeder (ADF)</li>
<li>Remote printing and scanning</li>
</ul>
<p>I haven&#8217;t yet managed to make the &#8220;Scan to PC&#8221; button on the front of the device work but that&#8217;s just a minor issue for me.</p>
<p>The price/performance ratio is very good. The printouts look very good and the ADF could cope with all media that I&#8217;ve fed him so far (even these thin, glossy, cohesive catalogue pages; you just have to spoon feed them one at a time).</p>
<p>The scanner is good, but not top notch. The quality of the scans is OK, colors are pretty close to the original but the images could be sharper. The scanner uses a CCD line, so no warmup time (if you don&#8217;t have to switch on the whole machine).</p>
<p>If you want better quality color copies, set the resolution to 300 DPI (factory setting is a poor 150 DPI which makes thin lines really smear).</p>
<br /> Tagged: Error, HP, Linux, SANE, Scanner <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/darkviews.wordpress.com/571/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/darkviews.wordpress.com/571/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/darkviews.wordpress.com/571/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pdark.de&amp;blog=6384723&amp;post=571&amp;subd=darkviews&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pdark.de/2009/03/21/hpaio-unable-to-read-device-id/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8a4d6f03a8879432d8563aefbf48e787?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">digulla</media:title>
		</media:content>
	</item>
	</channel>
</rss>
