Yeah.
I've been wanting to make a filter joke about these pictures, but it just doesn't seem funny.
It's a neat effect, though.
( ,
Mon 5 Feb 2007, 5:43,
archived)
I've been wanting to make a filter joke about these pictures, but it just doesn't seem funny.
It's a neat effect, though.
Well here's a formula you can start out with :)
// ------------------------------------------------------------------------------------------------
// FUNCTIONS
// ------------------------------------------------------------------------------------------------
// FUNCTION to create a selection
function makeSelection (top_s, left_s, bottom_s, right_s, isElipse) {
var setd = charIDToTypeID( "setd" );
var actDesc_1 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_1 = new ActionReference();
var charID_chnl = charIDToTypeID( "Chnl" );
var charID_fsel = charIDToTypeID( "fsel" );
actRef_1.putProperty( charID_chnl, charID_fsel );
actDesc_1.putReference( charID_null, actRef_1 );
var charID_T = charIDToTypeID( "T " );
var actDesc_2 = new ActionDescriptor();
var charID_pxl = charIDToTypeID( "#Pxl" );
var charID_top = charIDToTypeID( "Top " );
actDesc_2.putUnitDouble( charID_top, charID_pxl, top_s );
var charID_left = charIDToTypeID( "Left" );
actDesc_2.putUnitDouble( charID_left, charID_pxl, left_s );
var charID_btom = charIDToTypeID( "Btom" );
actDesc_2.putUnitDouble( charID_btom, charID_pxl, bottom_s );
var charID_rght = charIDToTypeID( "Rght" );
actDesc_2.putUnitDouble( charID_rght, charID_pxl, right_s );
if (isElipse == true) {
var charID_elps = charIDToTypeID( "Elps" );
actDesc_1.putObject( charID_T, charID_elps, actDesc_2 );
var charID_anta = charIDToTypeID( "AntA" );
actDesc_1.putBoolean( charID_anta, true );
} else {
var charID_rect = charIDToTypeID( "Rctn" );
actDesc_1.putObject( charID_T, charID_rect, actDesc_2 );
}
executeAction( setd, actDesc_1, DialogModes.NO );
}
// FUNCTION to merge all layers to a single layer
// NOTE : OTHER LAYERS ARE USUALLY DISCARDED BY THIS FUNCTION
function mergeAll () {
while (doc.artLayers.length > 1) {
doc.activeLayer = doc.artLayers[0];
doc.activeLayer.merge();
}
}
// FUNCTION to discard and apply a layer mask to the active layer
function applyLayerMask () {
var charID_dlt = charIDToTypeID( "Dlt " );
var actDesc_3 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_2 = new ActionReference();
var charID_chnl = charIDToTypeID( "Chnl" );
var charID_msk = charIDToTypeID( "Msk " );
actRef_2.putEnumerated( charID_chnl, charID_chnl, charID_msk );
actDesc_3.putReference( charID_null, actRef_2 );
var charID_aply = charIDToTypeID( "Aply" );
actDesc_3.putBoolean( charID_aply, true );
executeAction( charID_dlt, actDesc_3, DialogModes.NO );
}
// FUNCTION to undo changes to the "original image" layer
function undoImageChange () {
var charID_slct = charIDToTypeID( "slct" );
var actDesc_4 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_3 = new ActionReference();
var charID_hsts = charIDToTypeID( "HstS" );
var charID_ordn = charIDToTypeID( "Ordn" );
var charID_prvs = charIDToTypeID( "Prvs" );
actRef_3.putEnumerated( charID_hsts, charID_ordn, charID_prvs );
actDesc_4.putReference( charID_null, actRef_3 );
executeAction( charID_slct, actDesc_4, DialogModes.NO );
}
// FUNCTION to generate a random number within a range
function getRandomNumber (min, max) {
randNum = Math.floor(Math.random() * ((max + 1) - min) + min);
return randNum;
}
// ------------------------------------------------------------------------------------------------
// PREPARE THE DOCUMENT
// ------------------------------------------------------------------------------------------------
// store ruler unit preference
var originalRulerUnit = preferences.rulerUnits;
// set temporary script-specific ruler preference
preferences.rulerUnits = Units.PIXELS;
// get a reference to the active document
var doc = app.activeDocument;
// merge all current layers to produce an "original image" layer
// IDEALLY THIS SHOULD BE DEPENDENT UPON A CONDITIONAL CONFIRMATION DIALOGUE BOX
mergeAll();
// add a new normal art layer
// THIS IS THE 'dot' LAYER THAT THE DOTS WILL BE ADDED TO
var dotLayer = doc.artLayers.add();
dotLayer.kind = LayerKind.NORMAL;
// ------------------------------------------------------------------------------------------------
// CREATE THE DOTS
// ------------------------------------------------------------------------------------------------
// set the elipse top left and bottom right points and the row and column intervals
var elipse_top = 1;
var elipse_left = 1;
var elipse_bottom = 9;
var elipse_right = 9;
var elipse_row_interval = 10;
var elipse_column_interval = 10;
// store total rows and columns required
var total_rows_required = Math.floor(doc.width / elipse_row_interval);
var total_columns_required = Math.floor(doc.height / elipse_column_interval);
// initiate counters for rows and columns
var row_count = 0;
var column_count = 0;
while (column_count < total_columns_required) {
while (row_count < total_rows_required) {
// activate the bottom layer (the "original image" layer)
doc.activeLayer = doc.artLayers[doc.artLayers.length - 1];
// set the selection parameters
top_s = elipse_top + (column_count * elipse_column_interval);
left_s = elipse_left + (row_count * elipse_row_interval);
bottom_s = elipse_bottom + (column_count * elipse_column_interval);
right_s = elipse_right + (row_count * elipse_row_interval);
// make the selection
// ELIPSE
makeSelection (top_s, left_s, bottom_s, right_s, true);
// RECTANGLE
// makeSelection (top_s, left_s, bottom_s, right_s, false);
// average the selection
doc.activeLayer.applyAverage();
// apply gaussian blur to the selection
// THIS IS ONLY NECESSARY IF THERE ARE TRANSPARENT AREAS ON THE ORIGINAL IMAGE
// if this method is used it's necessary to make multiple copies (approx 10)
// of the finished dot layer and merge them down in order to make the dots opaque
// UNCOMMENT THE NEXT LINE TO APPLY GAUSSIAN BLUR
// doc.activeLayer.applyGaussianBlur(1.7);
// copy the averaged selected area of the "original image" layer
doc.selection.copy();
// undo the changes to the "original image" layer
doc.activeLayer = doc.artLayers[1];
undoImageChange();
// paste the copied area INTO THE SELECTION on a new layer
doc.paste(true);
// apply the layer mask
applyLayerMask();
// set the layer's opacity
doc.activeLayer.opacity = 100.0;
// merge the new layer with the "dot" layer
doc.activeLayer = doc.artLayers[0];
doc.activeLayer.merge();
// increment the row counter
row_count += 1;
}
// reset row_count
row_count = 0;
// increment the column_count
column_count += 1;
}
// ------------------------------------------------------------------------------------------------
// CLEAN UP AND RESET THE DOCUMENT
// ------------------------------------------------------------------------------------------------
// release references
doc = null;
dotLayer = null;
pasteToLayer = null;
// restore original ruler unit setting
app.preferences.rulerUnits = originalRulerUnit;
Edit:
Ashally I don't use this very often any more, I found a way around most of it immediately after writing it, duh.
And it's only a starting point to generate the the 'dots'... it's mainly offset layers and blending modes after that.
( ,
Mon 5 Feb 2007, 5:48,
archived)
// ------------------------------------------------------------------------------------------------
// FUNCTIONS
// ------------------------------------------------------------------------------------------------
// FUNCTION to create a selection
function makeSelection (top_s, left_s, bottom_s, right_s, isElipse) {
var setd = charIDToTypeID( "setd" );
var actDesc_1 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_1 = new ActionReference();
var charID_chnl = charIDToTypeID( "Chnl" );
var charID_fsel = charIDToTypeID( "fsel" );
actRef_1.putProperty( charID_chnl, charID_fsel );
actDesc_1.putReference( charID_null, actRef_1 );
var charID_T = charIDToTypeID( "T " );
var actDesc_2 = new ActionDescriptor();
var charID_pxl = charIDToTypeID( "#Pxl" );
var charID_top = charIDToTypeID( "Top " );
actDesc_2.putUnitDouble( charID_top, charID_pxl, top_s );
var charID_left = charIDToTypeID( "Left" );
actDesc_2.putUnitDouble( charID_left, charID_pxl, left_s );
var charID_btom = charIDToTypeID( "Btom" );
actDesc_2.putUnitDouble( charID_btom, charID_pxl, bottom_s );
var charID_rght = charIDToTypeID( "Rght" );
actDesc_2.putUnitDouble( charID_rght, charID_pxl, right_s );
if (isElipse == true) {
var charID_elps = charIDToTypeID( "Elps" );
actDesc_1.putObject( charID_T, charID_elps, actDesc_2 );
var charID_anta = charIDToTypeID( "AntA" );
actDesc_1.putBoolean( charID_anta, true );
} else {
var charID_rect = charIDToTypeID( "Rctn" );
actDesc_1.putObject( charID_T, charID_rect, actDesc_2 );
}
executeAction( setd, actDesc_1, DialogModes.NO );
}
// FUNCTION to merge all layers to a single layer
// NOTE : OTHER LAYERS ARE USUALLY DISCARDED BY THIS FUNCTION
function mergeAll () {
while (doc.artLayers.length > 1) {
doc.activeLayer = doc.artLayers[0];
doc.activeLayer.merge();
}
}
// FUNCTION to discard and apply a layer mask to the active layer
function applyLayerMask () {
var charID_dlt = charIDToTypeID( "Dlt " );
var actDesc_3 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_2 = new ActionReference();
var charID_chnl = charIDToTypeID( "Chnl" );
var charID_msk = charIDToTypeID( "Msk " );
actRef_2.putEnumerated( charID_chnl, charID_chnl, charID_msk );
actDesc_3.putReference( charID_null, actRef_2 );
var charID_aply = charIDToTypeID( "Aply" );
actDesc_3.putBoolean( charID_aply, true );
executeAction( charID_dlt, actDesc_3, DialogModes.NO );
}
// FUNCTION to undo changes to the "original image" layer
function undoImageChange () {
var charID_slct = charIDToTypeID( "slct" );
var actDesc_4 = new ActionDescriptor();
var charID_null = charIDToTypeID( "null" );
var actRef_3 = new ActionReference();
var charID_hsts = charIDToTypeID( "HstS" );
var charID_ordn = charIDToTypeID( "Ordn" );
var charID_prvs = charIDToTypeID( "Prvs" );
actRef_3.putEnumerated( charID_hsts, charID_ordn, charID_prvs );
actDesc_4.putReference( charID_null, actRef_3 );
executeAction( charID_slct, actDesc_4, DialogModes.NO );
}
// FUNCTION to generate a random number within a range
function getRandomNumber (min, max) {
randNum = Math.floor(Math.random() * ((max + 1) - min) + min);
return randNum;
}
// ------------------------------------------------------------------------------------------------
// PREPARE THE DOCUMENT
// ------------------------------------------------------------------------------------------------
// store ruler unit preference
var originalRulerUnit = preferences.rulerUnits;
// set temporary script-specific ruler preference
preferences.rulerUnits = Units.PIXELS;
// get a reference to the active document
var doc = app.activeDocument;
// merge all current layers to produce an "original image" layer
// IDEALLY THIS SHOULD BE DEPENDENT UPON A CONDITIONAL CONFIRMATION DIALOGUE BOX
mergeAll();
// add a new normal art layer
// THIS IS THE 'dot' LAYER THAT THE DOTS WILL BE ADDED TO
var dotLayer = doc.artLayers.add();
dotLayer.kind = LayerKind.NORMAL;
// ------------------------------------------------------------------------------------------------
// CREATE THE DOTS
// ------------------------------------------------------------------------------------------------
// set the elipse top left and bottom right points and the row and column intervals
var elipse_top = 1;
var elipse_left = 1;
var elipse_bottom = 9;
var elipse_right = 9;
var elipse_row_interval = 10;
var elipse_column_interval = 10;
// store total rows and columns required
var total_rows_required = Math.floor(doc.width / elipse_row_interval);
var total_columns_required = Math.floor(doc.height / elipse_column_interval);
// initiate counters for rows and columns
var row_count = 0;
var column_count = 0;
while (column_count < total_columns_required) {
while (row_count < total_rows_required) {
// activate the bottom layer (the "original image" layer)
doc.activeLayer = doc.artLayers[doc.artLayers.length - 1];
// set the selection parameters
top_s = elipse_top + (column_count * elipse_column_interval);
left_s = elipse_left + (row_count * elipse_row_interval);
bottom_s = elipse_bottom + (column_count * elipse_column_interval);
right_s = elipse_right + (row_count * elipse_row_interval);
// make the selection
// ELIPSE
makeSelection (top_s, left_s, bottom_s, right_s, true);
// RECTANGLE
// makeSelection (top_s, left_s, bottom_s, right_s, false);
// average the selection
doc.activeLayer.applyAverage();
// apply gaussian blur to the selection
// THIS IS ONLY NECESSARY IF THERE ARE TRANSPARENT AREAS ON THE ORIGINAL IMAGE
// if this method is used it's necessary to make multiple copies (approx 10)
// of the finished dot layer and merge them down in order to make the dots opaque
// UNCOMMENT THE NEXT LINE TO APPLY GAUSSIAN BLUR
// doc.activeLayer.applyGaussianBlur(1.7);
// copy the averaged selected area of the "original image" layer
doc.selection.copy();
// undo the changes to the "original image" layer
doc.activeLayer = doc.artLayers[1];
undoImageChange();
// paste the copied area INTO THE SELECTION on a new layer
doc.paste(true);
// apply the layer mask
applyLayerMask();
// set the layer's opacity
doc.activeLayer.opacity = 100.0;
// merge the new layer with the "dot" layer
doc.activeLayer = doc.artLayers[0];
doc.activeLayer.merge();
// increment the row counter
row_count += 1;
}
// reset row_count
row_count = 0;
// increment the column_count
column_count += 1;
}
// ------------------------------------------------------------------------------------------------
// CLEAN UP AND RESET THE DOCUMENT
// ------------------------------------------------------------------------------------------------
// release references
doc = null;
dotLayer = null;
pasteToLayer = null;
// restore original ruler unit setting
app.preferences.rulerUnits = originalRulerUnit;
Edit:
Ashally I don't use this very often any more, I found a way around most of it immediately after writing it, duh.
And it's only a starting point to generate the the 'dots'... it's mainly offset layers and blending modes after that.
Ugh.
What syntax is that?
Java? C? PHP?
I should recognise it but I don't.
( ,
Mon 5 Feb 2007, 6:00,
archived)
What syntax is that?
Java? C? PHP?
I should recognise it but I don't.
It's Javascript.
It turns out you can script photoshop.
I was after a particular effect and wrote this, which work pretty well but very slowly.
Then about an hour after finishing it, I found a really quick way to achieve most of what this can do without any code at all.
I still use it sometimes though, there are a couple of things it can do that are difficult to achieve in other ways.
It's only really a starting point, but it was actually kind of fun to write, just as an exercise in scripting something other than a browser or a flash movie.
( ,
Mon 5 Feb 2007, 6:03,
archived)
I was after a particular effect and wrote this, which work pretty well but very slowly.
Then about an hour after finishing it, I found a really quick way to achieve most of what this can do without any code at all.
I still use it sometimes though, there are a couple of things it can do that are difficult to achieve in other ways.
It's only really a starting point, but it was actually kind of fun to write, just as an exercise in scripting something other than a browser or a flash movie.
So, that's a neato?
If I had photoshop, I'd definitely play around with it.
( ,
Mon 5 Feb 2007, 6:18,
archived)
If I had photoshop, I'd definitely play around with it.
Looks like it.
edit: on looking at it some it will
still run correctly, as javascript
will bail early (doc.artLayers.length
at zero) before resolving the "1)".
( ,
Mon 5 Feb 2007, 6:10,
archived)
still run correctly, as javascript
will bail early (doc.artLayers.length
at zero) before resolving the "1)".
Hehe! Filters!
Funny that, in the case picked, it
would have worked with some parsers.
Been meaning to play with scripting PS.
thx for the post/code snippet.
( ,
Mon 5 Feb 2007, 6:24,
archived)
would have worked with some parsers.
Been meaning to play with scripting PS.
thx for the post/code snippet.