Actually, that'll work even if you did change the proportions, but the image will no longer be proportionaly scaled. In that case, you can use Fit Content Proportionally followed by Fit Frame to Content (perhaps with Center Content interspersed) to get as close as possible to where you want to be.
Dave
Dave
Dave
Next: remember to not scale a pictureframe by percentages but by adjusting height/width and or adjusting with your mousepointer. Keep the percentages of the pictureframe 100%.
tell application "InDesign 2.0.2"
try
set myFrame to item 1 of selection
set theProps to properties of myFrame
set thePercent to vertical scale of myFrame
set theRadius to the corner radius of myFrame
set theStroke to the stroke weight of myFrame
if image 1 of myFrame exists then
set myPic to image 1 of myFrame
set myVScale to absolute vertical scale of myPic
set myHScale to absolute horizontal scale of myPic
set picBounds to geometric bounds of myPic
end if
set theProps to {absolute vertical scale:nothing, vertical scale:100, absolute horizontal scale:nothing, horizontal scale:100} & theProps
set properties of myFrame to theProps
set the stroke weight of myFrame to thePercent * theStroke / 100
set the corner radius of myFrame to thePercent * theRadius / 100
if image 1 of myFrame exists then
set the absolute vertical scale of myPic to thePercent * myVScale / 100
set the absolute horizontal scale of myPic to thePercent * myHScale / 100
set the geometric bounds of myPic to picBounds
end if
on error
display dialog " Select the picture frame and try again"
end try
end tell
If you're interested, I also have a script which opens the picture into Photoshop and resizes, rotates, resamples to 300ppi, and positions the picture.
Rob
Hope this helps.
Rob... I'm interested.
Would you post that please?
TIA
tell application "InDesign 2.0.2"
set myDoc to active document
tell myDoc
tell view preferences
set myOrigHorMeasurementUnits to get horizontal measurement units
set myOrigVerMeasurementUnits to get vertical measurement units
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
end tell
try
set mySelection to item 1 of selection
set myClass to class of mySelection
if myClass is image then
set myLink to item link of mySelection
else
set myLink to item link of image 1 of mySelection
end if
on error
display dialog "Please select a picture before running this script."
return
end try
set myFileName to file path of myLink
--the picture box could be parent of myLink
set myFrame to parent of parent of myLink
set myPic to parent of myLink
--gets the pictures scale
set myVScale to absolute vertical scale of myPic
set myHScale to absolute horizontal scale of myPic
--gets the pictures rotation
set myRotation to absolute rotation angle of myPic
--gets the bounding box of both the picture and the picture box
set boxBounds to geometric bounds of myFrame
set picBounds to geometric bounds of myPic
--gets the dimension for the PS file
set boxRight to item 4 of boxBounds
set boxleft to item 2 of boxBounds
set boxTop to item 1 of boxBounds
set boxBottom to item 3 of boxBounds
set boxHeight to boxBottom - boxTop
set boxWidth to boxRight - boxleft
--for the picture offset relative to the frame
--picture center of bounds
set picX1 to item 2 of picBounds
set picY1 to item 1 of picBounds
set picX2 to item 4 of picBounds
set picY2 to item 3 of picBounds
set picXCenter to picX1 + ((picX2 - picX1) / 2)
set picYCenter to picY1 + ((picY2 - picY1) / 2)
--frame center of bounds
set boxX1 to item 2 of boxBounds
set boxY1 to item 1 of boxBounds
set boxX2 to item 4 of boxBounds
set boxY2 to item 3 of boxBounds
set boxXCenter to boxX1 + ((boxX2 - boxX1) / 2)
set boxYCenter to boxY1 + ((boxY2 - boxY1) / 2)
--offset of picture to frame
set hOff to picXCenter - boxXCenter
set vOff to picYCenter - boxYCenter
tell application "Adobe Photoshop 7.0"
activate
try
open myFileName
on error
display dialog " Update Indesign Links"
return
end try
--apply gathered variables to images here
tell current document
resize image width percent myHScale resample method none
resize image resolution 300 resample method bicubic
select all
copy
paste
set name of layer "Layer 1" to "Photo"
delete layer "Background"
resize canvas width boxWidth height boxHeight
rotate layer "Photo" angle -myRotation
end tell
tell layer "Photo" of current document
translate delta x hOff
translate delta y vOff
end tell
--tell current document
--flatten
--end tell
end tell
end tell
set myRulers to ruler units of settings
set myRulers to inch units
after
Tell application "Adobe Photoshop 7.0"
activate
Rob
I have a large job that I'll try that on soon. (A duplicate of the project, of course, until I'm sure I know what I'm doing with it.)
Scripts that work are sure time savers.
I haven't come around to the Transform tool applying the scale to the frame so you have a scenario where the box could be 123.04% and the picture could be 43.2% and only a gifted mathematician has clue what the real scale of the image is.
Nice site.
Is the photo link active?
When you select a picture frame, you are selecting the primary item (object) when it is empty so if you paste it will paste the content of the clipboard on the page.
We n eed to keep in mind that QXP and InDesign are two complete different horses, and because of their individuality we can not treat, ride, or expect them to behave the same way. Once we treat them as what they are, different applications, we will be able to enjoy the ride without getting frustated and what one or the other can or cnanot do.
I just tried running the script in Script Editor. With the added two lines (re inches), I get the error, 'expected end of line, etc. but found identifier'. I took them back out, ran the script and got the error message, 'expected end of line, etc. but found class name' a few lines below, on the word document.
Any ideas for what I need to do?
set myRulers to ruler units of settings
set myRulers to inch units
doesn't work (I never tried it) it should be:
set ruler units of settings to inch units
Applescript is very fussy about how lines break, so sometimes when you cut and paste from your browser and don't know what to look for the script won't compile correctly. I cut the script from my second post and got it to compile—so the post is OK. Here's the script again with the inch setting—if you still have trouble I can e-mail you a compiled script:
tell application "InDesign 2.0.2"
set myDoc to active document
tell myDoc
tell view preferences
set myOrigHorMeasurementUnits to get horizontal measurement units
set myOrigVerMeasurementUnits to get vertical measurement units
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
end tell
try
set mySelection to item 1 of selection
set myClass to class of mySelection
if myClass is image then
set myLink to item link of mySelection
else
set myLink to item link of image 1 of mySelection
end if
on error
display dialog "Please select a picture before running this script."
return
end try
set myFileName to file path of myLink
set myFrame to parent of parent of myLink
set myPic to parent of myLink
set myVScale to absolute vertical scale of myPic
set myHScale to absolute horizontal scale of myPic
set myRotation to absolute rotation angle of myPic
set boxBounds to geometric bounds of myFrame
set picBounds to geometric bounds of myPic
set boxRight to item 4 of boxBounds
set boxleft to item 2 of boxBounds
set boxTop to item 1 of boxBounds
set boxBottom to item 3 of boxBounds
set boxHeight to boxBottom - boxTop
set boxWidth to boxRight - boxleft
set picX1 to item 2 of picBounds
set picY1 to item 1 of picBounds
set picX2 to item 4 of picBounds
set picY2 to item 3 of picBounds
set picXCenter to picX1 + ((picX2 - picX1) / 2)
set picYCenter to picY1 + ((picY2 - picY1) / 2)
set boxX1 to item 2 of boxBounds
set boxY1 to item 1 of boxBounds
set boxX2 to item 4 of boxBounds
set boxY2 to item 3 of boxBounds
set boxXCenter to boxX1 + ((boxX2 - boxX1) / 2)
set boxYCenter to boxY1 + ((boxY2 - boxY1) / 2)
set hOff to picXCenter - boxXCenter
set vOff to picYCenter - boxYCenter
tell application "Adobe Photoshop 7.0"
activate
set ruler units of settings to inch units
try
open myFileName
on error
display dialog " Update Indesign Links"
return
end try
tell current document
<http://www.adobe.com/support/downloads/product.jsp?product=39&platform=Macintosh>
Photoshop is not scriptable without it. If I pull the plugin the script fails on the first Photoshop command.
Also, I'm running OSX10.2.6
Still no luck. You were right, I didn't have the Photoshop Scripting Plugin installed. I installed it, restarted Photoshop, but the script now tells me that an identifier can't go after this identifier ('ruler units' highlighted). I don't think the problem is line breaks, but I'm no scripting expert, like you. I'd love a to try a compiled copy if you don't mind sending me one. I activated my email listing in forum preferences.
tell application "Adobe Photoshop 7.0"
activate
set ruler units of settings to inch units
end tell
When you paste text try clicking the Check Syntax button to compile before you click Run.
Also it probably will not work if the placed file is a layered PS file. I haven't made any attempt to debug this...