Applescript Open PDF save as JPG

I can do a batch process in Photoshop pretty easily, but I need it be a little more robust.
I want to grab a folder full of PDFs then open each PDF in Photoshop. Then check to the width and height of the document. If the file is wider than it is tall it runs one Photoshop action. If it is taller than it is wide, it runs another action.
Thoughts on how to accomplish this?
-Kirk

Kirk, have a very brief look at fit image. I must say I've never used this feature before and Im a long time user of PS. I've coded what I think it does you will have to test and see for yourself. I have also moved a few things about as they did not need to be part of the repeat loop in PS. Also included convert to RGB color space as files are to be for web. Can you also check PS's pref's file handling set append file extension to always and lower case if it is not already.
property fitImage : 1280 / 854 -- Your fit image scale.
set tempFolderName to "Converted to RGB JPEG"
set inputFolder to choose folder
tell application "Finder"
set filesList to (files of inputFolder whose file type is "PDF " or name extension is "pdf")
if (not (exists folder ((inputFolder as string) & tempFolderName))) then
set outputFolder to make new folder at inputFolder with properties {name:tempFolderName}
else
set outputFolder to folder ((inputFolder as string) & tempFolderName)
end if
end tell
tell application "Adobe Photoshop CS" -- Moved out of repeat loop only need to do this once.
set UserPrefs to properties of settings -- Record user settings
set ruler units of settings to pixel units -- Easier to use for web stuff
set background color to {class:RGB color, red:255, green:255, blue:255}
end tell
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
activate
set display dialogs to never
open theFile as PDF with options {class:PDF open options, mode:CMYK, resolution:300, use antialias:true, constrain proportions:true}
set docRef to the current document
tell docRef
if (mode of docRef is not RGB) then
change mode docRef to RGB
end if
set docHeight to height of docRef
set docWidth to width of docRef
flatten
if (docHeight > docWidth) then -- This is what I think fit image does.
set imagePro to (docHeight / docWidth)
if imagePro < fitImage then
resize image width 854 resolution 72
else
resize image height 1280 resolution 72
end if
end if
if (docWidth > docHeight) then
set imagePro to (docWidth / docHeight)
if imagePro < fitImage then
resize image height 854 resolution 72
else
resize image width 1280 resolution 72
end if
end if
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (outputFolder as string) & docBaseName
end tell
save docRef in file newFileName as JPEG with options ¬
{class:JPEG save options, embed color profile:true, format options:optimized, matte:background color matte, quality:9} ¬
appending lowercase extension with copying
close current document without saving
end tell
end repeat
tell application "Adobe Photoshop CS" -- Reset changed user settings after repeat loop.
set ruler units of settings to ruler units of UserPrefs
end tell
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName
--

