Skip to main content
Silly-V
Legend
September 28, 2015
Answered

ExportOptionsTIFF not listening to my instructions!

  • September 28, 2015
  • 3 replies
  • 4193 views

I have discovered yet another inconvenience, and I hope someone may tell me what I am doing wrong.

Using the export TIFF command from an Illustrator document, I am hoping to produce a .tif with 600dpi.

#target illustrator-19

function test(){

    if(app.documents.length == 0){

        return;

    }

    var doc = app.activeDocument;

    var dest = Folder.selectDialog("Choose Folder.");

    if(dest != null){

        var opts = new ExportOptionsTIFF();

        opts.resolution = 600;

        var destFile = File(dest + "/" + "TestFile.tif");

        doc.exportFile(destFile, ExportType.TIFF, opts);

        alert("Successfully exported '" + destFile.displayName + "'.\nNow, check out that resolution...");

    }

}

test();

What I have found is that the script ignores my opts.resolution property and just uses the last resolution that was manually set through the File > Export / TIFF format dialog.
I am expecting new ExportOptionsTIFF(); to set the resolution, but it simply taunts me.
Is there anything wrong with my code?

This topic has been closed for replies.
Correct answer Qwertyfly___

your not the first person to hit this wall.

take a look at this thread...

Problem when passing value to resolution (Export TIFF)

though I don't think using photoshop is ideal as illustrator has(should have) the capabilities...

it actually does work but it uses a value from 2 times ago. Don't ask me to explain!

ie

set dpi          saved dpi

250              250

80                250

100              250

100              80

150              100

200              100

300              150

starting to see the pattern...

Here is my hack work around.

I set the res to 72 for the dead saves so they don't take too long.

#target illustrator-19

function test(){

    if(app.documents.length == 0){

        return;

    }

    var doc = app.activeDocument;

    var dest = Folder.selectDialog("Choose Folder.");

    if(dest != null){

        var opts = new ExportOptionsTIFF();

        var destFile = File(dest + "/" + "TestFile.tif");

        opts.resolution = 300;

        doc.exportFile(destFile, ExportType.TIFF, opts);

        opts.resolution = 72;

        doc.exportFile(destFile, ExportType.TIFF, opts);

        doc.exportFile(destFile, ExportType.TIFF, opts);

        alert("Successfully exported '" + destFile.displayName + "'.\nNow, check out that resolution...");

    }

}

test();

3 replies

Zetta
Known Participant
December 29, 2016

Just an update here, just in case anyone else stumbles on this issue...  I'm excited to report THIS BUG HAS BEEN FIXED in 2017!!

Its been a while since I've seen an scriptability issue get addressed in a new release, but this appears to have been the case!   I had the latest version of AI and was not seeing the issue, but my client was.   He was still on 2015.3.   So I tested the same function in both versions and I see a clear fix!   Yippee!!

A huge thank you to Silly-V, Carlos, and everyone else who helped communicate this issue to the Illustrator team.  And love to the AI team for addressing some scripting issues in this latest release. 

FYI:  If you need a script to work for both older versions and new, Here is a function that will work in both, 

function exportFileToTIF()

{

var inDpi = 199;  // whatever you want here.

app.preferences.setRealPreference("DPI",inDpi);

var dest = Folder.desktop + "/test_" + inDpi + ".tif";

  if ( app.documents.length > 0 )

  {

  var exportOptions = new ExportOptionsTIFF();

  var type = ExportType.TIFF;

  var fileSpec = new File(dest);

  exportOptions.resolution = inDpi;

  exportOptions.artboardRange = 1;

  exportOptions.imageColorSpace = ImageColorSpace.CMYK;

  exportOptions.saveMultipleArtboards = true;

  app.activeDocument.exportFile( fileSpec, type, exportOptions );

  return;

  }

}

CarlosCanto
Community Expert
Community Expert
December 29, 2016

thanks for the update Zetta!!

Silly-V
Silly-VAuthor
Legend
April 7, 2017

I'm not sure now, that I didn't myself stick the DPI preference in the top level while I was messing around.

This appears to be working now: app.preferences.setRealPreference("plugin/TIFFFileFormat/DPI", 350);

Silly-V
Silly-VAuthor
Legend
April 27, 2016

