View Full Version : scripting....

05 May 2005, 11:10 AM
hey people,

I am trying to automate the process for tileable textures, I want to remove obvious patterns in images but need to tile them to see it better.
What i mean is, I want to have a 256x256 texture, and make photoshop create a new larger document and fill this with the previous pattern but tiled 4x4 or whatever. and maybe have it update when i change the original.

When i created the action, i select the first document and define pattern, then create a 1024x1024 and fill the canvas with this new pattern, but the action creates a pattern ID for every pattern and it won't override it, so everytime i run this action the document fills with another pattern....not the one i want, i even rename and delete the previous pattern but it doesn't work.

What i need is a script to create a temp pattern and override itself everytime i run the script. i don't think this is difficult, but i am not a programmer type person and i can't devote the time to learn a programming language for just this one thing, but hopefully someone here is kind enough to steer me the right way....or make one for me ;)

05 May 2005, 11:15 PM


05 May 2005, 08:36 AM
I do this sometimes, but I'm not sure you can get Photoshop to do exactly what you want. You can specify which pattern you want an action to delete, but from what I just tried, you don't seem to be able to specify which one you want to fill with.

You could map it on a plane in your 3d app, tile it four times and look at that instead?

05 May 2005, 11:15 AM
It's well easy to obtain a new document filled with the pattern, but not using patterns (which are a bit dodgy to use because of unique IDs).

Let me tell you how i would do it, and then let me go home and check if it could work using patterns, and post back tomorrow.

I would just open the 256x256, select all, and then paste it into a new document 4 times.
Which would give it a 1024x1024 document.

It can be done with actions I guess but I'll try to do a workable script for tomorrow.

05 May 2005, 11:21 AM
You could try using actions in combo with a lotta moving and copy pasting.

Say you've got a 256x256 texture.

1.Canvas size>512x512 (you'll wan't your current texture in the corner so select a certain position)

2. Duplicate the layer.

3. I dunno if this was what it is, but with the move tool you should be able to align the image to a certain side, align it so that you'll have the texture twice, next to eachother or above eachother.

4. Merge down and fill the to other images the same way as the first one (but now you've got a doubled one already so you've only got to do it once more)

05 May 2005, 02:24 PM
xeppitz: you're right actually.
this action works for a 256 texture (

problem is .. you can't set 'new document' to open at 200% of the texture you just copied, you have to specify a pixel or metric dimension.. so you can't make one generic action that'll always work, you have to make separate ones for different size textures.

I think ;)

