🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8708

Re: images in folder to select graphic boxes

#8708
From: Shane_Stanley
Date: Tue, 26 Sep 2006 23:44
80 lines
3752 bytes
Now there's a blast from the past -- one of Sal's originals.

Here's a quick port:

tell application "Adobe InDesign CS2"
    -- get list of frames
    try
        set theFrames to every item of selection whose class is in
{rectangle, oval, polygon}
    on error
        display dialog "No frames selected." buttons {"OK"} default button 1
        error number -128
    end try
    
    -- offer to reverse order
    if length of theFrames > 1 then
        set importOrder to button returned of (display dialog "Do you want
the images to begin importing into the topmost or bottommost picture frame?"
buttons {"Cancel", "Topmost", "Bottommost"} default button 3)
        if importOrder is "Bottommost" then
            set foundPictBoxes to my reverseList(theFrames)
        end if
    end if
    
    -- get fitting required
    set fitOptions to {"Leave 100%", "Fit to Frame", "Fit to Frame
(Proportionally)", "Fit Frame to Picture", "Fill Frame Proportionally"}
    set fitEnums to {nothing, content to frame, proportionally, frame to
content, fill proportionally}
    set autoFitImages to (choose from list fitOptions with prompt "How
should the images be scaled?" default items {"Fit to Frame
(Proportionally)"})
    if autoFitImages is false then
        beep
        error number -128
    end if
    set autoFitImages to item 1 of autoFitImages
    repeat with i from 1 to count of items of fitOptions
        if autoFitImages = item i of fitOptions then
            set autoFitImages to item i of fitEnums
            exit repeat
        end if
    end repeat
    
    -- pick folder
    set theFolder to choose folder with prompt "Pick a folder from which to
auto-import the images."
    tell application "Finder"
        -- This section will make a list of the images that are in the
specified folder 
        set theImageList to (every file of theFolder whose kind is not
"alias" and �
            file type is "TIFF" or file type is "EPSF" or file type is
"PICT" or �
            file type is "JPEG" or file type is "GIFf" or file type is "BMP
" or �
            file type is "RIFF" or file type is "BINA" or file type is
"PNTG" or �
            file type is "BMPf") as alias list
    end tell
    
    -- place 'em
    set imageCount to count of theImageList
    repeat with i from 1 to count of theFrames
        if i > imageCount then exit repeat
        set placedImage to (place item i of theImageList on item i of
theFrames)
        if autoFitImages is not nothing then
            fit placedImage given autoFitImages
        end if
    end repeat
    display dialog "Finished." buttons {"OK"} default button 1
end tell

on reverseList(theFrames)
    return reverse of theFrames
end reverseList

-- 
Shane Stanley <sstanley@myriad-com.com.au>
Technical Details
Message-ID: <C13FF86A.305BF%sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossing
References: <3bc1c6c5.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,7abff512d9180145
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII
From: Shane_Stanley@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeed.freenet.de!news.albasani.net!news.isoc.lu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: images in folder to select graphic boxes
Message-ID: <C13FF86A.305BF%sstanley@myriad-com.com.au>
Date: Tue, 26 Sep 2006 16:44:10 -0700
References: <3bc1c6c5.-1@webcrossing.la2eafNXanI>
Lines: 88
Return-Path: <sstanley@myriad-com.com.au>
User-Agent: Microsoft-Entourage/11.2.5.060620
Thread-Topic: images in folder to select graphic boxes
Thread-Index: AcbhxanJ6HEivk24Eduy3AARJHm3nA==
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit