Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Plugin and Companion App SDK
Viewing all articles
Browse latest Browse all 54282

How to place raster images as smart objects?

$
0
0

I'm trying to duplicate Photoshop's File:Place menu functionality and I'm experiencing something that I can't figure out. (I've added my code to the end of this message.)

 

I have a variety of test EPS images that I can run through the File:Place menu. They all appear on the document as "Smart Objects". That is I can then do a bunch of transforms to the image (like rotate, move, deform) before committing to the image to the document.

 

The important point here is that some images, when opened by Photoshop, first ask that I "Rasterize EPS Format" while others just open up without comment.

 

While doing these File:Place actions, I've been using the Listener plugin that comes with the SDK to generate code dumps of my actions. From these I've then generated my own code for placing images onto a document. I've had to re-arrange the code a bit to work in Objective-C so there's a good chance that I've done something wrong while translating.

 

Now if you look at my code you notice a commented out section. If you uncomment those lines then you basically have what I got from the Listener plugin log. But the problem is that this code then doesn't act like the File:Place menu action. It creates a new layer, places the image on the page - but its gone one step too far and the image is no longer a "Smart Object". The image is committed to the layer.

 

With a bit of experimenting I commented out the line that you can see commented out in my code. However, this does something odd. For all images you can see Photoshop put up a busy icon for a few seconds showing that it is process, but only images that Photoshop wants to "Rasterize EPS Format" actually appear on the page as Smart Objects. Trying to place the images that Photoshop doesn't rasterize results in nothing appearing.

 

That's my problem. If I uncomment that line in my code then all images that I test with appear on the page - but not as Smart Objects. If I comment out the code then only images that Photoshop wants to rasterize appear - but those that do appear then appear as Smart Objects.

 

So that's my goal: to place any image onto a document as a Smart Object just like Photoshop's File:Place menu command does. Any ideas where I'm going wrong?

 

//------------

 

- (SPErr)photoshopPlayeventPlace:(char *)cPath

{

PIActionDescriptor result = NULL;

 

Auto_Desc descriptor;

Auto_Desc offsetDetails;

 

SPErr error = kSPNoError;

 

Handle aliasValue = NULL;

FullPathToAlias(cPath, aliasValue);

 

do

{

error = sPSActionDescriptor->PutAlias(descriptor.get(), keyNull, aliasValue);

if (error) break;

 

// error = sPSActionDescriptor->PutEnumerated(descriptor.get(), keyFreeTransformCenterState, typeQuadCenterState, enumQCSAverage);

// if (error) break;

 

error = sPSActionDescriptor->PutUnitFloat(offsetDetails.get(), keyHorizontal, unitDistance, 0);

if (error) break;

 

error = sPSActionDescriptor->PutUnitFloat(offsetDetails.get(), keyVertical, unitDistance, 0);

if (error) break;

 

error = sPSActionDescriptor->PutObject(descriptor.get(), keyOffset, classOffset, offsetDetails.get());

if (error) break;

 

error = sPSActionControl->Play(&result, eventPlace, descriptor.get(), plugInDialogSilent);

if (error) break;

}

while (false);

if (result != NULL) sPSActionDescriptor->Free(result);

if (aliasValue != NULL) sPSHandle->Dispose(aliasValue);

 

return error;

}

 


Viewing all articles
Browse latest Browse all 54282

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>