User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 361,914 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,586 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 5393 | Replies: 4 | Solved
Reply
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Photoshop - javascript slice : error : copy command not available??

  #1  
Jul 29th, 2006
Hi,

Good Morning.

I wanted to slice one image to tiles and i got a script for it. I did not had a photoshop so I got Photoshop CS2 Version 9.0. This script was working fine but it says error over a copy command.

    // We make sure our source image is the active document
    var srcDoc = activeDocument;
              
    //Select Area and Copy
    srcDoc.selection.select(Array (Array(MyXO, MyYO), Array(MyXL, MyYO), Array(MyXL, MyYL), Array(MyXO, MyYL)), SelectionType.REPLACE, 0, false);    
     srcDoc.selection.copy();
            
     //Paste to new Doc
     var pasteDoc = documents.add(PixelWidth, PixelHeight, srcDoc.resolution, "Paste Target");
     pasteDoc.paste();
     pasteDoc = null;

    //Save New Doc
    var saveMe = activeDocument;
        

The error shown is

Error 8800: General Photoshop error occurred.The command copy is not currently available.LIne 69 -> srcDoc.Selection.Copy();

What is the replacment command that i could use for it or what is the command that i could use over any versions....

I could not find the Scripts menu option below automate where i could browse to this script and get the slicing in version 7. I could gind the scripts option ibelow Automate in files menu in Version 9 though but this says this error.

I hope here to have photoshop experts who could help me out.

regards

Harish

Observation: before showing the above pop-up error -> it makes the first 7 slice as set in the variables.

