Create a folder of layer in Photoshop Javascript - directory

in Photoshop, you can create folder with layer in it. I would like to do this with Photoshop script (JS). I have been looking to the documentation but didn't found any way to do it. Can someone show me the command or lead me to a related question please ? Thank you !
The doc I looked at :
https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-scripting-guide-2020.pdf

I found this and it seems to work :
var group = app.activeDocument.layerSets.add();
group.name = "Annotations";
var layerGroup = app.activeDocument.layerSets.getByName("Annotations");
var layerRef = layerGroup.artLayers.add();
layerRef.name = "Annotations";
layerRef.blendMode = BlendMode.NORMAL;

Related

S3 Multipart Upload with SSE-KMS

I am trying to write a utility using aws-java-sdk (1.11.230).
I am able to write a file with SSE-KMS by using PutObjectRequest as follow:
PutObjectRequest putRequest = new PutObjectRequest(existingBucketName, keyName, file)
.withSSEAwsKeyManagementParams(kmsKeyId);
but while trying to upload it in multipart, I could not find any way to specify encryption configuration for SSE-KMS.
Could anyone please suggest a way to go through this successfully.
Any suggestion will be appreciated.
Vikash Pareek
Can also be done like this:
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest("example-bucket", "textfile.txt"); SSEAwsKeyManagementParams kms = new SSEAwsKeyManagementParams("KMS-key-alias");
initRequest.setSSEAwsKeyManagementParams(kms);
initResponse = s3Client.initiateMultipartUpload(initRequest);
Finally, I am able to find the solution for this. It can be done by setting headers to InitiateMultipartUploadRequest object as follow:
InitiateMultipartUploadRequest initRequest = new
InitiateMultipartUploadRequest(bucketName, keyName);
initRequest.putCustomRequestHeader("x-amz-server-side-encryption", "aws:kms");
initRequest.putCustomRequestHeader("x-amz-server-side-encryption-aws-kms-key-id", kmsKey);

document.querySelectorAll not defined

I am following a calculator tutorial from here: http://thecodeplayer.com/walkthrough/javascript-css3-calculator
However I am using nitrous as the IDE and Meteor. In this part of the code in the js file:
// Get all the keys from document
var keys = **document.querySelectorAll**("#calculator span");
var operators = ['+', '-', 'x', 'รท'];
var decimalAdded = false;
The 'document.querySelector All' part comes up with a not defined error. I have tried replacing it with the more Meteor friendly 'template. find' however then it just says that template is not defined. Any help would be very much appreciated. :)

DevExpress WinForms XtraRichEdit - Export Document to an Image

I'm looking for an ability to export documents (e.g. doc, rtf, txt) as images. Does XtraRichEdit support such functionality? This is definitely supported by Aspose.Words, but I'm not sure about DevExpress.
This can be done by using the XtraPrinting Library. Please refer to the code below:
using DevExpress.XtraPrinting;
//...
PrintableComponentLink link = new PrintableComponentLink(printingSystem1);
link.Component = richEditControl1;
link.CreateDocument();
link.ExportToImage(#"c:\image.png", new ImageExportOptions()
{
Format = System.Drawing.Imaging.ImageFormat.Png,
ExportMode = ImageExportMode.DifferentFiles,
Resolution = 96
});

How can I obtain ObjectSet<T> from Entity-Framework at runtime where T is dynamic?

(Note, the code below are just examples. Please don't comment on the why this is necessary. I would appreciate a definitive answer of YES or NO, like if it is possible then how? If not it's fine too. If the question is vague let me know also. Thanks!)
Example, I can get ObjectSet<T> below:
ObjectSet<Users> userSet = dbContext.CreateObjectSet<Users>();
ObjectSet<Categories> categorySet = dbContext.CreateObjectSet<Categories>();
The code above works okay. However, I need the entity table to be dynamic so I can switch between types. Something like below.
//var type = typeof(Users);
var type = typeof(Categories);
Object<type> objectSet = dbContext.CreateObjectSet<type>();
But the code above will not compile.
[EDIT:]
What I'd like is something like, or anything similar:
//string tableName = "Users";
string tableName = "Categories";
ObjectSet objectSet = dbContext.GetObjectSetByTableName(tablename);
I've got this working with the following tweak to the suggestions above:
var type = Type.GetType(myTypeName);
var method = _ctx.GetType().GetMethod("CreateObjectSet", Type.EmptyTypes);
var generic = method.MakeGenericMethod(type);
dynamic objectSet = generic.Invoke(_ctx, null);
Can you use the example here in How do I use reflection to call a generic method?
var type = typeof(Categories); // or Type.GetType("Categories") if you have a string
var method = dbContext.GetType.GetMethod("CreateObjectSet");
var generic = method.MakeGenericMethod(type);
generic.Invoke(dbContext, null);
I have found the answer here, http://geekswithblogs.net/seanfao/archive/2009/12/03/136680.aspx. This is very good because it eliminates having multiple repository objects for each table mapped by EF particularly for mundane operations like CRUD, which is exactly what I was looking for.

