Highlighted

Translating in Photoshop Script creates strange blur

New Here ,
Aug 12, 2020

Copy link to clipboard

Copied

Hi guys (and girls)!

I created a script which saves my icons in several formats. This is part of my code:

 

    // Makes list of all files located in that folder  
    var IcoonFile = EPSfile_icoon;

    // Create a EPS option object   
    var eps_oo = new EPSOpenOptions();  
    eps_oo.antiAlias = true;  
    eps_oo.mode = OpenDocumentMode.RGB;
    eps_oo.constrainProportions = true;  
    eps_oo.resolution = 72;
    eps_oo.width = 512;
      
     // open the file 
	 var faviconDoc = app.documents.add(512,512,72,'Favicon', NewDocumentMode.RGB,DocumentFill.TRANSPARENT);
     var icoonDoc = app.open( IcoonFile, eps_oo);      

     // put your code to 'save as' the file here          
     var saveFileJPG = new File ( exportFolder3 + "/icoon-512px.jpg" );  
     var saveFilePNG = new File ( exportFolder4 + "/icoon-512px.png" );  
     var quality = 100;       
     SaveForWebJPG(saveFileJPG,quality); // set quality to suit  
     SaveForWebPNG(saveFilePNG,quality); // set quality to suit  	 
     
     if(icoonDoc.height > icoonDoc.width) {
   
    // Create a EPS option object   
    var eps_oo = new EPSOpenOptions();  
    eps_oo.antiAlias = true;  
    eps_oo.mode = OpenDocumentMode.RGB;
    eps_oo.constrainProportions = true;  
    eps_oo.resolution = 72;
    eps_oo.height = 512;  // Deze keer op basis van de hoogte!!
    
    var icoonDoc = app.open( IcoonFile, eps_oo);      
    
    }
     
     var duplicated = icoonDoc.artLayers[0].duplicate(faviconDoc, ElementPlacement.INSIDE)     
	 var Hoffset = (faviconDoc.width - icoonDoc.width) / 2;
	 var Voffset = (faviconDoc.height - icoonDoc.height) / 2;
	 
	 app.activeDocument = faviconDoc;
	 duplicated.translate(Hoffset, Voffset);
	 
	var saveFaviconFilePNG = new File ( exportFolder4 + "/favicon-512x512px.png" );  
     var quality = 100;  
	SaveForWebPNG(saveFaviconFilePNG,quality); // set quality to suit  	           
     activeDocument.close( SaveOptions.DONOTSAVECHANGES );  
	activeDocument.close( SaveOptions.DONOTSAVECHANGES ); 
    activeDocument.close( SaveOptions.DONOTSAVECHANGES );  

 

 

Everything works just fine, except one part. On the line that says :

 

duplicated.translate(Hoffset, Voffset);

 

I move the pasted image to the center of the document. By going through my script line-by-line I find out that with that action, it creates a strange little blur to the right of my icon and cuts it off a little on the left. This is what I mean (you have to look closely 🙂  )

 

favicon-512x512px.png


Is there any way to prevent this or to center my image in a square document without using 'translate'? The other PNG files that are created are clean. This is is too, right up untill the point where I translate it.

Thank you! 

TOPICS
Actions and scripting, Problem or error, Windows

Views

15

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Translating in Photoshop Script creates strange blur

New Here ,
Aug 12, 2020

Copy link to clipboard

Copied

Hi guys (and girls)!

I created a script which saves my icons in several formats. This is part of my code:

 

    // Makes list of all files located in that folder  
    var IcoonFile = EPSfile_icoon;

    // Create a EPS option object   
    var eps_oo = new EPSOpenOptions();  
    eps_oo.antiAlias = true;  
    eps_oo.mode = OpenDocumentMode.RGB;
    eps_oo.constrainProportions = true;  
    eps_oo.resolution = 72;
    eps_oo.width = 512;
      
     // open the file 
	 var faviconDoc = app.documents.add(512,512,72,'Favicon', NewDocumentMode.RGB,DocumentFill.TRANSPARENT);
     var icoonDoc = app.open( IcoonFile, eps_oo);      

     // put your code to 'save as' the file here          
     var saveFileJPG = new File ( exportFolder3 + "/icoon-512px.jpg" );  
     var saveFilePNG = new File ( exportFolder4 + "/icoon-512px.png" );  
     var quality = 100;       
     SaveForWebJPG(saveFileJPG,quality); // set quality to suit  
     SaveForWebPNG(saveFilePNG,quality); // set quality to suit  	 
     
     if(icoonDoc.height > icoonDoc.width) {
   
    // Create a EPS option object   
    var eps_oo = new EPSOpenOptions();  
    eps_oo.antiAlias = true;  
    eps_oo.mode = OpenDocumentMode.RGB;
    eps_oo.constrainProportions = true;  
    eps_oo.resolution = 72;
    eps_oo.height = 512;  // Deze keer op basis van de hoogte!!
    
    var icoonDoc = app.open( IcoonFile, eps_oo);      
    
    }
     
     var duplicated = icoonDoc.artLayers[0].duplicate(faviconDoc, ElementPlacement.INSIDE)     
	 var Hoffset = (faviconDoc.width - icoonDoc.width) / 2;
	 var Voffset = (faviconDoc.height - icoonDoc.height) / 2;
	 
	 app.activeDocument = faviconDoc;
	 duplicated.translate(Hoffset, Voffset);
	 
	var saveFaviconFilePNG = new File ( exportFolder4 + "/favicon-512x512px.png" );  
     var quality = 100;  
	SaveForWebPNG(saveFaviconFilePNG,quality); // set quality to suit  	           
     activeDocument.close( SaveOptions.DONOTSAVECHANGES );  
	activeDocument.close( SaveOptions.DONOTSAVECHANGES ); 
    activeDocument.close( SaveOptions.DONOTSAVECHANGES );  

 

 

Everything works just fine, except one part. On the line that says :

 

duplicated.translate(Hoffset, Voffset);

 

I move the pasted image to the center of the document. By going through my script line-by-line I find out that with that action, it creates a strange little blur to the right of my icon and cuts it off a little on the left. This is what I mean (you have to look closely 🙂  )

 

favicon-512x512px.png


Is there any way to prevent this or to center my image in a square document without using 'translate'? The other PNG files that are created are clean. This is is too, right up untill the point where I translate it.

Thank you! 

TOPICS
Actions and scripting, Problem or error, Windows

Views

16

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0

Have something to add?

Join the conversation