Pedro's Space

A place to share my thoughts with the world.

Archive for January 2014

ReadyNAS Duo Sane Addon

leave a comment »

I spotted that there was a Sane add-on available for the readyNAS duo.

See: http://rnxtras.com/addons/sane-backends-readynas-4-sparc

I was curious to see if it would work with my ancient (now over a decade old, but still functional) Canon canoScan N650U.

As this is an old scanner, canon no longer support it and drivers are not available for 64bit operating systems, however it can be used on both Windows and MacOS with VueScan (https://www.hamrick.com/) but this has a more hefty price tag starting at $49.95 (~£30)

The Sane add-on is a commercial add-on, but at only $2.69 (£1.69) I though it was worth the risk.

Setting up the ReadyNas Sane add on

Having bought the add-on I installed it as an update to the readyNAS in the usual manner. Once the update was installed, and the ReadyNAS restarted, the  add-on showed up in the readyNAS UI, indicating that it was installed.

I connected my scanner to the USB port on the rear or the readyNAS. Unfotunately, the add-on does not give any indication that the scanner had been detected.

Setting up Sane on Windows

Setting up sane on windows was pretty straightforward, simple download sane from 

http://www.filewatcher.com/m/xsane-win32-0.991.zip.10243614-0.html

Extract the file, and copy the sane directory to the c:\ drive

note: sane must be installed in c:\sane, otherwise it will not work.

In order for sane to find the scanner on the network, edit the file c:\sane\etc\sane.d\net.conf and add the ip address of your readyNas on a new line to the end of the file.

in the same directory, check that the dll.conf does not have the net entry commented out (i.e remove the # symbol at the start of the line if it’s there).

You should now be able to launch xsane (in the bin folder), which will detect the scanner and allow you to preview and scan.

Making your sane scanner available as a TWAIN device

saneTwain provides a TWAIN driver that allows the sane scanner to be available to TWAIN capable applications such as Adobe Photoshop (more on photoshop later).

You can download saneTwain from:

http://sanetwain.ozuzo.net/downloads/setup136.exe

Simply run the installer to install.

This installs the saneTwain driver as well as a simple scanning interface called “ScanImage.exe”, that you can find in the program’s install directory.

TWAIN and Photoshop on Windows

Photoshop no longer ships with the TWAIN support, but you can download a TWAIN plugin for Photoshop here:

http://helpx.adobe.com/photoshop/kb/twain-plug-photoshop-cs4-cs5.html

This page also includes installation instructions. (Its simply a case of extraction the zip and copying one file!)

Note that the TWAIN plugin is 32-bit, so if you want to use your scanner, you’ll need to run the 32-bit version of Photoshop (I’ve tested this with CS5).

 

Setting up Sane on Mac OS X

Setting up sane on mac os is a bit more involved:

You’ll need to download TWAIN Sane from the following website:

http://www.ellert.se/twain-sane/

You’ll need the four files that correspond to your version of Mac OS (Mountain Lion or Mavericks)

  • TWAIN Sane Interface
  • Sane Preference Pane
  • Sane backends
  • libusb

Download the above installers and install them in the reverse order to the above list.

Open the sane preferences in the system preferences.

Ensure that net is checked. If you know which driver your scanner uses (in my case the plustek driver) you can uncheck everything except the net and the required driver.

Screen Shot 2014 01 10 at 17 20 45

Click the ‘configure’ radio button corresponding with the ‘net’ entry. The following dialogue will open.

Screen Shot 2014 01 10 at 17 23 08

Enter the IP address of your ReadyNas on a new line at the end of the file (in this example 192.168.1.2).

Click OK, you’ll need to authenticate to save the changes.

 

Sane is now set up.

You can test the set up by entering the following command in a terminal window.

scanimage > test.pnm

 

This should create an image file in your home folder called “test.pnm” (this might take a few seconds).

TWAIN and Photoshop on Mac OS X

As with the windows version of Photoshop, you’ll need to download and install the TWAIN plugin for photoshop (available at the same page linked to above).

Note that you’ll need to run Photoshop CS5 in 32 bit mode (There’s a checkbox to set this on the Get Info dialogue for the application). 

This will not work in Photoshop CS6, as it can only run in 64bit mode.

Apple Image Capture

It should be possible to get the scanner working with Apple Image Capture, however I’ve not managed to get this working at this point in time.

Snac

Although photoshop CS5 and CS6 can coexist on the mac, for reasons that I won’t go into, I don’t like having two versions of the same software on the same machine. 

Since I’d rather use the latest version of Photoshop, which won’t be able to acquire images via TWAIN or via Image Capture, I need another way of acquiring images (TWAIN sane doesn’t provide any GUI for image capture).

Enter Snac.

Snac provides a simple GUI for capturing an image from a Sane source and can also be configured to open a default application after the scanned image has been saved. By default it opens the preview app, but configuring it to open Photoshop CS6 does work.

Perhaps this solution is not as elegant as importing from within Photoshop, it is an usable workaround.

There is one limitation though; Snac can only save images in two formats: PNM and TIFF. 

You can download Snac from:

 http://www.wallner.nu/fredrik/software/snac/

 

Update: I’ve had an issue scanning in greyscale with Snac. It turns out the solution was to simply change the “Greyscale’  to ‘Grey’ in the available modes field in the Snac preferences.

 

Other TWAIN applications

TWAIN is an old technology, rapidly going out of favour so the only other TWAIN application I’ve been able to test is Adobe Acrobat Pro (mac). Unfortunately Acrobat hangs after scanning completes.

Conclusion

Setting up Sane on the readyNas has pros and cons. On the plus side, the scanner can be shared. On the downside, the scanner is in a less convenient location but as this is already the case with the shared printer, its an inconvenience that we already live with and some desk space has been feed up. Lack of 64 bit support on both platforms is not good either. 

It has made VueScan somewhat redundant, other than perhaps the rare occasion that I want to do use the scanner away from home.

 

Written by pedrocadiz13

10/01/2014 at 6:14 pm

Posted in Computing

Geektools, iTunes and appleScripts

leave a comment »

I’ve just rolled back my mac to a previous Time Machine backup to find that quite a bit of stuff had not been backed up. As a result I’ve had to set up geek tools from scratch.

I previously had a geeklet that displayed the information for the currently playing track in iTunes, but quick google had shown that it should also be possible to display the album art as well.  I downloaded a few scripts / geeklets  but couldn’t get any of them to work, or at least not as I’d like so I ended up creating my own.

So here’s a quick write up of what I did, but first here’s a quick description of how this works.

First we need a folder in the current users Pictures folder called iTunes. This will contain three images:

1. empty.png (Transparent image)

Empty

2. default.png

Default

 

3. iTunes.png

The geeklet will run a script to replace the iTunes.png  with the album artwork for the current track or the default image if there is no artwork or no song playing.

 To allow us to get started of make a copy of the default.png file and rename it to iTunes.png. This will give us a visible image to display at first.

Add a picture geeklet to display the iTunes.png.

Next we need to create a script to display the song info and update the image. I did this in a single script although other solutions do this in separate scripts. Open the apple script editor an paste the following code:

set myPath to ((path to home folder) as text) & “Pictures:iTunes:”

set artworkItunes to POSIX path of myPath & “iTunes.png”

set defaultPic to POSIX path of myPath & “default.png”

 

set the_string to “”

 

if running of application “iTunes” then

tell application “iTunes”

 

 

if (player state is paused) or (player state is playing) then

set aTrack to current track

if player state is paused then

set the_string to “iTunes now playing (paused):

else

set the_string to “iTunes now playing:

end if

 

(* Is there any Artwork? *)

if (count of artwork of aTrack) ≥ 1 then

 

set artData to data of artwork 1 of current track

set fileRef to (open for accessartworkItunes with write permission)

try

writeartDatatofileRefstarting at 0

close accessfileRef

on error errorMsg

try

close accessfileRef

end try

error errorMsg

end try

 

else

tell application “Image Events”

set defaultData to opendefaultPic

savedefaultDataasPNGinartworkItunes with replace

closedefaultData

quit

end tell

end if

 

 

set the_string to the_string & “\”” & name of current track & “\”

if artist of current track is not “” then

set the_string to the_string & “Artist: ” & artist of current track & “

end if

 

if album of current track is not “” then

set the_string to the_string & album of current track

end if

 

if year of current track is not 0 then

set the_string to the_string & ” (” & year of current track & “)”

end if

else

set the_string to “iTunes stopped”

tell application “Image Events”

set defaultData to opendefaultPic

savedefaultDataasPNGinartworkItunes with replace

closedefaultData

quit

end tell

end if

 

end tell

 

end if

return the_string

 

Save the script as itunesCombi.scpt

You  can now add a shell geeklet to execute this script with the command:

osascript <path to script>

for example:

osascript /Users/peter/AppleScripts/itunesCombi.scpt

important:  Set both geeklets to refresh every two seconds.

If you launch iTunes, the default image will be shown along with the message “iTunes stopped”. 

If you play a song with artwork, the artwork will be displayed, along with the track info. 

If you pause the song, the artwork is still displayed, as is the track info, but with an extra message indicating that the song is paused.

However, you’ll notice that if you quit iTunes, the picture geeklet displays still displays the album art for the last track played. Ideally we’d want to display the empty.png.

We could add an ‘else’ statement to replace the iTunes.png with the empty.png when iTunes is not running. However as the geeklet refreshes every two seconds, this would mean that the image is replaced every two seconds even when iTunes is not running.

A better solution would be to detect that iTunes has quit, then run a script to swap the image. To do this we’ll need to download and install “Do Something When”.

This is an old program, no longer in development (the developers website is no long available) however it can be downloaded from the following url and it does work in Mavericks: 

http://download.cnet.com/Do-Something-When/3000-2344_4-50417.html

We’ll need to create a script for “Do Something When” to launch, but we’ll need to create the script as an application, otherwise “Do Something When” will open the script in the Apple Script Editor. To do this:

1. Open Automator

2. Choose “Application”

3. Type “Run” in the search field.

4. Drag “Run AppleScript” from the results into your application.

5. Replace the contents of the code editor with the following code :

on run {input, parameters}

 

set myPath to ((path to home folder) as text) & “Pictures:iTunes:”

set artworkItunes to POSIX path of myPath & “iTunes.png”

set blankPic to POSIX path of myPath & “empty.png”

tell application “Image Events”

set defaultData to openblankPic

savedefaultDataasPNGinartworkItunes with replace

closedefaultData

quit

end tell

 

return input

end run


6. Save your application as “iTunesCleanup.app”.

Now we need to set up a new rule in “Do Something When”.  “Do Something When” is installed as a preference pane, so open it via system preferences.

In the ‘Rule Name’ field enter “iTunes Cleanup”

There are two drop downs labeled ‘when’, change the second one to quits, then in the first one choose ‘browse to application’ and browse to iTunes,

There are two drop downs labeled ‘what’. In the first, choose ‘open’ and in the second choose  ‘Select Application or Document’ and browse to the “iTunesCleanup.app”

Set the delay to 2 seconds and save.

Ensure that the rule is active, “Do Something When” is ON and that “Automatically Start on Login is checked.

Screen Shot 2014 01 08 at 12 43 30

And that’s it; the album art will be removed when iTunes is not playing.

Here are some shots of what to expect:

iTunes running, but stopped:

Screen Shot 2014 01 08 at 12 46 33

iTunes playing:

Screen Shot 2014 01 08 at 12 47 19

iTunes paused:

Screen Shot 2014 01 08 at 12 47 57

iTunes not running:

Screen Shot 2014 01 08 at 12 48 28

Written by pedrocadiz13

08/01/2014 at 12:51 pm

Posted in Computing