via page 14 - Dave's Blog

Search
My timeline on Mastodon

hpl1.JPG : My[confined]Space

2009 Jun 27, 12:29HP Lovecraft as religious propaganda comic.PermalinkCommentshumor comic hp-lovecraft via:chris religion parody cthulhu

PowerShell Scanning Script

2009 Jun 27, 3:42

I've hooked up the printer/scanner to the Media Center PC since I leave that on all the time anyway so we can have a networked printer. I wanted to hook up the scanner in a somewhat similar fashion but I didn't want to install HP's software (other than the drivers of course). So I've written my own script for scanning in PowerShell that does the following:

  1. Scans using the Windows Image Acquisition APIs via COM
  2. Runs OCR on the image using Microsoft Office Document Imaging via COM (which may already be on your PC if you have Office installed)
  3. Converts the image to JPEG using .NET Image APIs
  4. Stores the OCR text into the EXIF comment field using .NET Image APIs (which means Windows Search can index the image by the text in the image)
  5. Moves the image to the public share

Here's the actual code from my scan.ps1 file:

param([Switch] $ShowProgress, [switch] $OpenCompletedResult)

$filePathTemplate = "C:\users\public\pictures\scanned\scan {0} {1}.{2}";
$time = get-date -uformat "%Y-%m-%d";

