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

Problem when passing value to resolution (Export TIFF)

Advocate ,
Feb 13, 2013 Feb 13, 2013

I´m passing by a strange script behaviour. I´m trying to refine a script to export artboards as TIFF.

So suppose I started "var op = new ExportOptionsTIFF()"

And I set op.resolution = 250

Now I try to run this script via Extended Script Toolkit. I press play and it goes right...But If I make more tests I have this problem:

If I set a differnt resolution (for example, 365) the Script will ignore this new and will use the only value 250 defined in the past (in my first test). If, for a third time, I set another new value, the Extended Script will ignore this value and use the 365 I set in a previous test.

Look´s it´s recording the differnt values I put but it is always delayed one or two times 😕

Do not know if I was able to better explain the problem.

Have you already passed by it?? Should I consider this as a problem? Or it´s only an Extendes Script software mistake?

Thank you a lot

Gustavo.

TOPICS
Scripting
5.9K
Translate
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
LEGEND ,
Feb 14, 2013 Feb 14, 2013

Just a couple of quick questions. Is AI targeted in the script? Do you save after making the changes?

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Yes Larry

I inserted #target illustrator as the first line of the code.

And I save after making changes. Even running the script directlly from Illustrator, the same problem occurs.

😕

Any idea?

Gustavo.

Translate
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
LEGEND ,
Feb 14, 2013 Feb 14, 2013

You might try using the Export from the GUI in AI and see what is reported in the resolution fields. It may be setting the resolution there and uses the last export value before changing it.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

I am just starting to script InDesign and Illustrator after years of Photoshop scripting so this may not help. But the Illustrator guide doesn't list an exportoption for tiff.

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Hi Larry

I´ve made the test you suggested. After exporting normally from File > Export (using for example resolution as 456 ppi)..I tried to run my script...And (lol) even I setting a different resolution in my dialog box it exported using the resolution of last File > Export acess.

However...after acessing and running again my script, Illustrator ignores that 456 ppi and go back to export using an old resolution I set times ago.

It´s crazy hehehe

--

Michael...yes Illustrator CS6 has an object called ExportOptionsTIFF. See CS6 documentation.

Gustavo.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

Yep this class is new to CS6 which I don't yet have so sorry Gustavo… I can't offer any help on this… Pre CS6 you could use AI's image capture but its lacking some proper options…

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

The stranger is:

If I insert an alert just one line before the document.export method in my code...like alert(op.resolution) ...remembering "op" is my variant of the ExportOptionsTIFF object...it returns the correct number set in the dialog box 😕

Also..seems the ExportOptionsTIFF.embedICCProfile is not working too (at least in my tests). This property is not documented..but it´s avaliable in the library!

Gustavo.

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Just one more question:

Is ExportOptionsJPG also new to CS6? Or it´s from older Ai versions?

Perhaps I could change the properties to target this object and see if the resolution problem persists

Gustavo.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