Similar Messages

  • Pdf save as jpg and png looks pixelated like it doesn't anti-alias text

    This has been an issue for a while and I can't figure out how to resolve it.  When i open a pdf in acrobat 11.0.0 and click file/save as other/ i can't get the text to anti-alias, it always looks jagged no matter what settings i adjust.
    I can bring the pdf into photoshop or illustrator and can export there but with multiple pages it is a bit absurd.  any ideas?

    thanks bill,
    I'll try to do the updates, it is rather difficult to do when the creative cloud software thinks you are up to date.
    I've tried everything from determine automatically and 72-600 dpi, adjusting the interlace and filter options. It happens regardless of the font - here are 2 more examples on a file created in illustrator, saved off as pdf and then jpg using default settings and png using default settings

  • All open PDFs save to RTF

    Wondering if anyone knows a javascript I could run to save all open PDFs as RTF with images.
    File>Save As> RTF (settings include images)
    Save to same folder
    Thanks

    Yes, there is the output option, I was looking for the first command sequence.
    Basically, I just set it up to a basic task that doesn't affect the file.
    Select the folder
    And the output options give me the result
    Thanks

  • AppleScript open and save file with Numbers

    Hi all,
    I need to save an Excel .xls file as an .xls file in order to break the links that are included in the original Excel file. Since Numbers doesn't have any actions for Automator, I hoped someone could help me writing an AppleScript?
    It needs to open (Numbers) and all the .xls files that are added to a specific folder on my Mac, then save them to another folder as .xls (not .xlsx) and overwrite any existing files with same name. Since this all should work automatically, warnings and pop-ups that need a user to click an option are not allowed.
    Didn't think this could be too hard, but I'm just a noob when it comes to AppleScript. Help?
    Thanks in advance

    Check the attributes of the <textarea> tag. You can use wrap="no" or wrap="virtual" or wrap="hard" to define how the text area handles carriage returns.
    Brian

  • How do I open and save a jpg attachment from mail?

    I received an email that has a jpg photo. This photo is an attachment. In my Inmail there is a paper clip next to the name of the person who sent the email. I want to be able to copy the jpg photo and put it someplace else. Is there any way this can be done? I am new to all of this.

    Try holding down the jpeg picture for a second or two, an option to copy or save should appear.

  • Can I save an open PDF file as a .jpg using Acrobat Reader?

    Is there some kind of ad-on or other (third party?) program which would allow Acrobat reader to save or convert a PDF to a JPG?  I have the full version, along with Adobe Creative Suite, so I know I can do it with those programs.  This is for a friend with whom I share files and he only had the Acrobat Reader.
    Thanks

    No, Adobe Reader can only save as a text file, or using ExportPDF as Word or Excel documents.
    However, use Google to find many free PDF conversion tools on the Internet.

  • Open a TIF file then save in JPG

    Started to use PhotoShop CS4.
    I use Canon DPP for preprocess then bridge to PhotoShop in TIF format.  I occasionaly want to
    save in JPG format rather than TIF to give the file to my friend.  However, there is no option to
    save in JPG in "File/Save in other name/" function.
    Could a guru help me how to do this.
    If a file was in jpg when opened, it can be saved in jpg, though.

    Thanks, but,,,,
    There is the SaveAs function.  (I wrote "Save in other name" which is a
    translation in Japanese version PS)
    However, there is no JPG format listed.  All available are:
      PhotoShop
      Cineon
      Dicom
      FXG
      IFF
      PhotoShop PDF
      PNG
      Portable Bit Map
      TIFF
      PSG
      RAW
    No JPG there.
    Tak

  • Illustrator applescript open multi-page PDF error

    Hi all, I am trying to create a script to find and replace objects in a multi-page pdf in Illustrator.  Everything else works except for open and save, which I still have to do manually.  I tried to open the file using the following
    open myFile as PDF with options {class:PDF open options, page:4}
    But Applescript returns the error "Expected class name but found application constant or consideration." 

    Checkout this discussion
    http://forums.adobe.com/thread/499840?tstart=0
    esp the last from Mario Arizmendi

  • Save As Dialog Not Showing when opening pdf from Outlook 2010

    Hi
    I have recently had to change the default documents folder on a windows 7 machine (Right Click Documents, properties,  include folder, set save location). Since this change, when opening an attached pdf document in outlook 2010 and viewing with adobe reader, if i click Save as from the file menu, no os dialog appears and therefore user cannot choose a place to save the document.
    As a work around the user can right click the attachment save the docment to a location, once opened, ther save as dialog is usable.
    I have uninstalled and re-installed reader to the laterst version, but with no luck.
    Any ideas?
    Jason Congerton

    This looks like a new behavior of Outlook 2010 and isn't specific to PDFs. You will need to "save as" the document. There is a thread at Microsoft forums about this with some possible workarounds:
    http://social.technet.microsoft.com/Forums/en-US/outlook/thread/927d678d-b55b-4732-93cb-f1 3ed1dacf96/

  • HT4059 When I have a PDF that I want to open and save into iBooks - it will attempt to open it and the shelf flips around to make room for it. But it doesn't save it. I have to end up opening it in Adobe or Kindle app to view & save it.

    When I have a PDF that I want to open and save into iBooks - it will attempt to open it and the shelf flips around to make room for it. But it doesn't save it. I have to end up opening it in Adobe or Kindle app to view &amp; save it. This has been doing this awhile, what's wrong. Should
    I take it and have it looked at?

    is there any important stuff saved to your emails? if so you could log on to your emails from a seperate device and back them up. im not sure what else you could do :/

  • I am running Vista and Windows Mail, I can not open PDF files when in Windows Mail, I must save to Desktop first, this has changes recently and I do not know why or how to fix

    I am running Vista and Windows Mail, I can not open PDF files when in Windows Mail, I must save to Desktop first, this has changes recently and I do not know why or how to fix.
    Why after 6 year's this has changed?
    I would like to open PDF's straight from Window Mail.

    Good day Jeff.
    I am running most current Adobe Reader X.
    Tks Mark

  • Script to open eps and save to jpg

    Hi,
    I would need a script to open an eps or ai file at 100dpi, rgb, with the longest side of 500 px.
    It would save the jpg at amximum quality with the same name  +  .jpg
    then close the eps file without saving it.
    I wanted tyo create an action for this but I cant figure how to create the jpg file with it's longest side to 500 pixels.
    Jean

    When you record your action use Fit Image to resize the document. Enter 500 in both width and height, that way the longest side will be 500. Fit Image will keep the image ratio.

  • Clicking a .pdf link does not open .pdf file, it opens a SAVE DIALOG box

    Recently when I click on a .pdf file link I am no longer able to open the file in a adobe reader either within a FIREFOX webpage or open it using the full adobe program. Instead it opens a SAVE dialog box requesting me to save to my harddrive. I am not sure what has happened and am trying to find someone who might know what is going on?

    You can change the action for Portable Document Format (PDF) from Preview in Firefox to use the Adobe Reader or set to Always Ask in "Firefox > Options/Preferences > Applications".
    You can set the pdfjs.disabled pref to true on the <b>about:config</b> page to disable the build-in PDF viewer.
    You can check the value of the plugin.disable_full_page_plugin_for_types pref on the about:config page and remove the application/pdf part if present or reset the pref to the default via the right-click context menu.
    *http://kb.mozillazine.org/about:config
    See also:
    *https://support.mozilla.org/kb/view-pdf-files-firefox-without-downloading-them

  • I have just upgraded to OSX 10.6.8 and now I cannot open or save PDF files from the internet. I get a dialogue box saying the QuickTime plugin has failed. I have tried to download the latest plugin but this doesn't work. Can anyone help?

    I have just upgraded to OSX 10.6.8 and now I cannot open or save PDF files from the internet using either Safari or Firefox. I get a dialogue box saying the QuickTime plugin has failed. Can anyone help?

    Is this what you downloaded: iTunes 10.7?
    When the update fails what if any error report do you get, specifically? Please do this before trying again:
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.

  • I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after saving as from word 2007 - I uninstalled Pro X1 and now when I save as from word 2007 to PDF it will

    Can anyone help with this - do I have to uninstall Reader and then reinstall?

    I have had a trial version of Acrobat X1 Pro - I have decided not to buy at this stage - for some time it has been conflicting with opening PDF docs after "saving as" from word 2007 - I uninstalled Pro X1 and now when I "save as" PDF from word 2007 to PDF it will save the document as a PDF but will not open the document to display after publishing - I have to got to where the file has been saved to view the new PDF document - this is really annoying - do I have to delete adobe reader and reinstall it - adobe needs to look at this conflict with acrobat pro as I have even gone it to properties and tried to have adobe reader as the default PDF program - the main issue is that I cannot view the PDF after publishing it from word 2007

