Giter Club home page Giter Club logo

Comments (6)

jardicc avatar jardicc commented on June 2, 2024

Maybe we could optionaly save very big strings (XMP, RAW) as a file to file system and make path reference instead value itself? What about temp folder used by Photoshop.

from descriptor-info.

JavierAroche avatar JavierAroche commented on June 2, 2024

If we're going to save to the user's file system, we should save the entire descriptor output to an external file. Maybe we have a flag like this?

var descFlags = {
    reference : false,
    extended : false,
    maxStringLimit : 5000,
    saveToFile : '~/Desktop/output.json'
};

If the user sets a maxStringLimit, then it'll use that for any string (RAW, XMP, etc), otherwise it defaults to 10,000 max.

If the user sets the saveToFile flag, then it will only save to file, without a max string limit. The only downside is that this method will not return anything in JSX, since it could crash. Thoughts?

from descriptor-info.

jardicc avatar jardicc commented on June 2, 2024

I think there should be some faster way how to save data to file. I will try to do some measurements what is fastest way for saving data. Maybe is problem stroting long text in variable? Maybe variable should have always only part of string? Like a buffer?

Is there any chance run saving in separated thread? Can we use setTimeout?

I am also not sure if all raw data should be in one file. Maybe we could save it into separated files in one folder?

from descriptor-info.

jardicc avatar jardicc commented on June 2, 2024

I can confirm that. If you save Raw data into file without writing it in variable then it's pretty fast.

var count = 0;
function saveTxt(txt)
{
    var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
    if (Ext.toLowerCase() != 'psd')
        return;

    var Path = app.activeDocument.path;
    var saveFile = File(Path + "/" + "descriptor-data" + count+".bin");
    count++;

    if(saveFile.exists)
        saveFile.remove();

    saveFile.encoding = "UTF8";
    saveFile.open("e", "TEXT", "????");
    saveFile.writeln(txt);
    saveFile.close();
}
case 'DescValueType.RAWTYPE':  
        if(theDesc.getData( position ).length > this.descParams.maxRawLimit){
                saveTxt(theDesc.getData( position ));
        }
	return theDesc.getData( position ).substring( 0, this.descParams.maxRawLimit );
	break;

from descriptor-info.

jardicc avatar jardicc commented on June 2, 2024

It seems that script doesn't has problem store 1,5MB text in variable. The problem is if you want save it as JSON file. Probably JSON processing takes most time. So if JSON has to process a few milion character less then it runs faster :-)

Saving files itself is not problem.

from descriptor-info.

JavierAroche avatar JavierAroche commented on June 2, 2024

This was implemented in #12

from descriptor-info.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.