Skip to main content
Participant
June 16, 2023
Question

Automatic saving of images in Photoshop using the Photoshop scripting language

  • June 16, 2023
  • 1 reply
  • 753 views

I am trying to save images in the AV1 Image (.AVIF) format using a script. My version of Photoshop (20.0.5) does not support this file format, but I added this feature to the version via a plugin located at https://github.com/0xC0000054/avif-format/releases

AvifFormat_x64.zip

I am able to access the feature by navigating to File>Save As>Save as type:> AV1 Image (.AVIF). However, when I attempt to save using the following code, I receive the error message: "Error 8800: General photoshop error occurred. This functionality may not be available in this version of Photoshop."
This is while I can manually save images in that format from the same path without any problem. But it is not possible by script.

 

// Save the image as an AVIF file
    var saveFile = new File(saveFolder + '/Image' + i + '.avif');
    var avifOptions = new ActionDescriptor();
    avifOptions.putPath(charIDToTypeID('In  '), saveFile);
    avifOptions.putEnumerated(charIDToTypeID('As  '), charIDToTypeID('FTcs'), charIDToTypeID('AVIF'));
    executeAction(charIDToTypeID('save'), avifOptions, DialogModes.NO);

 


Does anyone know how to resolve this error and successfully save images in the AV1 Image (.*AVIF) format using this script?

This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
June 17, 2023

It obviously depends on the settings, with the following defaults, this code works:

 

 

var idsave = charIDToTypeID( "save" );
    var desc16 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc17 = new ActionDescriptor();
        var idQlty = charIDToTypeID( "Qlty" );
        desc17.putInteger( idQlty, 85 );
        var idavoneC = charIDToTypeID( "av1C" );
        var idchSu = charIDToTypeID( "chSu" );
        var idchSone = charIDToTypeID( "chS1" );
        desc17.putEnumerated( idavoneC, idchSu, idchSone );
        var idavoneS = charIDToTypeID( "av1S" );
        var idcoSp = charIDToTypeID( "coSp" );
        var idcsPone = charIDToTypeID( "csP1" );
        desc17.putEnumerated( idavoneS, idcoSp, idcsPone );
        var idhTrf = charIDToTypeID( "hTrf" );
        var idhdRt = charIDToTypeID( "hdRt" );
        var idtrFzero = charIDToTypeID( "trF0" );
        desc17.putEnumerated( idhTrf, idhdRt, idtrFzero );
        var idavoneB = charIDToTypeID( "av1B" );
        var idimBd = charIDToTypeID( "imBd" );
        var idiBdtwo = charIDToTypeID( "iBd2" );
        desc17.putEnumerated( idavoneB, idimBd, idiBdtwo );
    var idzeroxCzerozerozerozerozerofivefourAVoneImage = stringIDToTypeID( "0xC0000054 AV1 Image" );
    desc16.putObject( idAs, idzeroxCzerozerozerozerozerofivefourAVoneImage, desc17 );
    var idIn = charIDToTypeID( "In  " );
    desc16.putPath( idIn, new File( "~/Desktop/test.avif" ) );
    var idDocI = charIDToTypeID( "DocI" );
executeAction( idsave, desc16, DialogModes.NO );

 

 

Participant
June 17, 2023

Excellent. Thank you for your help

c.pfaffenbichler
Community Expert
Community Expert
June 17, 2023

Please remember to mark a correct answer accordingly.