• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
6

Automatic saving of images in Photoshop using the Photoshop scripting language

New Here ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

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?

TOPICS
Actions and scripting , Windows

Views

391

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
community guidelines
Adobe
Community Expert ,
Jun 16, 2023 Jun 16, 2023

Copy link to clipboard

Copied

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

 

avif.png

 

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 );

 

 

Votes

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
community guidelines
New Here ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

Excellent. Thank you for your help

Votes

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
community guidelines
Community Expert ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

Please remember to mark a correct answer accordingly. 

Votes

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
community guidelines
Community Expert ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

LATEST

You're welcome, do you know about the ScriptListener plugin?

 

https://helpx.adobe.com/au/photoshop/kb/downloadable-plugins-and-content.html

Votes

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
community guidelines