07-10-2018, 07:06 AM
I often use photoshop for image processing. I saw a PS automation component in a forum. It seems that I need to use C#, but I may need to install visual studio. It is too large. Can I use QM to run this automation component? I hope that developers can create an example and let more people use QM+PS automation components to work, thanks in advance.
Component download address( I have downloaded it, below):
http://psdotnet.com/downloads/
Component instructions
Note: PsDotNet is currently considered in a beta state. More information can be found at psdotnet.com or by emailing me at [email protected]
1. INTRODUCTION
PsDotnet is a strongly typed .net library used to automate Adobe Photoshop. It currently supports CS3, CS4, CS5, CS6, CC, CC2014, CC2015, CC2017, and CC2018.
2. KNOWN ISSUES
None
3. RELEASE INFO
This is a beta release. All of the features I wanted to get in for the initial release are in and tested as much as possible. If you encounter any issues let me know and I will fix it ASAP.
Release contents:
PsDotNet.dll
PsDotNet.pdb
readme.txt
4. USAGE
1) Add a reference to the PsDotNet.dll to your project. Make sure that it does not have prefer 32-bit checked in the project settings.
2) At the appropriate initialization place in your code, add one of the following:
PsConnection.StartAndConnect(); // Will start the highest version installed
PsConnection.StartAndConnect(EPsVersion.CS6); // Will start a specific version (if installed)
This only needs to be done once. If Photoshop is already started it will try to attach, otherwise it will start Photoshop and attach.
After initialization you can get the application by using the following code:
var app = PsConnection.Application;
Once you have the application you can do things like the following:
app.BackgroundColor = Color.Black.ToPsSolidColor();
app.ForegroundColor = Color.FromArgb(0, 0, 0, 128).ToPsSolidColor();
// Create a new document
IPsDocument document = app.Documents.Add(1024, 256, 72, "Welcome", EPsDocumentMode.psRGB);
//IPsDocument document = app.ActiveDocument;
// Add an alpha channel
document.Channels.Add("ExtraChannel", EPsChannelType.psMaskedAreaAlphaChannel);
// Create a new layer
IPsArtLayer cloudLayer = document.ArtLayers.AddNormalLayer("Clouds");
// Apply a few filters with default settings
cloudLayer.ApplyClouds();
cloudLayer.ApplyTwirl();
cloudLayer.ApplyAngledStrokes();
cloudLayer.ApplyAccentedEdges();
// Get a list of all of the available fonts
IEnumerable<IPsTextFont> fonts = app.Fonts.Cast<IPsTextFont>().ToList();
// Create a new text layer
IPsArtLayer textLayer = document.ArtLayers.AddTextLayer("Text");
textLayer.TextItem.Contents = ("Welcome to PsDotNet, " + Environment.UserName + "!");
var fontSize = 70;
textLayer.TextItem.Size = fontSize;
textLayer.TextItem.Position = new PointF((float)document.Width / 2, (float)document.Height / 2 + (float)fontSize / 2);
textLayer.TextItem.Justification = EPsJustification.psCenter;
textLayer.TextItem.Color = Color.OrangeRed.ToPsSolidColor();
textLayer.TextItem.Font = fonts.Skip(26).First();
textLayer.TextItem.HorizontalScale = 150;
// Create a layerStyle to apply to the Text layer
IPsLayerStyle layerStyle = app.CreateLayerStyle();
// Get the opposite color used from the foreground
IPsSolidColor pixelColor = app.ForegroundColor;
pixelColor.HSB.OffsetHue(180);
pixelColor.HSB.Saturation = 100;
pixelColor.HSB.Brightness = 100;
// Apply a glowStyle
IPsOuterGlowStyle glowStyle = layerStyle.AddOuterGlowStyle(pixelColor);
glowStyle.BlendMode = EPsLayerStyleBlendMode.Normal;
glowStyle.Opacity = 100;
glowStyle.Spread = 5;
glowStyle.Size = 50;
// Apply a strokeStyle
IPsStrokeStyleColorFillType strokeFill = app.CreateStrokeStyleColorFillType(Color.Black.ToPsSolidColor());
IPsStrokeStyle stroke = layerStyle.AddStrokeStyle(strokeFill);
stroke.Size = 2;
stroke.Position = EStrokePosition.Outside;
// Apply to the text layer
textLayer.ApplyLayerStyle(layerStyle);
// Flatten
document.Flatten();
Component download address( I have downloaded it, below):
http://psdotnet.com/downloads/
Component instructions
Note: PsDotNet is currently considered in a beta state. More information can be found at psdotnet.com or by emailing me at [email protected]
1. INTRODUCTION
PsDotnet is a strongly typed .net library used to automate Adobe Photoshop. It currently supports CS3, CS4, CS5, CS6, CC, CC2014, CC2015, CC2017, and CC2018.
2. KNOWN ISSUES
None
3. RELEASE INFO
This is a beta release. All of the features I wanted to get in for the initial release are in and tested as much as possible. If you encounter any issues let me know and I will fix it ASAP.
Release contents:
PsDotNet.dll
PsDotNet.pdb
readme.txt
4. USAGE
1) Add a reference to the PsDotNet.dll to your project. Make sure that it does not have prefer 32-bit checked in the project settings.
2) At the appropriate initialization place in your code, add one of the following:
PsConnection.StartAndConnect(); // Will start the highest version installed
PsConnection.StartAndConnect(EPsVersion.CS6); // Will start a specific version (if installed)
This only needs to be done once. If Photoshop is already started it will try to attach, otherwise it will start Photoshop and attach.
After initialization you can get the application by using the following code:
var app = PsConnection.Application;
Once you have the application you can do things like the following:
app.BackgroundColor = Color.Black.ToPsSolidColor();
app.ForegroundColor = Color.FromArgb(0, 0, 0, 128).ToPsSolidColor();
// Create a new document
IPsDocument document = app.Documents.Add(1024, 256, 72, "Welcome", EPsDocumentMode.psRGB);
//IPsDocument document = app.ActiveDocument;
// Add an alpha channel
document.Channels.Add("ExtraChannel", EPsChannelType.psMaskedAreaAlphaChannel);
// Create a new layer
IPsArtLayer cloudLayer = document.ArtLayers.AddNormalLayer("Clouds");
// Apply a few filters with default settings
cloudLayer.ApplyClouds();
cloudLayer.ApplyTwirl();
cloudLayer.ApplyAngledStrokes();
cloudLayer.ApplyAccentedEdges();
// Get a list of all of the available fonts
IEnumerable<IPsTextFont> fonts = app.Fonts.Cast<IPsTextFont>().ToList();
// Create a new text layer
IPsArtLayer textLayer = document.ArtLayers.AddTextLayer("Text");
textLayer.TextItem.Contents = ("Welcome to PsDotNet, " + Environment.UserName + "!");
var fontSize = 70;
textLayer.TextItem.Size = fontSize;
textLayer.TextItem.Position = new PointF((float)document.Width / 2, (float)document.Height / 2 + (float)fontSize / 2);
textLayer.TextItem.Justification = EPsJustification.psCenter;
textLayer.TextItem.Color = Color.OrangeRed.ToPsSolidColor();
textLayer.TextItem.Font = fonts.Skip(26).First();
textLayer.TextItem.HorizontalScale = 150;
// Create a layerStyle to apply to the Text layer
IPsLayerStyle layerStyle = app.CreateLayerStyle();
// Get the opposite color used from the foreground
IPsSolidColor pixelColor = app.ForegroundColor;
pixelColor.HSB.OffsetHue(180);
pixelColor.HSB.Saturation = 100;
pixelColor.HSB.Brightness = 100;
// Apply a glowStyle
IPsOuterGlowStyle glowStyle = layerStyle.AddOuterGlowStyle(pixelColor);
glowStyle.BlendMode = EPsLayerStyleBlendMode.Normal;
glowStyle.Opacity = 100;
glowStyle.Spread = 5;
glowStyle.Size = 50;
// Apply a strokeStyle
IPsStrokeStyleColorFillType strokeFill = app.CreateStrokeStyleColorFillType(Color.Black.ToPsSolidColor());
IPsStrokeStyle stroke = layerStyle.AddStrokeStyle(strokeFill);
stroke.Size = 2;
stroke.Position = EStrokePosition.Outside;
// Apply to the text layer
textLayer.ApplyLayerStyle(layerStyle);
// Flatten
document.Flatten();