Maybe you are looking for

  • Returning a single custom instance.

    Hi, I am loading data into a jdo class using CustomResultSetResultObjectProvider. All is working well. I am in fact using a CachedRowSet (optional download from the sun website). I wish to load records 20 to 30 from the resultset into a collection of

  • [SOLVED] citrix-client wfica fails

    Hi, I have installed the latest citrix-client from AUR and followed the instructions for copying in the .ini files, and have updated my Arch system today.  I am running on x86.  When I try and run a Citrix app in Firefox, nothing happens.  If I run F

  • Using Assert id

    Hi  ABAP guru's, In this scenario, data: w_c1(3) type c,       w_c2 type i,       zemp1 like table of zemp. field-symbols <fs> type zemp. select * from zemp into table zemp1. read table zemp1 with key empno = '1' assigning <fs>. assert id AAB_DEMO co

  • Where the the latest stable 64 bit Linux firefox (I do not want 32 bit)

    No windows related responses please

  • Probleme d'impression avec Adobe illustrator

    Bonjour, Je rencontre actuellement des problemes lorsque je veux imprimer sous Adobe Illustrator CS5 , lorque je lance l'impression rien ne se passe. Ce probleme arrive que sur Illustrator avec d'autres logiciels ( excel, notepad,word....) tout se pa