Posts

Showing posts from May, 2012

New Website

For those of you who like video game art my new website is up and running . Its got a whole heap of content from my own personal stuff to renders from my work on DeBlob2. Keen an eye out in the future for an art dump of my current project, but until then, enjoy!

More scribbles.

Image
I'd love to run around this, hopefully without being impaled by some ancient piece of hardware.

Python and the Photoshop Script listener, Part Two

If you read my earlier post about using the scripting listener to help write useful Python code, you probably noticed that there is alot of CharIDtoTypeID going on, followed by one of any number of ambiguous four letter codes. You probably figured out that these are pretty much shorthand codes that call Photoshop functions. While that's useful to know, the raw script listener output does not make it too easy to work out exactly what they are calling. Most of these are listed in Appendix A of the VB , or Javascript , scripting guides. Even better, if you are tech savvy enough and the appendix doesn't contain the information you need, you can download the relevant  PhotoshopSDK  for your version of Photoshop and poke around in the PITerminology.h file. As an example, this VB scripting listener output: idRGBC = objApp.CharIDToTypeID( "RGBC" ) Is calling upon this CharID, as seen in the PITerminology.h file: #define classRGBColor 'RGBC' // key...

Python and the Photoshop Script listener

Image
This little guide is written for Photoshop Cs5. Other versions of Photoshop may have slightly different folder setups and listener output locations.  As discussed in a few of my earlier posts, Python is a great choice for scripting in Photoshop when coupled with a good COM interface and a desire to make monkeywork just go away . But as you are busy putting those monkeys to work it is inevitable that you will come up against a command or two that's not made available in the regular Photoshop scripting documents. CRISIS! The monkeys go on strike.  But wait, there is hope! Introducing awesomeness... The scripting listener is a brilliant plugin for Photoshop. Using it gives you access to many commands that are not included in the Photoshop scripting reference. While active (that is, present in the Automate folder) it spits out a JS and VB log of all all your actions in Photoshop. For the purposes of this guide we are only really interested  in the VB log. Getting useful Pytho...

Quick paintover

Image
A quick paint-over of one of my commute scribbles:

Creating Guides in a Photoshop document using Python- Part Three

Image
Its been pretty straight forward to setup a function that allows a user defined number of guides to be added to an active document. I've plugged it into the Texture Toolset, so that when a user clicks the 'add guides' button, they get presented with: 'One million divisions!' As an example, asking for '1' division will give you a reasonable result.       Ask for a stupid amount and it will give you a stupid result... Whoo! Cyan for the win. But seriously, making the guides script has been a good excuse to use the script listener, and I'm pretty happy with the results.

Awesome error...

Image
You know you are doing something right when you get errors like this:

Creating Guides in a Photoshop document using Python- Part Two

Well. That was actually a lot quicker than I expected. Although the initial code looks like junk, its actually pretty easy to read if you know what you are looking for. Here is my very rapid Python translation that works exactly the same way as the VBS output. #Python translation... and go! import comtypes.client #Create a reference to the PS app psApp = comtypes.client.CreateObject('Photoshop.Application') #Create a ref to the dialog mode. Use mode 3 to use no dialog dialogMode = 3 #Start doing crazy shiz id43 = psApp.CharIDToTypeID( "Mk  " ) desc7 = comtypes.client.CreateObject( "Photoshop.ActionDescriptor" ) #I assume "Nw  " means... no idea. No worries? id44 = psApp.CharIDToTypeID( "Nw  " ) desc8 = comtypes.client.CreateObject( "Photoshop.ActionDescriptor" ) #This is obviously the resulting position, in pixels, followed by a measuement. id45 = psApp.CharIDToTypeID( "Pstn" ) id46 = psApp.CharIDToTypeID( "#Pxl...

Creating Guides in a Photoshop document using Python

When doing FX and sprite sheets I like to rule up my document into the correct UV frames before doing any art. Naturally enough, I thought to myself 'Why don't I just script that?'. Well... it seems that 'guides' are not very natural to Python/VB Photoshop Scripting. Although exposed to Javascript, the guides functionality in Python/VB is just not there. So after trying multiple ways of asking Photoshop nicely, I decided to try out the scripting listener with the intention of just hacking it in (now its personal!). After plugging in the listener Photoshop kindly supplied me with the required information written in VBs. Now all I've got to do is figure out how to make it into a usable Python script! Stay tuned! For anyone who is interested, this is what Photoshop sounds like when it mumbles to itself: REM ======================================================= DIM objApp SET objApp = CreateObject("Photoshop.Application") REM Use dialog mode 3 for show n...

More Sketch

Image
And now for the one and only good thing about my morning/afternoon commute! Random Sketch time!

Python and photoshop- code snippets

I thought I might make a little list of commands that I use *alot* in my Photoshop Python scripts in case they might be useful to other people out there trying to do the same thing. These examples are written using Python 2.7. An invaluable help is the Photoshop Cs4 Visual basic scripting guide . Although the scripting guide does not specifically deal with Python, the majority of the VB code works straight out of the box. Before anything else, you need to set up the COM interface! I recommend using the comtypes module . The win32com module can also do the job, but you will find it very limiting if you want to do anything with paths or selection arrays . This is how I usually create my photoshop COM reference in my scripts: import comtypes.client psApp = comtypes.client.CreateObject('Photoshop.Application') The psApp object that I have created is my reference to the photoshop application. From now on, I can call psApp to execute various actions. It's worth noting that if y...