app.preferences.rulerUnits = Units.PIXELS
app.displayDialogs = DialogModes.NO
var documentWidthAsInteger = app.activeDocument.width.value ;
var documentHeightAsInteger = app.activeDocument.height.value ;
layerRef = app.activeDocument.artLayers.getByName("Layer 1");
layerRef.applyAddTexture(2.0,texturizer.puzzle,true);
My goal is to make a javascript code for photoshop that will not only make any picture a puzzle, but I also want to randomize pictures/puzzle generator or a jigsaw puzzle game.
edit 1
var myDoc = app.activeDocument;
var myLayer = myDoc.layers[0];
myLayer.name = "myLayer";
var myGroup = myDoc.groupItems[0];
myGroup.name = "myGroup";
myDoc.graphicStyles.getByName("PathFinder / Add").applyTo(myGroup);
var rasterizeOptions = new RasterizeOptions;
rasterizeOptions.antiAliasingMethod = AntiAliasingMethod.ARTOPTIMIZED;
rasterizeOptions.backgroundBlack = false;
rasterizeOptions.clippingMask = true;
rasterizeOptions.colorModel = RasterizationColorModel.GRAYSCALE;
rasterizeOptions.convertSpotColors = false;
rasterizeOptions.convertTextToOutlines = false;
rasterizeOptions.includeLayers = false;
rasterizeOptions.padding = 0;
rasterizeOptions.resolution = 300;
rasterizeOptions.transparency = false;
var rasterItem = myDoc.rasterize(myGroup, myGroup.controlBounds, rasterizeOptions);
var myPath = rasterItem.groupItems[0].pathItems[0].duplicate(myLayer, ElementPlacement.PLACEATBEGINNING);
myPath.name = "myPath";
rasterItem.remove();