Escaped path in AppleScript adds leading /
quoted form of also escapes the tilde. quoted form of "~/Pictures" returns '~/Pictures'. open interprets '~/Pictures/' as a relative path, and the default working directory for do shell script is /.

I couldn't get the sqlite commands to work, but try something like this:

path=$(sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db 'select data.value from data'|tail -n1);open -b com.adobe.Photoshop "${path/#~/$HOME}"

Or remove the tilde with AppleScript:

set p to "~/Pictures"
if p starts with "~/" then set p to (system attribute "HOME") &amp; text 2 thru -1 of p


You can also get the desktop picture of the current space with System Events:

tell application "System Events" to picture of current desktop