TIFF is new to CS6… Changing to JPEG will be of no help… All exports from AI have been restricted to 72dpi resolution… Offering a scale factor instead ( I don't know anybody how finds it useful this way around but hey ho it must be!!! to someone? ) Only export to PSD has resolution option before CS6… BTW what happens if you set this line twice in your code

op.resolution = 250;

the color profile is in my docs…

Class

ExportOptionsTIFF

Options which may be supplied when exporting a document as a TIFF file.

Class

PropertyTypeAccessDescription
antiAliasingAntiAliasingMethod:
AntiAliasingMethod.None
AntiAliasingMethod.ARTOPTIMIZED
AntiAliasingMethod.TYPEOPTIMIZED
r/wShould the resulting image be antialiased. (default: AntiAliasingMethod.ARTOPTIMIZED)
artboardRangestringr/wIf SaveMultipleArtboards is true,this will be considered for multi-asset extraction which specifies artboard range.Empty string will extracts all the artboards.Default is empty string.
byteOrderTIFFByteOrder:
TIFFByteOrder.IBMPC
TIFFByteOrder.MACINTOSH
r/wMac or PC byte order when exporting. (default: TIFFByteOrder.IBMPC)
embedICCProfileboolr/wEmbed an ICC profile when exporting. (default: false)
imageColorSpaceImageColorSpace:
ImageColorSpace.GrayScale
ImageColorSpace.RGB
ImageColorSpace.CMYK
ImageColorSpace.LAB
ImageColorSpace.Separation
ImageColorSpace.DeviceN
ImageColorSpace.Indexed
r/wThe color space of the exported file. (default: ImageColorSpace.RGB)
lZWCompressionboolr/wCompress TIFF file with LZW Compression when exporting. (default: false)
resolutionnumber (range: 72.0 - 2400.0)r/wThe resolution of the exported file. (default: 150)
saveMultipleArtboardsboolr/wAll the artboards or range of the artboards will be exported. (default: false)


Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Hi Muppet

I had already make this test (declare twice the resolution) but it does nothing. It continues to ignore the current resolution and use a resolution declared in previous times.

The Adobe Illustrator Script Reference tells the resolution must be a number (double)

What´s the influence of the "double" there?? I tried these tests:

op.resolution = 250

op.resolution = 250.0

op.resolution = "250"

It accepts everything (and also the string) but it looks not to make any difference!

Gustavo.

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

I isolated all the properties of TIFF...This is an example without my scripts dialog boxes

#target illustrator

var doc = app.activeDocument

var op = new ExportOptionsTIFF

op.antiAliasing = AntiAliasingMethod.TYPEOPTIMIZED

op.saveMultipleArtboards = true

op.artboardRange = "1"

op.byteOrder = TIFFByteOrder.IBMPC

op.embedICCProfile = true

op.lZWCompression = false

op.imageColorSpace = ImageColorSpace.RGB

op.resolution = 234.0

var ar = new File ("~/Desktop/My file.tif")

doc.exportFile (ar, ExportType.TIFF, op)

And it does not respect the op.resolution and does not respect the embedICCProfile = true 😕

So I´m assuming the problem is not in my functions or loops. Even not my dialog boxes and windows.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

I doubt you are constructing the object like that…

var op = new ExportOptionsTIFF

should be…

var op = new ExportOptionsTIFF();

and I always terminate my lines too…

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Thank you Muppet...

But...no... it continues not working (even setting the ExportOptionsTIFF() and even inserting the ; after each line).

Terminates the lines you mean by inserting ; at the end of each line??

Look´s it´s storing the past numbers in memory and using then after a time. Very strange rs.

Gustavo.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

Hum… then you may have to export a bogus TIFF with the options you want… Remove or overwrite with a further export… Ugly n Clunky… report the bug too it may get patched who knows…

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

How could I do that?? export a bogus TIFF?

AFAIK variables should be throwed out after completing the script running. So the time of a variable is the time script is running of a function is running. Anyway...as I´m having this problem...I´d like to ask a "fool" question (from the point of view of a beginner with JavaScript):

Is there any method in JavaScript to order to clean, empty all variables from previous scripts runned???

So I´m sure when running this script nothing is still in the memory?

Gustavo.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

AI's Javascript engine is persistent… As in your script variables are out for the user session… This is why they recommend wraping your variables in functions… I can't say I've put much of this to the test but you may want to try setting them all to null at the end of your script… I doubt $.gc() is going to do anything here either… Not sure if thats just for testing in the ESTK though…

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Yeah It really did not work too.. If I set op.resolution to null then I receive an error: "Specified value less than minimum allowed value"

If I set op.resolution to undefined then it does not resolve.

IF I use the $.gc() also does nothing.

I´ll try to report it as a bug and see what happens.

Thank you for your patiente Muppet and Larry.

Best Regards

Gustavo.

Translate
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
Mentor ,
Feb 14, 2013 Feb 14, 2013

I meant set your variable holding the object to null… op = null;

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

No...does nothing too.

Gustavo.

Translate
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 ,
Feb 14, 2013 Feb 14, 2013

I don't have CS6, so I changed your script to export as Photoshop, and it works just fine...so, there you go, make your own conclusions...but let me tell you, don't be surprised if Exporting to TIFF does not work, there's a number of other things that don't work either hahaha...

why don't you try a new script with a simple function, no multiple options, just hardcode the resolution to see if it works...this one is from the documentation, change PS to TIFF. If it works, include a prompt to ask for resolution...

// Exports current document to dest as a PSD file with specified

// options, dest contains the full path including the file name

function exportFileToPSD (dest) {

if ( app.documents.length > 0 ) {

var exportOptions = new ExportOptionsPhotoshop();

var type = ExportType.PHOTOSHOP;

var fileSpec = new File(dest);

exportOptions.resolution = 150;

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

}

}

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

Hi Carlos

Hahah if there are other things that does not work too..then I can keep myself calmer hahaha.

I´ve tried a new script with just TIFF options (see message 11 of this discussion). But it does not work either. Seems it´s really a bug.

Gustavo.

Translate
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
Advocate ,
Feb 14, 2013 Feb 14, 2013

But you gave me an idea Carlos

While not find a solution for ExportOptionsTiff, I'll change my script to export PSDs instead. Looks the properties are very near to Tiff.

Tomorrow late I publish here the result.

By the way..I'm checking the Illustrator version in the beginning of the script. So do you know when Illustrator starting supporting Exporting psds from JavaScript? So I could limit to users using supported version?

Thank you a lot

Gustavo

Translate
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 ,
Feb 14, 2013 Feb 14, 2013

sorry I don't know that, I would guess all versions should support psd, you'll only be limited to the earliest version that support scriptUI, which I guess is CS2

edit:

check the devnet, they have all guides for download.

Translate
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
Participant ,
Feb 18, 2013 Feb 18, 2013

Hello Gustavo,

I had the same problem with the limitations of exporting TIFF files from AI.  I solved the problem by using two functions (with help from everyone in both this and the Photoshop forum.  Thank you all, again!).

My solution was to export the file from AI as an .eps file, then open it in Photoshop so I could use all of its TIFF features.  It seems clunky and messy, but it works.  And, thanks to everyone having newer computers here, it's relatively fast.  This is being called from a palette button:

 

saveEPS();

 

function saveEPS()

{

    var bt = new BridgeTalk();

    bt.target = "illustrator";

   

    var script =  "var destination = (\"S:/Extras/Bookmark.eps\");" +

        "exportFileToEPS(destination);" +

        "function exportFileToEPS(destFile){" +

        "copy();"  +

        "var delSel = app.activeDocument.selection;" +  

        "for (i=0;i<delSel.length;i++){" +

        "delSel.remove();" +

        "}" +

          "app.documents.add();" + 

        "var saveDoc = app.activeDocument;" +

        "paste();"  +   

        "var newFile = new File(destFile);" +

        "var saveDoc;"  + 

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

        "saveDoc = app.documents.add();}" +

        "else {saveDoc = app.activeDocument;}" +

        "var saveOpts = new EPSSaveOptions();" +

        "saveOpts.cmykPostScript = true;" +

        "saveOpts.embedAllFonts = true;" +

        "saveDoc.saveAs( newFile, saveOpts );" +

        "app.activeDocument.close();}" 

 

    bt.body = script;

    bt.onResult = function(retObj){photoshopFile()}; 

    bt.onError = function(ErrObj) {alert("There's been a error saving the file.  Please try again.")};

    bt.send();

   

}

function photoshopFile()

{

   var bt = new BridgeTalk();

        bt.target = "photoshop";

       

   var script = "var originalRulerUnits = app.preferences.rulerUnits;" +

      "app.preferences.rulerUnits = Units.PIXELS;" +

      "var fileRef = new File(\"S:/Extras/Bookmark.eps\");" +

      "var epsOpenOptions = new EPSOpenOptions;" +

      "epsOpenOptions.antiAlias = true;" +

      "epsOpenOptions.mode = OpenDocumentMode.CMYK;" +

      "epsOpenOptions.resolution = 300;" +

      "epsOpenOptions.page = 3;" +

       "app.open( fileRef, epsOpenOptions );" +

       "app.preferences.rulerUnits = originalRulerUnits;" +

       "var saveName = new File (\"S:/Extras/Bookmark\");" +

       "saveOpts = new TiffSaveOptions();" +

       "saveOpts.imageCompression = TIFFEncoding.JPEG;" +

       "saveOpts.jpegQuality = 12;" +

       " saveOpts.layers = true;" +

       "saveOpts.embedICCProfile = true;" +

       "app.activeDocument.saveAs( saveName, saveOpts );" +

       "fileRef.remove();" +

        "app.activeDocument.close();"

           

  bt.body = script;

   

  bt.onResult = function(retObj){retrieveTIFF()}; 

  bt.onError = function(ErrObj) {alert("There's been an error opening the file.  Please try again.")};

  bt.send();

}

Notice that some requirements for the TIFF file are given during the creation of the Photoshop file, not on the export from Illustrator.  This is for CS5.1

I'm not sure if this will help in your situation, but I thought I would throw it out there to see if it might be something you can use.  (NOTE: there's some copying, pasting, and removing being done for my specific application that are not necessarily required.  Also, onResult back from PS when completed calls anthor function that's not listed).

Translate
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