[void]([reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll"))

$deviceManager = new-object -ComObject WIA.DeviceManager
$device = $deviceManager.DeviceInfos.Item(1).Connect();

foreach ($item in $device.Items) {
        $fileIdx = 0;
        while (test-path ($filePathTemplate -f $time,$fileIdx,"*")) {
                [void](++$fileIdx);
        }

        if ($ShowProgress) { "Scanning..." }

        $image = $item.Transfer();
        $fileName = ($filePathTemplate -f $time,$fileIdx,$image.FileExtension);
        $image.SaveFile($fileName);
        clear-variable image

        if ($ShowProgress) { "Running OCR..." }

        $modiDocument = new-object -comobject modi.document;
        $modiDocument.Create($fileName);
        $modiDocument.OCR();
        if ($modiDocument.Images.Count -gt 0) {
                $ocrText = $modiDocument.Images.Item(0).Layout.Text.ToString().Trim();
                $modiDocument.Close();
                clear-variable modiDocument

                if (!($ocrText.Equals(""))) {
                        $fileAsImage = New-Object -TypeName system.drawing.bitmap -ArgumentList $fileName
                        if (!($fileName.EndsWith(".jpg") -or $fileName.EndsWith(".jpeg"))) {
                                if ($ShowProgress) { "Converting to JPEG..." }

                                $newFileName = ($filePathTemplate -f $time,$fileIdx,"jpg");
                                $fileAsImage.Save($newFileName, [System.Drawing.Imaging.ImageFormat]::Jpeg);
                                $fileAsImage.Dispose();
                                del $fileName;

                                $fileAsImage = New-Object -TypeName system.drawing.bitmap -ArgumentList $newFileName 
                                $fileName = $newFileName
                        }

                        if ($ShowProgress) { "Saving OCR Text..." }

                        $property = $fileAsImage.PropertyItems[0];
                        $property.Id = 40092;
                        $property.Type = 1;
                        $property.Value = [system.text.encoding]::Unicode.GetBytes($ocrText);
                        $property.Len = $property.Value.Count;
                        $fileAsImage.SetPropertyItem($property);
                        $fileAsImage.Save(($fileName + ".new"));
                        $fileAsImage.Dispose();
                        del $fileName;
                        ren ($fileName + ".new") $fileName
                }
        }
        else {
                $modiDocument.Close();
                clear-variable modiDocument
        }

        if ($ShowProgress) { "Done." }

        if ($OpenCompletedResult) {
                . $fileName;
        }
        else {
                $result = dir $fileName;
                $result | add-member -membertype noteproperty -name OCRText -value $ocrText
                $result
        }
}

I ran into a few issues:

PermalinkCommentstechnical scanner ocr .net modi powershell office wia

Free OCR software? You may already have it... - Jon Galloway

2009 Jun 20, 9:39If you have Office installed you may have an OCR library sitting on your hard drive just waiting to be used via C#...PermalinkCommentsocr microsoft office .net automation scanner camera windows technical

Cory Doctorow's craphound.com - Blog Archive - Little Brother option sold to Don Murphy (Natural Born Killers, From Hell, etc)

2009 Jun 19, 3:34"Don Murphy, producer of such films as Natural Born Killers and From Hell, has bought a film option on Little Brother." You should read Little Brother. Its available via Creative Commons so you can, right now, go read the first chapterPermalinkCommentslittle-brother cory-doctorow don-murphy movie film literature book

Mao RTFM vectorize by ~cmenghi on deviantART

2009 Jun 12, 12:17Propaganda poster styled RTFM.PermalinkCommentshumor tshirt mao rtfm internet art propaganda

Paleo-Future: Robots vs. Musicians (1931)

2009 Jun 12, 9:16"This ad from the March 9, 1931 Simpson's Leader-Times (Kittanning, PA) is in no way subtle. The consequences of using recorded music at theatre performances rather than live musicians are, "Monotony in the theatre - corruption of taste - destruction of art." Yikes."PermalinkCommentsvia:ethan_t_hein music advertising technology robot copyright

Why we link: A brief rundown of the reasons your news organization needs to tie the Web together - Publishing 2.0

2009 Jun 12, 9:02"Because linking to sources and resources is the key gesture to being a citizen of the Web and not just a product on the Web...If, on the other hand, you want to embrace the traits that make blogs, Twitter, and so many other online communication tools a vital part of the daily life of your readers, your news site shouldn't feel like an endpoint in the conversation. It should feel like the beginning."PermalinkCommentsvia:sambrook journalism news internet web article link

SCIENCE SCOUTS

2009 Jun 11, 3:16Humorous science merit badges. "The 'I build robots' badge (LEVEL IV): In which, technically technically, the recipient is not in the business of world domination (as dictated by membership rules), but has built a robot that is.", "The 'non-explainer' badge (LEVEL I): Where the recipient can no longer explain what they do to their parents", And other humorous badges.PermalinkCommentshumor web science math nerd badge via:boingboing

Mix an Exploding Drink - Wired How-To Wiki

2009 Jun 4, 3:14You've seen the YouTube clips demonstrating the riotous effect of dropping Mentos into Diet Coke. Why not turn the fizzy fun into an epic party prank of your own? Here's our recipe for a little cocktail we call the Manhattan Project.PermalinkCommentsvia:boingboing mentos meme wired humor coke soda howto alcohol drink for:hellosarah

XML.com: The Atom Link Model

2009 Jun 3, 9:55"A "via" link is simply a link back to the site where you found the article you're linking to. Atom has a link tag for this scenario: ." Is there an HTML version?PermalinkCommentsatom rss xml link syndication via

Social Media Venn Diagram Tee

2009 Jun 2, 11:18"Social Media. Unlocking the awesome potential of behavioral disorders." Can't go wrong with a venn diagram shirt.PermalinkCommentssocial humor shirt facebook twitter via:ericlaw

The Ultimate Lock Picker Hacks Pentagon, Beats Corporate Security for Fun and Profit

2009 Jun 1, 3:21"Marc Weber Tobias can pick, crack, or bump any lock. Now he wants to teach the world how to break into military facilities and corporate headquarters."PermalinkCommentsvia:boingboing hack diy business politics security video lockpicking lock crime wired

What happened to me and the new girl (or: "The girl who cried Webmaster") - The Adventures of Accordion Guy in the 21st Century

2009 Jun 1, 2:03Wow, read this without expectations of what its about. This is the second identity-theft/Internet/personal-relationships story I've read. It makes me think we need VeriSign to do cert verification for personal relationships but then I must remind myself that this must not be very common...PermalinkCommentsvia:swannman identity identity-theft story psychology web blog joey-devilla

A Brief History of Microsoft's Live Search's New Domain Bing

2009 Jun 1, 11:07
Logo for bing! from 2003 via The Wayback MachineLogo for BING* from 2006 via The Wayback MachineKimberly Saia's flickr photo of the Microsoft bing search logo.
When I heard that Live Search is now Bing one of my initial thoughts was how'd they get that domain name given the unavailability of pronouncable four letter .COM domain names. Well, the names been used in the past. Here now, via the Wayback Machine is a brief, somewhat speculative, and ultimately anticlimactic history of bing.com:

The new name reminds me of the show Friends. Also, I hope they get a new favicon - I don't enjoy the stretched 'b' nor its color scheme.

PermalinkCommentsmicrosoft technical domain history search archive dns bing

IR Ink

2009 May 29, 9:01"These inks are completely invisible to the human eye yet can be seen by using a device which can see in the infrared range - such as our modified cameras and camcorders. These inks do not fluoresce in the visible range, cannot be seen with ultraviolet lights and cannot be seen by the human eye alone." Via and not via .PermalinkCommentsir ir-paint ink purchase

CoCam: Infrared Photography: Recipe for Coating Flash Bulbs with Infrared Paint

2009 May 29, 8:59Don't need to cover _flash bulbs_ with infrared paint, but the paint is to block out all but infrared light so could be useful otherwise. ViaPermalinkCommentsir photography recipe ir-paint

Infrared Paint Link Roundup

2009 May 29, 2:50

I like the idea of QR codes, encoding URLs and placing them on real world objects, but the QR codes themselves are kind of ugly. To make them less obvious I thought I could spray QR codes on to an object with an infrared reflective paint and shine infrared light on the QR codes, since most cameras, for instance the camera in my G1 phone, pick up infrared that our eyes do not.

In my search for infrared paint I've found a seller of IR ink (via programming forum) and an Infrared Paint Recipe (via IR FAQ).

In looking for this paint I've found that it comes up a lot in relation to the military for things like paint markers that are visible at night with proper equipment, and paint that absorbs IR light to make vehicles less obvious to night vision goggles. Even though the first reflects infrared light and the second absorbs it websites end up refering to both as infrared paint which made it difficult to search.

Additionally I found links to some other geeky infrared projects:

PermalinkCommentsir paint technical ir infrared qr qr code

Using BitTorrent to Retrieve Objects Stored in Amazon S3

2009 May 29, 12:12"Any object in Amazon S3 that can be read anonymously can also be downloaded via BitTorrent. ... Retrieving a .torrent file for any publicly available object is easy. Simply add a "?torrent" query string parameter at the end of the REST GET request for the object." Yes, this is awesome!PermalinkCommentstorrent amazon s3 bittorrent p2p via:pskomoroch

Movies In Frames

2009 May 26, 10:10"One movie - four frames. That's it." The site has some good ones on here this one is Blade Runner. I added several movies to my Netflix queue from this. Netflix should incorporate this into their site.PermalinkCommentsmovie via:kottke netflix art humor

Our soon-to-be outdated beliefs

2009 May 22, 6:55"So many of our grandparents were racist, and some of our parents are homophobes. Which of our own closely held beliefs will our own children and grandchildren by appalled by?" I thought about this too but didn't come up with as good answers.PermalinkCommentsracism via:kottke
Older EntriesNewer Entries Creative Commons License Some rights reserved.