/*********
//**** YOU SHOULD CUSTOMIZE THE FOLLOWING VARIABLE DEPENDING ON YOUR NEED ****
var ZoomLevel = 2;  

var FolderPath = "/Documents and Settings/harish/Desktop/images/Zoom"+ZoomLevel+"slices/"; 

// We start with the coordinates, zoom, and width of an upper left corner tile and generate everything from there
// We can calculate new tile values from these values for any zoom level without having to look up these details for each.
var OrgX = 1204;   //<-- the X value
var OrgY = 1536;   //<-- the Y value
var OrgZoomLevel = 5;   //<-- the zoom level
var OrgTileWidth = 7;    //<-- the number of tiles wide your full map area is
var OrgTileHeight = 7;    //<-- the number of tiles high your full map area is


//**** EVERYTHING BEYOND HERE SHOULD NOT BE TOUCHED UNLESS YOU KNOW WHAT YOU ARE DOING!!!

// Exponent Function 
// we will need this later
function PowMe(a, b){
   var o = a;
   for (n=1; n<b; n++){ o *= a; }
   if (b==0){ o = 1;    }
   return o;
};

var StartX = OrgX*PowMe(2,(OrgZoomLevel - ZoomLevel)); 
var StartY = OrgY*PowMe(2,(OrgZoomLevel - ZoomLevel));  
var xTiles = OrgTileWidth*PowMe(2,(OrgZoomLevel - ZoomLevel)); 
var yTiles = OrgTileHeight*PowMe(2,(OrgZoomLevel - ZoomLevel)); 

var PixelWidth = 256; 
var PixelHeight = 256;

var TotalTiles = xTiles * yTiles;  


preferences.rulerUnits = Units.PIXELS;


var xm = 0;
var ym = 0;

var TileX = StartX; 
var TileY = StartY; 



for (n=1; n<TotalTiles+1; n++) {            
            
    if (ym == yTiles){   
         xm += 1; //<-- Up the x value by 1, i.e. we move over to the next column   
         ym = 0;  //<-- Reset the y value to 0 so we start back at the top of our new column
         TileX += 1; //<-- Increase our Google X value for our file name 
         TileY = StartY;  //We reset out Google Y value for out file name everytime we change columns
    };
                    
    
    MyXO = xm*(PixelWidth);
    MyXL = xm*(PixelWidth)+(PixelWidth);
    MyYO = ym*(PixelHeight);
    MyYL = ym*(PixelHeight)+(PixelHeight);                

    // We make sure our source image is the active document
    var srcDoc = activeDocument;
              
    //Select Area and Copy
    srcDoc.selection.select(Array (Array(MyXO, MyYO), Array(MyXL, MyYO), Array(MyXL, MyYL), Array(MyXO, MyYL)), SelectionType.REPLACE, 0, false);    
     srcDoc.selection.copy();
            
     //Paste to new Doc
     var pasteDoc = documents.add(PixelWidth, PixelHeight, srcDoc.resolution, "Paste Target");
     pasteDoc.paste();
     pasteDoc = null;

    //Save New Doc
    var saveMe = activeDocument;
            
    //Flatten
    saveMe.flatten();

    //Set path to file and file name
    saveFile = new File(FolderPath + TileX+ "_" + TileY+ "_" + ZoomLevel + ".gif");    
    //Set save options
    gifSaveOptions = new GIFSaveOptions();
         gifSaveOptions.colors = 64;
         gifSaveOptions.dither = Dither.NONE;
         gifSaveOptions.matte = MatteType.NONE;
         gifSaveOptions.preserveExactColors = 0;
         gifSaveOptions.transparency = 0;
         gifSaveOptions.interlaced = 0;
            
    //Save the file and close it
    saveMe.saveAs(saveFile, gifSaveOptions, true,Extension.LOWERCASE);
    saveMe.close(SaveOptions.DONOTSAVECHANGES);                                           
            
    //Advance Y counter for next image
    ym += 1;
            
    //Advance Google Y value for next image name
    TileY += 1;
                        
}
/*****************
Last edited by tgreer : Aug 20th, 2006 at 10:37 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,774
Reputation: peter_budo has a spectacular aura about peter_budo has a spectacular aura about 
Rep Power: 8
Solved Threads: 184
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Monster is back

Re: Photoshop - javascript slice : error : copy command not available??

  #2  
Jul 29th, 2006
wouldn't be easier to use ImageReady which you have with your copy of Photoshop and manually slice image then use dodgy script?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: Photoshop - javascript slice : error : copy command not available??

  #3  
Jul 29th, 2006
Originally Posted by peter_budo
wouldn't be easier to use ImageReady which you have with your copy of Photoshop and manually slice image then use dodgy script?


Thanks for reply. but i can't do so for the slice would be some 840 of an image and likewise i have some 28 images to do. Another concern is that the slices are called by a functional calcualtion by application and each sliced needs to be saved with x_y_value.gif... Here a layer would be having x changing values incrementally by one and each vertical layer changing y value incremented by 1.

I dont believe anyone would still approve that this could be manuaaly done for nearly 840*28 slices. Nearly impossible and this script slices and saves it in the name format also.

I would like to know would the trial versions have restriction of some commands for JSX or JS scripts. I am using the trial version and it says that copy() command is not available.

Observation : My client was able to do it using his photoshop with the same script and he before moving for vacation did one image slice for me.

Scripts works fine if i comment the line srcDoc.selection.copy(); with one image slice getting saved and goes on saving the same image.

Hope somebody would let me know what is wrong with PS CS2 version trial with copy() command or alternate command that i could use.

With regards

Harish

.
Last edited by tgreer : Aug 20th, 2006 at 10:38 am.
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 1,774
Reputation: peter_budo has a spectacular aura about peter_budo has a spectacular aura about 
Rep Power: 8
Solved Threads: 184
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Monster is back

Re: Photoshop - javascript slice : error : copy command not available??

  #4  
Jul 30th, 2006
didn't know that you want to slice so many images. I see only two options then, 1st to try get in touch with person who came up with this script and ask him directly or 2nd try to find forum which is more related to photoshop. I'm not saying that daniweb hasn't got one but it is rarely used and often i'm answering questions over there
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: Photoshop - javascript slice : error : copy command not available??

  #5  
Aug 19th, 2006
Hi,

the reason was the i have to make the multiples of the slices width as total width and height. Script worked fine and sorry in replying late here.

If anyone wants any help on this or clarification just send me a email to marar.harish@gmail.com

With regards

Harish
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC