Using Javascript & Actions to resize an image and add the filename as text

Hello,
I am currently working on a way to take an image, resize it and add exactly what is in it's file name (before extension) as a text layer. I have succeded in this BUT am having issues with file names that require more than one line of text.
I need the text to align to the bottom of the image & the script or action must then resize the image so that the text does not overlap.
Any ideas on how this can be done?
At the moment I am using:
-"Fit Image.jsx" to resize my image to a specific size (This was included in the Photoshop CS5 scripts)
- A script to add the file name without extension and place the file name at a specific position.
AdFileName.jsx
if ( documents.length > 0 )
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
try
  var docRef = activeDocument;
  // Now create a text layer at the front
  var myLayerRef = docRef.artLayers.add();
  myLayerRef.kind = LayerKind.TEXT;
  myLayerRef.name = "Filename";
  var myTextRef = myLayerRef.textItem;
  // strip the extension off
  var fileNameNoExtension = docRef.name;
  fileNameNoExtension = fileNameNoExtension.split( "." );
  if ( fileNameNoExtension.length > 1 ) {
   fileNameNoExtension.length--;
  fileNameNoExtension = fileNameNoExtension.join(".");
  myTextRef.contents = fileNameNoExtension;
  // off set the text to be in the middle
  myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
  myTextRef.size = 12;
        myTextRef.font="Arial-BoldMT"
        //set position of text
        myTextRef.justification = Justification.CENTER;
        myTextRef.kind = TextType.PARAGRAPHTEXT;
        myTextRef.width= docRef.width;
        myTextRef.height= docRef.height/ 2;
        myTextRef.position= [0, docRef.height * 0.88];
catch( e )
  // An error occurred. Restore ruler units, then propagate the error back
  // to the user
  preferences.rulerUnits = originalRulerUnits;
  throw e;
// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
else
alert( "You must have a document open to add the filename!" );
Can the position be changed to allow more rows of text but keep it aligned with the bottom of the layer?
How can I script in a way to make the image resize based on the amount of text lines?
Any help would be greatly appreciated.

You can add a text layer any where the only thing you need to worry about is the size of the font you use.  You can normally calculate a font size by saving the images resoltuion and then setting its resolution to 72 DPI calculate a font size basied of the images pixel width and the number of characters you want in a line. After adding the text layer you can restore the image to its original resolution and align the text layer by making a selection and alignint the text layer to the selection.  There are nine posibilites like the positions in the selection you can align to like a tick tack toe board. You need to use a script to add the text layer because your retrieving the filename.  The positioning of the text layer could be done easily in an action the would use the scriot to add a text layer the do a select all  the align the added text layer to the selection.
About your script don't make text paragraph just add new line characters to make a multi line text layer So it can be positioned easily
I do just that with my stampexif action.  The action uses my stampexif Photoshop java script to add a multi line text layer containing some formatted EXIF data then the action centers the text layer and add a layer style to it. Link http://www.mouseprints.net/old/dpr/StampExif.jsx Example

Similar Messages

  • I need your help with a decision to use iPhoto.  I have been a PC user since the mid 1980's and more recently have used ACDSee to manage my photo images and Photoshop to edit them.  I have used ProShow Gold to create slideshows.  I am comfortable with my

    I need your help with a decision to use iPhoto.  I have been a PC user since the mid 1980’s and more recently have used ACDSee to manage my photo images and Photoshop to edit them.  I have used ProShow Gold to create slideshows.  I am comfortable with my own folder and file naming conventions. I currently have over 23,000 images of which around 60% are scans going back 75 years.  Since I keep a copy of the originals, the storage requirements for over 46,000 images is huge.  180GB plus.
    I now have a Macbook Pro and will add an iMac when the new models arrive.  For my photos, I want to stay with Photoshop which also gives me the Bridge.  The only obvious reason to use iPhoto is to take advantage of Faces and the link to iMovie to make slideshows.  What am I missing and is using iPhoto worth the effort?
    If I choose to use iPhoto, I am not certain whether I need to load the originals and the edited versions. I suspect that just the latter is sufficient.  If I set PhotoShop as my external editor, I presume that iPhoto will keep track of all changes moving forward.  However, over 23,000 images in iPhoto makes me twitchy and they are appear hidden within iPhoto.  In the past, I have experienced syncing problems with, and database errors in, large databases.  If I break up the images into a number of projects, I loose the value of Faces reaching back over time.
    Some guidance and insight would be appreciated.  I have a number of Faces questions which I will save for later. 

    Bridge and Photoshop is a common file-based management system. (Not sure why you'd have used ACDSEE as well as Bridge.) In any event, it's on the way out. You won't be using it in 5 years time.
    Up to this the lack of processing power on your computer left no choice but to organise this way. But file based organisation is as sensible as organising a Shoe Warehouse based on the colour of the boxes. It's also ultimately data-destructive.
    Modern systems are Database driven. Files are managed, Images imported, virtual versions, lossless processing and unlimited editing are the way forward.
    For a Photographer Photoshop is overkill. It's an enormously powerful app, a staple of the Graphic Designers' trade. A Photographer uses maybe 15% to 20% of its capability.
    Apps like iPhoto, Lightroom, Aperture are the way forward - for photographers. There's the 20% of Photoshop that shooters actually use, coupled with management and lossless processing. Pop over to the Aperture or Lightroom forums (on the Adobe site) and one comment shows up over and over again... "Since I started using Aperture/ Lightroom I hardly ever use Photoshop any more..." and if there is a job that these apps can do, then the (much) cheaper Elements will do it.
    The change is not easy though, especially if you have a long-standing and well thought out filing system of your own. The first thing I would strongly advise is that you experiment before making any decisions. So I would create a Library, import 300 or 400 shots and play. You might as well do this in iPhoto to begin with - though if you’re a serious hobbyist or a Pro then you'll find yourself looking further afield pretty soon. iPhoto is good for the family snapper, taking shots at birthdays and sharing them with friends and family.
    Next: If you're going to successfully use these apps you need to make a leap: Your files are not your Photos.
    The illustration I use is as follows: In my iTunes Library I have a file called 'Let_it_Be_The_Beatles.mp3'. So what is that, exactly? It's not the song. The Beatles never wrote an mp3. They wrote a tune and lyrics. They recorded it and a copy of that recording is stored in the mp3 file. So the file is just a container for the recording. That container is designed in a specific way attuned to the characteristics and requirements of the data. Hence, mp3.
    Similarly, that Jpeg is not your photo, it's a container designed to hold that kind of data. iPhoto is all about the data and not about the container. So, regardless of where you choose to store the file, iPhoto will manage the photo, edit the photo, add metadata to the Photo but never touch the file. If you choose to export - unless you specifically choose to export the original - iPhoto will export the Photo into a new container - a new file containing the photo.
    When you process an image in iPhoto the file is never touched, instead your decisions are recorded in the database. When you view the image then the Master is presented with these decisions applied to it. That's why it's lossless. You can also have multiple versions and waste no disk space because they are all just listings in the database.
    These apps replace the Finder (File Browser) for managing your Photos. They become the Go-To app for anything to do with your photos. They replace Bridge too as they become a front-end for Photoshop.
    So, want to use a photo for something - Export it. Choose the format, size and quality you want and there it is. If you're emailing, uploading to websites then these apps have a "good enough for most things" version called the Preview - this will be missing some metadata.
    So it's a big change from a file-based to Photo-based management, from editing files to processing Photos and it's worth thinking it through before you decide.

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • Photoshop open multiple image and add different texts

    Hi All,
    Hope you are all doing great. I just started doing photoshop scripting due to the requirement which I will mention in detail below.
    My scripting is knowledge is very basic so I was hoping you guys could be able to help me out with this.
    The requirment is that I have 100's of images which needs to be opened in photoshop and add text based on the image name then save the image as JPEG at 70 quality. For example:
    I have images named as below in my desktop folder,
    Image1.jpg
    Image2.jpg
    Image3.jpg
    Image4.jpg
    Image5.jpg
    Image6.jpg
    Image7.jpg
    Image8.jpg
    Image9.jpg
    Image10.jpg
    For the script, I think the easiest way is that if I define what image name are:
    image[1] = Image1.jpg
    image[2] = Image2.jpg
    image[3] = Image3.jpg
    image[4] = Image4.jpg
    image[5] = Image5.jpg
    image[6] = Image6.jpg
    image[7] = Image7.jpg
    image[8] = Image8.jpg
    image[9] = Image9.jpg
    image[10] = Image10.jpg
    and for text I have done this:
    text [1] = Image1
    text [2] = Image2
    text [3] = Image3
    text [4] = Image4
    text [5] = Image5
    text [6] = Image6
    text [7] = Image7
    text [8] = Image8
    text [9] = Image9
    text [10] = Image10
    So everytime when I run the script image1 will be added to the photoshop and the text name Image1 will be added (For this I think defining layer name would be better so I will gave "Imagetext").
    Then the image will be saved on a specific location on my desktop.
    I have all this plan on what I want to do but I don't know how to write the script using photoshop API and my limited javascript coding.
    So if you guys could help me out with this, that would be awesome. Hope to hear on this soon.
    Kind Regards,
    Zoogle

    Hi Ghoulfool,
    Thank you very much for taking your time in looking into my question.
    Also thanks for the script you've provided. Your script works perfectly close to my requirements but there are few minor addon that I would like to request please.
    My apologies for not being very clear
    First of all to answer your questions:
    Image size varies but mostly between 1200-1000 pixels.
    Good question regarding text size, I would like to control the size of the text based on how long the character length is.
    Position varies so I would like to adjust it manually or if I could definie within the script that would be superb.
    The images open in new window rather that staying in the currently opend psd, I have other layers which I need to keep it as static and use the script to add the image between these layers.
    I wouldn't mind if all these 100's of images stay in current psd as layers.
    I was hoping if possible I would have more control over what text I would like to put on the image.
    Below is the example , I am sure the code below is wrong but with my limited scripting that's all I could come up with
    This is the code that would be controlling what text/text size appear on images based on the i value:
    var publicPath = 'C:/Users/Username/Desktop/imagesavetest';
    var outputPath = publicPath;
    var imagetext = new Array();
    imagetext[0] = "imagetext0";
    imagetext[1] = "Apple";
    imagetext[2] = "imagetext2";
    imagetext[3] = "Pineapple";
    imagetext[4] = "Orange";
    imagetext[5] = "imagetext5";
    imagetext[6] = "imagetext6";
    imagetext[7] = "Berries";
    for (var i in imagetext) {
      textLength = imagetext[i].length;
      saveMyFile = imagetext;
      theText.contents = imagetext[i].toUpperCase();
      switch (true) {
        case textLength <= 9:
          theText.font = "Arial";
          theText.size = 38;
          theText.contents = imagetext[i].toUpperCase();
          break;
        case textLength > 9 && textLength <= 12:
          theText.font = "Arial";
          theText.size = 28;
          theText.contents = imagetext[i].toUpperCase();
          break;
      saveAsJPEG(outputPath,  saveMyFile);
      counter++;
    And to open files from the user defined location:
    var inFolder = new Folder("C:/Input")
    var image = new Array();
    image[0] = "image0.jpg";
    image[1] = "image1.jpg";
    image[2] = "image2.jpg";
    image[3] = "image3.jpg";
    image[4] = "image4.jpg";
    image[5] = "image5.jpg";
    image[6] = "image6.jpg";
    image[7] = "image7.jpg";
    for (var j in image) {
    if j=0 look for i=0 and add i value as text
    To simplify i'll open psd with layers, add image between existing layers and add text based on the text name which we defined in script.
    Sorry for long post, but hope I have not made this simple process confusing.
    Please do let me know if you have any questions. Hope you hear from you soon and Thanks for your time.
    Kind Regards,
    Zoogle.

  • AS3 Load external image and add multiple instances to mcs

    Hi,
    Is there any way to load an external image and add it to more than one movie clip?
    Thanks,
    Chris McLaughlin

    Hi kglad,
    I was loading a larger jpeg to which I was applying 20 different masks so using the bitmapdata class to create duplicates was the best solution.
    It took me some time to wrap my head around it, but all is well.
    Thanks for pointing me in the right direction.
    Best regards,
    Chris

  • Photos in album are only a hash-marked outline the image only shows when scrolling how can I see the image and open the photo?

    Photos in iPhoto album are only a hash-marked outline the image only shows when scrolling how can I see the image and open the photo?

    Make a temporary, backup copy (if you don't already have a backup copy) of the library and apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Select the options identified in the screenshot. 
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • Downloads Low resolution images and not the high resolution as it did in 08

    'm using iPhoto '09 , unfortunately iPhoto only downloads the low res images and not the high resolution images. This makes it pretty much worthless, since the low resolution images are really bad in iPhoto. There was not any problems with Iphoto in the past Thank You

    What do you mean by "downloading"? There are a couple of ways to get image file out of iPhoto:
    1 - select the thumbnails and drag them to the desktop. This will give you copies of the latest version of each photo.
    2 - select the thumbnails, use the File->Export->File Export menu option. Depending on how you configure the export you will get the original, the latest version and/or a reduced size copy that you determine.
    3 - select thumbnails and use the Share->Send to DVD. This produces a mini library of the photos you've selected which include the original files, thumbnail files and any modified/edited file. This method is intended for use on computers that are running iPhoto.
    Which method are you using?

  • Need software which can send images to my editor, have them make selections, share them with me so I can edit the images and send the final results back to them.  Will Lightroom work?

    Need software which can send images to my editor, have them make selections, share them with me so I can edit the images and send the final results back to them.  Will Lightroom work?

    What I would like to do is to use Lightroom as I have been doing with LR 5.7.  Tag certain images to be shared to the Creative Cloud which my editor can then see and tag as to which she would like to see final versions of.  In the best case, I would then see these tags and edit the images as appropriate and save the JPEGs back to the Cloud where she can download them for final production.
    Possible?

  • My mac space was full, and i noticed that i had 10,000 images, so i deleted all of my images and emptied the trash, now i they don't appear on iphoto or anywhere, is there anyway i could get all of those images back so i can then store them in a device?

    my mac space was full, and i noticed that i had 10,000 images, so i deleted all of my images and emptied the trash, now i they don't appear on iphoto or anywhere, is there anyway i could get all of those images back so i can then store them in a device?

    yes, its the macbook air and mac OS X 10.7.4, not sure how that goes, about the time machine and time capsule, i only started using it today, when they were already deleted, also read at the support and help of iphoto, that if you delete your images from the picture folder that the images will be corrupted permanently, does this mean there there is no actual way of getting them back?
    Thanks for the help x

  • How to compare two images and display the difference on Front Panel

    HI..
    I have attached two images.
    I want to compare these two images and subtract the differenc from these two images and display the difference(the mouse) on the front panel
    Anyone can help me?
    Really thanks
    Attachments:
    IMG_2117.JPG ‏1677 KB
    IMG_2118.JPG ‏1650 KB

    The missing thing. You have to keep in mind that what you see is not the same as the camera sees.
    So when using IMAQ Substract it gives you the difference of the value of every single pixel!
    In order to find the mouse as only difference you have to manage that every other pixel value stays the same, e.g. with a proper lightening.
    At the other hand you can combine different filters or alogorithms to get the object, e.g. if the object is darker or brighter then everything else in the image you could use a threshold and then use morphologic operations to get the objects size and position.
    Christian

  • I mistake to using Iphone charger to recharge my Ipad and now the Ipad can't recharge thou.

    I mistake to using Iphone charger to recharge my Ipad and now the Ipad can't recharge by the original charger. How can I do?

    The quickest way (and really the only way) to charge your iPad is with the included 10W USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
    iPhone, iPod, Using the iPad Charger
    http://support.apple.com/kb/HT4327
    Install and use Battery Doctor HD
    http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
    In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
     Cheers, Tom

  • I am using ios 5 in my iphone 3g and all the apps that i have before is not working

    i am using ios 5 in my iphone 3g and all the apps that i have before is not working plz help !!!!!!!!!!!!!!!

    Hi
    Update the applications thru App Store

  • I had to change my user ID because I used my email at my old job and now the old one keeps popping up and I can't sync mu phone or authorize my computer at work to sync my phone. to syn

    I had to change my user ID because I used my email at my old job and now the old one keeps popping up and I can't sync my phone or authorize my computer at work to sync my phone. I have a new user ID and PW that allows me into ITUNES but that old one won't go away. Any help? Thanks

    Hi, you can't change which ID was used to purchase any app. However, you can edit your Apple ID, which may be a better option than using a new id.

  • When I download a movie from iTunes the cover art disappears. I try get info and add the art, it doesn't show up. So it's just gray. It opens and plays fine. Apple can't figure it out. It's an nas drive. When I use a firewire drive I get the art

    When I download movies from iTunes to my NAS drive, I don't get the cover art. It shows up while its downloading, but when it's finish it disappears. If it has an iTunes extra the cover art is there. I tried get info and add the cover art, it never shows. Regardless of how I add it. Funny thing is, if I download the same movie to my external firewire drive, no problem its there. I've called Apple with no success. I've even tried copying the movie with the art from the firewire drive to replace the file on then NAS drive I still loose the movie cover art. I also tried several times to re download it, no luck. Any ideas? I'm out of ideas.

    Do you have any videos/movies in the video app?
    In iTunes if you right click on the video and select Get Info and go to the Option tap what Media Type is shown?

  • How do I add the filename as an overlay on a PDF file compiled from images?

    I am creating pdf files from digital camera images and want to add the filename as a visible overlay (ie either in Header/Footer or as a watermark).  I can find all other alternatives eg Bates numbering, customised Header/Footer etc), but cannot find a solution to adding each image's filename to the image.  I can do it in Bridge but not Acrobat.

    Acrobat does not preserve the original filename information of images.
    You should it in another application (Photoshop?) and then import the final
    image into Acrobat.

Maybe you are looking for

  • Selecting one cursor at a time and then reading its value

    I am a novice LabView user. I am trying to develop a program in which I have to select portions of a waveform and delete the outliers.  The problems I run into is selecting cursors at a time and then reading its value. I was using Active Cursor. Idea

  • Fresh Windows 7 install on Satellite C75D-B7200

    Hey Toshiba Forums,  My laptop, the C75D-B7200 recently had some HDD hardware problems so I got a new one and decided to put windows 7 64 bit on it.  After the installation process was finished and I logged in, I couldn't connect to the internet.  Th

  • I would like to display current fiscal year always on variable screen

    Hi I have requirement in which I would like to display the current fiscal year on variable screen in BI Report. we have a standard variable however the sap exit to display the current fiscal year is not shown... Can any one tell me, how to proceed in

  • Iphoto transfer from mac to iphone

    How do I transfer photo folders (that I'd like to select, not all) from iphoto 9.6 on my macbook pro (OS X yosemite 10.10.1) to my iphone 5c (iOS8.1.2)

  • Lightroom 4 Beta Download problem.

    I cannot download LR 4 Beta.  I'm using windows 7 and 64 bit processing.  WIndow comes up asking me to click save or open.  I click on open and nothig happens.  HAs anyone else had this problem.  I'm currenty using LR3.6 with no problems.