05 May 2005, 07:01 PM
xeppitz: you're right actually.
this action works for a 256 texture (

Yeay! And I'm one step further from n00bism.

Anyways, as he gave a 256x256 as an example i figured he was doin it for game development of something like that wich needs images within the power of 2. (128x128, 256x256, 512x512.

You could also start the action with changing the image size to 256x256.

05 May 2005, 11:28 PM
yeh i have tried that, coping into a new document and pasting around but the problem is for a 256 and i decide i want a 1024 not a 512, then coping and pasting will be inadequate....thats why i decided for fill with pattern....maybe like you guys said having multiple ones for different resolutions...would be the easiest.

mlkdesign if you are still working on the script that would be dandy

plaf yes your works well, almost the same as mine only with a few extra step, like align...which will prove useful, i was just moving the image layers but aligning might be helpful i think. I might try again for this action.

for the script, it would be great if you could just get a dialog box and type 2 or 3 or 4 and it will find the image size and multiply it....if only...i think i might have to learn java or VB...sigh...its too hard ;)

05 May 2005, 05:17 PM
I'm working on it, but on a mac, and i'm not used to them, it'll be ready soon.

05 May 2005, 06:44 PM
I'm in a hurry i don't have much time to explain how it works but place this inside a .js file and run it, it should be self-explanatory

//written by mlk –
// if it doesn’t work, blame the syntax !

var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.displayDialogs = DialogModes.NO;

if(app.documents.length != 0){

var origiDoc = app.activeDocument;

var widthMult = prompt(“Width multiplier”,4);
var heightMult = prompt(“Height multiplier – default value same as width”,widthMult);
widthMult = parseInt(widthMult);
heightMult = parseInt(heightMult);

var infoArray = [app.activeDocument.width.value,app.activeDocument.height.value,app.activeDocument.resolution];

var patternDoc = app.documents.add(infoArray[0]*widthMult, infoArray[1]*heightMult, infoArray[2], “Tiled Doc (mult - “+widthMult+”)”,NewDocumentMode.RGB,DocumentFill.TRANSPARENT);

patternDoc.layers[0].translate(-infoArray[0]*widthMult/2+infoArray[0]/2, - infoArray[1]*heightMult/2+ infoArray[1]/2);


var newLayer = patternDoc.layers[0].duplicate();


var newLayer = patternDoc.layers[0].duplicate();


alert(“You must have your original pattern document opened!”);

app.preferences.rulerUnits = startRulerUnits;

05 May 2005, 10:18 AM

I'm just curious to know if it worked, I'm in the process of re-writing a tut for CS and CS2 scripting and it would be nice to know if it worked on different configs.

Sorry about the bump


05 May 2005, 02:39 AM
sorry mate, didn't even know i had a reply, in my userCP, nothing showed up.

i tried the script, not sure if it my photoshop version...CS...but it says the following:

Error 8: syntax error.
Line: 15
-> var WidthMult = prompt("Width multiplier",4);

do you know what would be going wrong?

05 May 2005, 04:40 AM
i just tried CS2 tryout, and it comes with a plugin under goodies, called TextureFill....which is a good attempt by adobe to do this. but the stupid thing is you have to save your psd as a grayscale....WTF why?

i don't mind the saving bit, which is fine, even though i don't wont to but the grayscale is odd.

05 May 2005, 05:55 AM
have you tried this

05 May 2005, 02:54 PM
It worked fine on a mac (well although I spelt 'TRANSPARENT' 'T RANSPARENT' and it wouldn't work) it's not the same bug...

I did little variable name changes and stuff and I don't see why it won't work on CS windows...
If a doesn't work try b...

05 May 2005, 12:29 AM
thanks so much!!! man i love you.

this script will make me faster in CS by at least 5/8ths. be waiting so long for it too.

only found a weird problem with the script, it only works with image of exactly 72 DPi any less or any more and it overlaps or gaps remain. i'm not worried cause all my textures are 72 dpi, just a heads up.


thanks again

05 May 2005, 01:22 AM
and one more.

if you have rulers on and run the script you'll get a gap on either side of the image....


05 May 2005, 01:04 PM
the 72 dpi issue will easily be fixed, it's just a matter of declaring the DPI of the new document (but I couldn't be bothered to script it, I will as soon as I have time)

The ruler issue is extremely weird though, it shouldn't affect you image as it's got nothing to do with it...

05 May 2005, 11:00 PM
yeh its very weird, i just created a new document with a few black boxes on a white background and ran the script adn then tried it with rulers and the gap appeared...

weird indeed, good news with DPi though.

thanks again for the script, this is all that i felt was missing from photoshop....that an equivalent of zbrush tileable canvas feature, where you can drag the image and it automatically tiles..... ;)

thanks mate.

05 May 2005, 04:07 PM
I resolved the DPI issue but after 10 or so experiments with rulers I couldn't find the glitch... Guess they need to be turned off...

Oh and btw, if you plan to do this for let's say 10x10 tiles or something just create a pattern using your initial texture, run the script but erase everything under 'var patternDoc = app.documents.add(infoArray[0]*widthMult, infoArray[1]*heightMult, infoArray[2], “Tiled Doc (mult - “+widthMult+”)”,NewDocumentMode.RGB,DocumentFill.TRANSPARENT);'.

This will create a doc which will be exactly 10x10 tiles in size, and then you can fill it using a pattern fill tool. The script is ridiculously slow for that many tiles...

glad it helped


CGTalk Moderation
05 May 2005, 04:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.