3 Replies Latest reply on Sep 8, 2015 7:47 AM by nvkzNemo

    Place image in active document 'not as smart object'

    JokerMartini

      How can i place an image into the active document, but not as a smart object?

        • 1. Re: Place image in active document 'not as smart object'
          nvkzNemo Level 2

          Edit > Preferences > General > Always Crete Smart Objects when Placing

           

          placeRasterSmartObject(false);
          
          /* Do something */
          
          placeRasterSmartObject(true);
          
          function placeRasterSmartObject(__bool) {
              var desc1 = new ActionDescriptor();
              var ref1 = new ActionReference();
              ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('GnrP'));
              ref1.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
              desc1.putReference(charIDToTypeID('null'), ref1);
              var desc2 = new ActionDescriptor();
              desc2.putBoolean(stringIDToTypeID("placeRasterSmartObject"), __bool);
              desc1.putObject(charIDToTypeID('T   '), charIDToTypeID('GnrP'), desc2);
              executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
          }
          
          
          
          • 2. Re: Place image in active document 'not as smart object'
            JokerMartini Level 1

            Could you demonstrate this being using with an actual image file?

            • 3. Re: Place image in active document 'not as smart object'
              nvkzNemo Level 2
              var filePath = new File(decodeURI('~/Downloads/Safari_logo.png')),
                  currentValue = getPlaceRasterSmartObjectValue();
              
              
              if (currentValue == true) {
                  placeRasterSmartObject(false);
              }
              
              
              placeEmbedded(filePath); /* Place Image */
              
              
              placeRasterSmartObject(currentValue); /* Return the default value */
              
              
              function placeRasterSmartObject(__bool) {
                  var desc1 = new ActionDescriptor();
                  var ref1 = new ActionReference();
                  ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('GnrP'));
                  ref1.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
                  desc1.putReference(charIDToTypeID('null'), ref1);
                  var desc2 = new ActionDescriptor();
                  desc2.putBoolean(stringIDToTypeID("placeRasterSmartObject"), __bool);
                  desc1.putObject(charIDToTypeID('T   '), charIDToTypeID('GnrP'), desc2);
                  executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
              }
              
              
              function placeEmbedded(filePath) {
                  var actDesc = new ActionDescriptor();
                  actDesc.putPath(charIDToTypeID('null'), filePath);
                  actDesc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa'));
                  executeAction(charIDToTypeID('Plc '), actDesc, DialogModes.NO);
              }
              
              
              /* Update: Check current value */
              function getPlaceRasterSmartObjectValue() {
                  var ref = new ActionReference();
                  ref.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("GnrP"));
                  ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
                  var psKey = executeActionGet(ref).getObjectValue(charIDToTypeID("GnrP")).getBoolean(stringIDToTypeID("placeRasterSmartObject"));
                  return psKey
              }