# Save in TIFF format

**URL:** <https://forums.creativeclouddeveloper.com/t/save-in-tiff-format/6692>\
**Category:** UXP Plugin API\
**Tags:** uxp, javascript\
**Created:** [August 17, 2023, 2:25am UTC](https://forums.creativeclouddeveloper.com/t/save-in-tiff-format/6692 "2023-08-17T02:25:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsehtak](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hsehtak](https://forums.creativeclouddeveloper.com/u/hsehtak)\
**Post date:** [August 17, 2023, 2:25am UTC](https://forums.creativeclouddeveloper.com/t/save-in-tiff-format/6692/1 "2023-08-17T02:25:54Z")

</div>

HI  
can some one please guide me , i want to save my file in TIFF format using UXP plugin.

async function saveTif(FileFullPath) {  
await core.executeAsModal(  
async () =\> {  
return await psAction.batchPlay(  
[  
{  
\_obj: “save”,  
as: {  
\_obj: “TIFF”,  
byteOrder: {  
\_enum: “platform”,  
\_value: “IBMPC”,  
},  
LZWCompression: true,  
layerCompression: {  
\_enum: “encoding”,  
\_value: “zip”,  
},  
},  
in: {  
\_path: FileFullPath,  
\_kind: “local”,  
},  
lowerCase: true,  
\_options: {  
dialogOptions: “dontDisplay”,  
},  
},  
],  
{  
“synchronousExecution”: false,  
“modalBehavior”: “fail”  
});  
},  
{ commandName: “Saving TIFF” }  
);  
}

this above is my save function , and below is my method to call this function

```
  let consolidatedFileName = `Consolidated-file-${consolidatedCounter}.tif`;
    consolidatedCounter++;
    consoldatedImgs.textContent = `Saving Consolidated Image...`;

    var conFile = await outPathToken.createFile(consolidatedFileName, {
      overwrite: true,
    });
    const saveTIFF_File = await fs.createSessionToken(conFile);

    await core.executeAsModal(async () => {
      await saveTif(saveTIFF_File);
      consoldatedImgs.textContent = `File Saved : ${consolidatedFileName}`;
      return;
    }, {});

```

---

<div class="post-metadata">

**Author:** ![sttk3](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sttk3](https://forums.creativeclouddeveloper.com/u/sttk3)\
**Post date:** [August 17, 2023, 12:59pm UTC](https://forums.creativeclouddeveloper.com/t/save-in-tiff-format/6692/2 "2023-08-17T12:59:37Z")

</div>

I wrote it while filling in the unknown parts and it worked.

For me, the key points were to specify `interactive: true` and to add await when specifying the destination folder.

What is the error in your case? It seems to me that there is a data type discrepancy around `outPathToken.createFile`.

```auto
const { localFileSystem } = require('uxp').storage ;
const photoshop = require('photoshop') ;
const { app, core, action } = photoshop ;

async function saveTif(FileFullPath) {
  return await action.batchPlay(
    [
      {
        _obj: "save",
        as: {
          _obj: "TIFF",
          byteOrder: {
            _enum: "platform",
            _value: "IBMPC",
          },
          LZWCompression: true,
          layerCompression: {
            _enum: "encoding",
            _value: "zip",
          },
        },
        in: {
          _path: FileFullPath,
          _kind: "local",
        },
        lowerCase: true,
        _options: {
          dialogOptions: "dontDisplay",
        },
      },
    ],

    {
      "synchronousExecution": false,
      "modalBehavior": "fail"
    }
  ) ;
}

const main = async () => {
  try {
    await core.executeAsModal(
      async (control) => {
        let consolidatedCounter = 0 ;
        let consolidatedFileName = `Consolidated-file-${consolidatedCounter}.tif` ;
        consolidatedCounter++ ;
        console.log(`Saving Consolidated Image...`) ;

        const outPathToken = await localFileSystem.getPluginFolder() ;
        const conFile = await outPathToken.createFile(consolidatedFileName, {
          overwrite: true,
        }) ;
        const saveTIFF_File = await localFileSystem.createSessionToken(conFile) ;

        const result = await saveTif(saveTIFF_File) ;
        console.log(`File Saved : ${consolidatedFileName}`) ;
        console.log(result) ;
      },

      {
        'commandName': 'Saving TIFF', 
        'interactive': true
      }
    );
  } catch (e) {
    await app.showAlert(e);
  }
} ;

```
