Graduate student needs help with script writing

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

radellin

Graduate student needs help with script writing

Post by radellin »

I am a graduate student currently working on my master’s thesis in biology, and I need help with creating a Photoshop script. I am currently working with Photoshop CS 2 and I am very new to working in the program. I have spoken to my advisor about creating a script that will allow me to edit my photographs more quickly and he has advised me to post this to your forum to seek volunteers. I have taken photographs of leaves without regard to scale, and need to size them so that they are all at the same scale. For example, the two pictures I have attached represent the largest and smallest leaves I have photographed. The one labeled "Leaf_R_58_a" is about 235 mm long. The one labeled "Leaf_R_48_b" is about 60 mm long.





I would like to be able to create pictures with standard pixel dimensions, in which the leaf images are centered and occupy the number of pixels that corresponded to their true size (i.e., the leaf on the right would occupy 60/234 of the length occupied by the leaf on the right). The extra space would be filled with black. I would start with the largest species and “shrink” all others to fit their appropriate relative sizes. I have hundreds of images to process so I need a way to at least semi-automate this procedure.
My advisor suggested that the script should be able to do the following:
1. Open the photograph (they are all taken with the same camera and will all be the same size).
2. Identify the top and bottom points on the leaf.
3. Input the relative size that this leaf should be within pixel size of the image (if it were the picture on the left, I would input 60/234, in decimal form)
4. The script would resize the image to the proper dimensions, then increase the canvas size to the starting size of the original image and fill the blank space with black.
5. The new file would be saved as a tiff with LZW compression, and “-R” (for resized) added to the end of the name.
6. Preferably work in Photoshop CS 5
It would be even better if the process could be completely automated. I do not know if this is possible, but it would be really great if I did not have to input the dimensions of every leaf. Would it be possible for me to prepare a CSV file with the file name in the first column and the size that the leaf should be in the second, and have Photoshop do a batch action to resize all of the photos based on the information in that file? For that to work, Photoshop would have to be able to separate the leaf from the black background. Would that be possible? I would greatly appreciate any volunteers since our budget is tight. Thank you for your time.