AS3: reading embedded metadata in flex

I saw that you can embed meta-data into images very much like you can in mp3s, here.
Can someone point me to a tutorial of how to embed and read this sort of information w/ photoshop and flex together?
I really wouldn't know where to start... Tried googling but I'm not sure I have the right keywords down.
Thanks!
I've written a small snippet on the matter. this snippet is far from being proper tested, and is most definite not written in a clear and coherent way. But for now it seems to work. I'll update as I work on it.
private function init(event:Event):void
{
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
var s:String = "link/to/asset.jpg";
ldr.load(new URLRequest(s));
}
private function imgLoaded(e:Event):void{
var info:LoaderInfo = e.target as LoaderInfo;
var xmpXML:XML = getXMP(info.bytes);
//trace(xmpXML);
var meta:XMPMeta = new XMPMeta(xmpXML);
}
private function trim(s:String):String{
return s.replace( /^([\s|\t|\n]+)?(.*)([\s|\t|\n]+)?$/gm, "$2" );
}
private function getXMP(ba:ByteArray):XML{
var LP:ByteArray = new ByteArray();
var PACKET:ByteArray = new ByteArray();
var l:int;
ba.readBytes(LP, 2, 2);
/*
http://www.adobe.com/devnet/xmp.html
read part 3: Storage in Files.
that will explain the -2 -29 and other things you see here.
*/
l = LP.readInt() - 2 -29;
ba.readBytes(PACKET, 33, l);
var p:String = trim(""+PACKET);
var i:int = p.search('<x:xmpmeta xmlns:x="adobe:ns:meta/"');
/* Delete all in front of the XMP XML */
p = p.substr(i);
/*
For some reason this left some rubbish in front, so I'll hardcode it out for now
TODO clean up
*/
var ar:Array = p.split('<');
var s:String = "";
var q:int;
var j:int = ar.length;
for(q=1;q<j;q++){
s += '<'+ar[q];
}
i = s.search('</x:xmpmeta>');
i += ('</x:xmpmeta>').length;
s = s.slice(0,i);
/* Delete all behind the XMP XML */
return XML(s);
}
Originally from http://snipplr.com/view/51037/xmp-metadata-from-jpg/
Photoshop (CS4+ I think) can also add XMP headers (XML style) which will be easier to parse than bytes but it contains different information.
http://code.google.com/p/exif-as3/
Here is a class that should do the job. It is non-commercial only but there is another option.
www.ultrashock.com/forums/server-side/extracting-metadata-from-photos-86065.html
Here is a php script that will do it that could be ported to as3 - it might be easier than creating one from scratch. If you did want php to read the info I would use the built in exif functions :)
Well AS3 don't have a built-in class to read jpg header.
BUT, if you are loading the image using URLLoader you can use the ByteArray to read if manually.
You can find the spec here:
http://www.obrador.com/essentialjpeg/HeaderInfo.htm
If you need some tutorial of using Bytearray you can start from here:
How to convert bytearray to image or image to bytearray ?
or here:
http://digitalmedia.oreilly.com/pub/a/oreilly/digitalmedia/helpcenter/flex3cookbook/chapter8.html?page=7
The principle is the same -read the bytes, convert them to readable data using the spec above and use it.
Good luck!
Yes, entirely possible. ByteArray is your friend.
You may want to give a read to this:
http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/
This may also be of use, but I'd rather go with the first option:
http://download.macromedia.com/pub/developer/xmp/sdk/XMPLibrary-v1.0.zip

Resources