28 Replies Latest reply on Feb 18, 2013 4:32 PM by Gustavo Del Vechio

    Problem when passing value to resolution (Export TIFF)

    Gustavo Del Vechio Level 3

      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.

        • 1. Re: Problem when passing value to resolution (Export TIFF)
          Larry G. Schneider Adobe Community Professional & MVP

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

          • 2. Re: Problem when passing value to resolution (Export TIFF)
            Gustavo Del Vechio Level 3

            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.

            • 3. Re: Problem when passing value to resolution (Export TIFF)
              Larry G. Schneider Adobe Community Professional & MVP

              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.

              • 4. Re: Problem when passing value to resolution (Export TIFF)
                Michael L Hale Level 5

                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.

                • 5. Re: Problem when passing value to resolution (Export TIFF)
                  Gustavo Del Vechio Level 3

                  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.

                  • 6. Re: Problem when passing value to resolution (Export TIFF)
                    Muppet Mark Level 5

                    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…

                    • 7. Re: Problem when passing value to resolution (Export TIFF)
                      Gustavo Del Vechio Level 3

                      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.

                      • 8. Re: Problem when passing value to resolution (Export TIFF)
                        Gustavo Del Vechio Level 3

                        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.

                        • 9. Re: Problem when passing value to resolution (Export TIFF)
                          Muppet Mark Level 5

                          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)


                          • 10. Re: Problem when passing value to resolution (Export TIFF)
                            Gustavo Del Vechio Level 3

                            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.

                            • 11. Re: Problem when passing value to resolution (Export TIFF)
                              Gustavo Del Vechio Level 3

                              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.

                              • 12. Re: Problem when passing value to resolution (Export TIFF)
                                Muppet Mark Level 5

                                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…

                                • 13. Re: Problem when passing value to resolution (Export TIFF)
                                  Gustavo Del Vechio Level 3

                                  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.

                                  • 14. Re: Problem when passing value to resolution (Export TIFF)
                                    Muppet Mark Level 5

                                    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…

                                    • 15. Re: Problem when passing value to resolution (Export TIFF)
                                      Gustavo Del Vechio Level 3

                                      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.

                                      • 16. Re: Problem when passing value to resolution (Export TIFF)
                                        Muppet Mark Level 5

                                        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…

                                        • 17. Re: Problem when passing value to resolution (Export TIFF)
                                          Gustavo Del Vechio Level 3

                                          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.

                                          • 18. Re: Problem when passing value to resolution (Export TIFF)
                                            Muppet Mark Level 5

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

                                            • 19. Re: Problem when passing value to resolution (Export TIFF)
                                              Gustavo Del Vechio Level 3

                                              No...does nothing too.

                                               

                                              Gustavo.

                                              • 20. Re: Problem when passing value to resolution (Export TIFF)
                                                CarlosCanto Adobe Community Professional & MVP

                                                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 );
                                                }
                                                }
                                                
                                                • 21. Re: Problem when passing value to resolution (Export TIFF)
                                                  Gustavo Del Vechio Level 3

                                                  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.

                                                  • 22. Re: Problem when passing value to resolution (Export TIFF)
                                                    Gustavo Del Vechio Level 3

                                                    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

                                                    • 23. Re: Problem when passing value to resolution (Export TIFF)
                                                      CarlosCanto Adobe Community Professional & MVP

                                                      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.

                                                      • 24. Re: Problem when passing value to resolution (Export TIFF)
                                                        klemango

                                                        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[i].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).

                                                        • 25. Re: Problem when passing value to resolution (Export TIFF)
                                                          Gustavo Del Vechio Level 3

                                                          Hi Klemango

                                                           

                                                          Thank you for posting this. Althought I was not intended to need Photoshop to do it...it´s good to learn I could do this way too

                                                           

                                                          Just one question: Why did you need to save an EPS in order to open in Photoshop?? Would not opening the AI file directlly in Photoshop (considering you chosed to include the PDF data) save time and code?

                                                           

                                                          Best Regards

                                                          Gustavo.

                                                          • 26. Re: Problem when passing value to resolution (Export TIFF)
                                                            klemango Level 1

                                                            Perhaps.  I'm not sure.  I was having problems importing the proper percentages of CMYK colors into PS (mainly K) via files saved as AI or PDF with scripts.  Opening those same files in PS manually didn't seem to have this problem.  EPS files didn't have this issue, so I stuck with them.  They also seem to save extremely fast.

                                                             

                                                            That's why I was interested when I saw your post about the new TIFF features in CS6--because I had such a problem!  I was hoping CS6 would do away with all the nonsense I had to go through!

                                                            • 27. Re: Problem when passing value to resolution (Export TIFF)
                                                              Gustavo Del Vechio Level 3

                                                              I need to learn how to work with BridgeTalk..I have some questions yet. But when I learn then I´ll be able to make test like you haha

                                                              • 28. Re: Problem when passing value to resolution (Export TIFF)
                                                                Gustavo Del Vechio Level 3

                                                                Ahh..hey friends...

                                                                 

                                                                As I promised, I´d like to share you the final version of my script. As TIFF is not working properly in CS6, I adapted my script to export as PSD. So here´s the version 1 (it´s my first public script, from a very beginner in programming and JavaScript. If you find any crazy thing in the code, please do not worry hahahaha

                                                                 

                                                                Download via this link: https://dl.dropbox.com/u/35273119/Export%20artboards%20as%20PSD%20v1%20%28English%20langua ge%29.jsx

                                                                 

                                                                Hope you like it

                                                                 

                                                                Best Regards

                                                                Gustavo.