Hmm I was poking around the Preferences, and there's a pref for the TIFF resolution. I wondered if changing the prefs file directly would be any more convenient or reliable.

My Windows prefs file is here:

C:\Users\<you>\AppData\Roaming\Adobe\Adobe Illustrator 19 Settings\en_US\x64\Adobe Illustrator Prefs

This is the section within the prefs file:

/TIFFFileFormat {

  /PreserveSpotColors 0

  /ByteOrder 2

  /LZWCompression 0

  /AntiAlias 2

  /DPI 600.0

  /ColorModel 1

}

I did a preliminary test though, by changing the value there in the file and acting like I was going to export a tiff in the UI, and there was no changes to the UI dialog next time I ran it. I restarted my AI and same thing, no changes - the UI dialog showed the default of 72 dpi, wherease the TIFFFileFormat section shows DPI 600.0.

So, I decided to do something wacky and type in an arbitrary DPI value into the Tiff export UI dialog and search for it within the prefs file - you know, on a chance that this TIFFFileFormat is not the *real* place to be looking at.

Sure enough, after quitting Illustrator (the prefs file is updated at that time) and restarting, I saw my value in a different spot in the file - completely by itself:/DPI 220.0

Changing this value in the prefs text file does nothing to the current operation of the application instance, and quitting AI overwrites the preferences to the latest UI input value. However if you change the text while Illustrator is not running, next time it starts up, it will actually use that value in the tiff export UI.

Bingo.

So the real way to change the preference here while Illustrator is operating is to do the script code for that stuff.

Here's how you can see what the current value of the 'standalone dpi' pref in script, thanks to Ten A​ for previous posts and helpful hints.

  var z = app.preferences.getRealPreference("DPI");

  alert(z);

And here's how you set it:

     app.preferences.setRealPreference("DPI", 350);

After the pref is set like so, the desired outcome is produced: the UI dialog reflects the new set value.

Does this work or solve our Tiff issue? Well, hopefully, I would assume so. Need to do a test one day.

Bottom line: The Tiff DPI is really not here:

The Tiff DPI setting is actually here!

CarlosCanto
Community Expert
Community Expert
April 28, 2016

great finding, thanks for sharing, it'll come handy.

Qwertyfly___
Qwertyfly___Correct answer
Legend
September 28, 2015

your not the first person to hit this wall.

take a look at this thread...

Problem when passing value to resolution (Export TIFF)

though I don't think using photoshop is ideal as illustrator has(should have) the capabilities...

it actually does work but it uses a value from 2 times ago. Don't ask me to explain!

ie

set dpi          saved dpi

250              250

80                250

100              250

100              80

150              100

200              100

300              150

starting to see the pattern...

Here is my hack work around.

I set the res to 72 for the dead saves so they don't take too long.

#target illustrator-19

function test(){

    if(app.documents.length == 0){

        return;

    }

    var doc = app.activeDocument;

    var dest = Folder.selectDialog("Choose Folder.");

    if(dest != null){

        var opts = new ExportOptionsTIFF();

        var destFile = File(dest + "/" + "TestFile.tif");

        opts.resolution = 300;

        doc.exportFile(destFile, ExportType.TIFF, opts);

        opts.resolution = 72;

        doc.exportFile(destFile, ExportType.TIFF, opts);

        doc.exportFile(destFile, ExportType.TIFF, opts);

        alert("Successfully exported '" + destFile.displayName + "'.\nNow, check out that resolution...");

    }

}

test();

Silly-V
Silly-VAuthor
Legend
September 29, 2015

This is why we can't have nice things! As in, well-meaning people can try all they can to make tutorials for the public for AI scripting, but it's stuff like this which would eventually deteriorate them into "Well, actually it's like the Heisenberg principle.. good luck!".

Brilliant work! Also, can't believe I missed the thread you referenced in my forum search when I was searching.

So, now then, when batch exporting TIFFs, I'll just have to do a temp blank file 3x before proceeding with the whole batch at my desired resolution to set it.

I'm pretty sure I owe you a beer for this answer!

Qwertyfly___
Legend
September 29, 2015

Glad I could help out.

I think 2x temp files would be enough to purge and old values out.

and if poss go for a small file to do that so you don't waste time creating 2 useless 1GB+ files.

and its just gone 12 noon here, so beer would be perfect. something black if possible!