<commit_before>﻿#target photoshop
app.bringToFront();
main();

//-- main function --
function main()
{
    // -- data -- (should this be outside of this function?)
    
    //general prefix
    var prefix = "tex_";
    
    //outputs & data
    var Outputs = [
    {name:"QFHD", suffix:"@4x", scalefactor:1, active:false}, //this is not real @4x
    {name:"Retina", suffix:"@2x", scalefactor:0.711, active:true},
    {name:"SD", suffix:"", scalefactor:0.355, active:true},]
        
    // -- code starts here --
    
    //get filename. If canceled -> abort
    var saveFile = File.openDialog("Y U NO type name? ლ(ಠ益ಠლ)");        
    if(saveFile == null)   
        return;
        
    var fileName = saveFile.name;
    
    //get original document and create the flattened image
    var originalDocument = app.activeDocument;
    var workingLayer = getWorkingLayer(originalDocument);
    workingLayer.name = "temporary Layer";
    originalDocument.activeLayer = workingLayer;
    
    //set save options
    var saveOptions = new ExportOptionsSaveForWeb();
    saveOptions.format = SaveDocumentType.PNG;
    saveOptions.PNG8 = false; 

    //generate each output
    for(var i = 0; i < Outputs.length; ++i)
    {
        if(Outputs[i].active)
        {
            //create new document
            Outputs[i].doc = createDocumentForLayer (workingLayer, prefix+fileName+Outputs[i].suffix);
            //copy layer to document
            addLayerToDocument(workingLayer, Outputs[i].doc);
            //resize 
            resizeDocument(Outputs[i].doc, Outputs[i].scalefactor);
            //set current document as active to save and close
            app.activeDocument = Outputs[i].doc;
            
            //set save path
            var savePath =  File(saveFile.path + "\\");
            
            Outputs[i].doc.exportDocument(savePath,ExportType.SAVEFORWEB, saveOptions);<commit_msg>Fixed exporting not working on mac added file extension check (basic)<commit_after>﻿#target photoshop
app.bringToFront();
main();

//-- main function --
function main()
{
    // -- data -- (should this be outside of this function?)
    
    //general prefix
    var prefix = "tex_";
    
    //outputs & data
    var Outputs = [
    {name:"QFHD", suffix:"@4x", scalefactor:1, active:false}, //this is not real @4x
    {name:"Retina", suffix:"@2x", scalefactor:0.711, active:true},
    {name:"SD", suffix:"", scalefactor:0.355, active:true},]
        
    // -- code starts here --
    
    //get filename. If canceled -> abort    
    var saveFile = File.saveDialog ("Y U NO type name? ლ(ಠ益ಠლ)", ".png")

    if(saveFile == null)   
        return;
        
    var fileName = saveFile.name;

    if(!fileName.match(".png$"))
    {
        fileName += ".png";
    }
    
    //get original document and create the flattened image
    var originalDocument = app.activeDocument;
    var workingLayer = getWorkingLayer(originalDocument);
    workingLayer.name = "temporary Layer";
    originalDocument.activeLayer = workingLayer;
    
    //set save options
    var saveOptions = new ExportOptionsSaveForWeb();
    saveOptions.format = SaveDocumentType.PNG;
    saveOptions.PNG8 = false;

    // TODO: options for optimisation

    //generate each output
    for(var i = 0; i < Outputs.length; ++i)
    {
        if(Outputs[i].active)
        {
            //create new document
            Outputs[i].doc = createDocumentForLayer (workingLayer, prefix+fileName+Outputs[i].suffix);
            //copy layer to document
            addLayerToDocument(workingLayer, Outputs[i].doc);
            //resize 
            resizeDocument(Outputs[i].doc, Outputs[i].scalefactor);
            //set current document as active to save and close
            app.activeDocument = Outputs[i].doc;
            
            //set save path
            var savePath =  File(saveFile.path + "\\");
            
            Outputs[i].doc.exportDocument(savePath,ExportType.SAVEFORWEB, saveOptions);
{'fraction_non_alphanumeric': 0.12408942476764633, 'fraction_numerical': 0.007033408691283597, 'mean_word_length': 2.2746710526315788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3467671', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1159, 'n_words': 296}