4 Replies Latest reply on Nov 5, 2012 4:51 AM by Nicolas3448

    Export for web problem

    Nicolas3448

      Hello,

       

      I have a problem with the export for web and device. I use this script :

       

      var vOptions = new ExportOptionsSaveForWeb();

      vOptions.format = SaveDocumentType.JPEG;

      vOptions.quality = 90;

      myPsDoc.exportDocument(vFile, ExportType.SAVEFORWEB, vOptions);

       

      All works fine except if before use this script, I export manually for web and device, and choose "HTML" or "HMTL and images" on format list. After that, when I execute my script, I have the html file (or html file and image file in folder) and not the image.

       

      How can I override this settings ?

       

      Thank you for your help.

        • 1. Re: Export for web problem
          Paul Riggott Level 6

          It's difficult to say as you haven't shown your filename, you are appending the ".jpg" arn't you?

          Save for Web can produce strange filenames depending on certain settings also make sure you have the latest updates for Photoshop.

          These settings can and do make a difference if you have spaces in your name, or lengh of filename....

          SaveForWeb.jpg

           

          The best way to save a file with the correct file name is to save it with a simple tempory name then rename it to the file name that you want.

          • 2. Re: Export for web problem
            Nicolas3448 Level 1

            Hello,

             

            The problem is not the file name. The file name is ok. I already use a temp file and move it after. But when a user export with the format setting "HTML" before use script, the file generate by the script is an html file and not an image. I want to override this settings in my script to be sure an image is produced.

            SaveForWeb.jpg

            • 3. Re: Export for web problem
              Paul Riggott Level 6

              Yes this is a bug but there is a workaround by saving using scriptlistener output I.E.

               

               

              var saveFile = File(Folder.desktop + "/deleteMe.jpg");
              SaveForWeb(saveFile,80.);
               
              function SaveForWeb(FileName,Quality) {
              var doc = activeDocument;
              if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) doc.bitsPerChannel = BitsPerChannelType.EIGHT;
                  var desc7 = new ActionDescriptor();
                      var desc8 = new ActionDescriptor();
                      desc8.putEnumerated( charIDToTypeID('Op  '), charIDToTypeID('SWOp'), charIDToTypeID('OpSa') );
                      desc8.putEnumerated( charIDToTypeID('Fmt '), charIDToTypeID('IRFm'), charIDToTypeID('JPEG') );
                      desc8.putBoolean( charIDToTypeID('Intr'), false );
                      desc8.putInteger( charIDToTypeID('Qlty'), Quality );
                      desc8.putInteger( charIDToTypeID('QChS'), 0 );
                      desc8.putInteger( charIDToTypeID('QCUI'), 0 );
                      desc8.putBoolean( charIDToTypeID('QChT'), false );
                      desc8.putBoolean( charIDToTypeID('QChV'), false );
                      desc8.putBoolean( charIDToTypeID('Optm'), true );
                      desc8.putInteger( charIDToTypeID('Pass'), 1 ); 
                      desc8.putDouble( charIDToTypeID('blur'), 0.000000 );
                      desc8.putBoolean( charIDToTypeID('EICC'), false ); 
                      desc8.putBoolean( charIDToTypeID('Mtt '), false );
                      desc8.putInteger( charIDToTypeID('MttR'), 255 );
                      desc8.putInteger( charIDToTypeID('MttG'), 255 );
                      desc8.putInteger( charIDToTypeID('MttB'), 255 );
                      desc8.putBoolean( charIDToTypeID('SHTM'), false );
                      desc8.putBoolean( charIDToTypeID('SImg'), true );
                      desc8.putEnumerated( charIDToTypeID('SWch'), charIDToTypeID('STch'), charIDToTypeID('CHsR') );
                      desc8.putEnumerated( charIDToTypeID('SWmd'), charIDToTypeID('STmd'), charIDToTypeID('MDNn') );
                      desc8.putBoolean( charIDToTypeID('SSSO'), false );
                          var list2 = new ActionList();
                      desc8.putList( charIDToTypeID('SSLt'), list2 );
                      desc8.putBoolean( charIDToTypeID('DIDr'), false );
                      desc8.putPath( charIDToTypeID('In  '), new File( FileName) );
                  desc7.putObject( charIDToTypeID('Usng'), stringIDToTypeID('SaveForWeb'), desc8 );
                  executeAction( charIDToTypeID('Expr'), desc7, DialogModes.NO );
              };
              
              
              • 4. Re: Export for web problem
                Nicolas3448 Level 1

                Thank you for your help.

                It works correctly.