• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
replacing embedded images in Illustrator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

replacing embedded images in Illustrator


  • Subject: replacing embedded images in Illustrator
  • From: Hamish Sanderson <email@hidden>
  • Date: Fri, 25 Jul 2008 10:23:59 +0100

Hi all,

Given an AI CS3 document containing an embedded bitmap, what's the easiest way to replace that item with another bitmap of equal size, given that its 'file path' property is read-only?

The following code seems to work okay as long as the original image is linked:

set theFile to alias "path:to:new.tiff"
set itemName to "foo"
set tempName to itemName & ".tmp"
tell document 1 of application "Adobe Illustrator"
set p to properties of page item itemName
make new placed item with properties {file path:theFile, name:tempName, position:position of p, matrix:matrix of p}
embed page item tempName
move page item tempName to after page item itemName
delete page item itemName
set name of page item tempName to itemName
end tell



However, when the original image is embedded, the replacement image ends up at a completely different location and orientation. So I compared the matrices for the original image before and after embedding it and found that they're different:


tell application "Adobe Illustrator" to get matrix of page item 1 of document 1

	-- before embedding
	--> {class:matrix,
		mvalue_a:0.095978476107,
		mvalue_b:0.095978476107,
		mvalue_c:0.172269061208,
		mvalue_d:-0.172269061208,
		mvalue_tx:1105.9033203125,
		mvalue_ty:2812.0498046875}

	-- after embedding
	--> {class:matrix,
		mvalue_a:0.095978476107,
		mvalue_b:-0.095978476107,
		mvalue_c:0.172269061208,
		mvalue_d:0.172269061208,
		mvalue_tx:383.4189453125,
		mvalue_ty:575.9853515625}


Is this a bug or a feature?

To cope with this, I adapted my original code to apply position and matrix values to the new image after embedding it:

set theFile to alias "path:to:new.tiff"
set itemName to "foo"
set tempName to itemName & ".tmp"
tell document 1 of application "Adobe Illustrator"
set p to properties of page item itemName
make new placed item with properties {file path:theFile, name:tempName}
embed page item tempName
transform page item tempName using matrix of p
set position of page item tempName to position of p
move page item tempName to after page item itemName
delete page item itemName
set name of page item tempName to itemName
end tell


This seems to work okay (as long as the original image is embedded, not linked, of course), although it's rather a lot of fuss for something that seems like it ought to be a simple one- or two-liner in the first place. Have I missed something? And what's with matrix values changing depending on whether an image is linked or embedded?

Thanks,

Hamish
--

Hamish Sanderson
Production Workflow Developer
Sun Branding Solutions Ltd
Tel: +44(0)1274 200 700
www.s-brandingsolutions.com




_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: replacing embedded images in Illustrator
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: QT mov vs mp4
  • Next by Date: Re: replacing embedded images in Illustrator
  • Previous by thread: changing content in scripted Mail reply: how?
  • Next by thread: Re: replacing embedded images in Illustrator
  • Index(es):
    • Date
    • Thread