-
All replies
-
Helpful answers
-
Jun 25, 2016 12:03 PM in response to alexanderPLby alexanderPL,here is script text, but it will not be work at yours mac because it use Imagine Photo application/
set thisFile to choose file with prompt "Choose an image file: "
tell application "iMagine Photo"
set thisImporter to import graphic thisFile
if the component error of thisImporter is not equal to 0 then
close thisImporter
display dialog "Not an image file that quicktime recognizes."
return
end if
set {x, y, xDim, yDim} to the natural bounds of thisImporter
set thisDocument to make new window document with properties {dimensions:{xDim, yDim}}
set the drawing destination of thisImporter to thisDocument
draw thisImporter
close thisImporter
-- The following section is to be replaced depending on the pixel value class
set pixelValueRect to {x, y, xDim, yDim}
set pixelValues1 to get pixel values of thisDocument with properties {pixel value class:pixels in rectangle, bounds rectangle:pixelValueRect}
close thisDocument
--class (pixel points) as list
--"class pCol" as list -- цвета и координаты разнесены по классам с именами, приводим к списку
end tell
tell application "TextEdit"
activate
make new document
set text of document 1 to pixelValues1 as list
-- set text of document 1 to pixelValues1 as list
-- save document 1 in "/Users/IMac/Desktop/LastUpdate.txt"
end tell
pixelValues1
-
Jun 25, 2016 12:45 PM in response to alexanderPLby Hiroto,★HelpfulHello
If I understand correctly, you're trying to coerce an AppleScript record to text. Unfortunately record-as-text coercion is not supported in AppleScript language. Fortunately there's been workaround to extract text representation of any AppleScript object from error string, which is ugly but works.
E.g.,
set x to {list:{0, 1, 2, 3}} --return x as string --> error -1700 return to_s(x) --> "{list:{0, 1, 2, 3}}" on to_s(a) (* a: anything return Unicode text: text representation of a *) local astid0 set astid0 to AppleScript's text item delimiters try {«class AAAA»:a}'s «class BBBB» on error t -- t = "Can't get «class BBBB» of {«class AAAA»:a}" try set AppleScript's text item delimiters to {"{«class AAAA»:"} set t to t's text items 2 thru -1 as Unicode text set AppleScript's text item delimiters to {"}"} set t to t's text items 1 thru -2 as Unicode text set AppleScript's text item delimiters to astid0 return t -- t = a, which is in Unicode text on error errs number errn set AppleScript's text item delimiters to astid0 error errs number errn end try end try end to_sFor your specific case, you may try something like this:
tell application "iMagine Photo" -- set pixelValues1 to ... set t to my to_s(pixelValues1) end tell tell application "TextEdit" tell (make new document) set its text to t end tell end tell on to_s(a) (* a: anything return Unicode text: text representation of a *) local astid0 set astid0 to AppleScript's text item delimiters try {«class AAAA»:a}'s «class BBBB» on error t -- t = "Can't get «class BBBB» of {«class AAAA»:a}" try set AppleScript's text item delimiters to {"{«class AAAA»:"} set t to t's text items 2 thru -1 as Unicode text set AppleScript's text item delimiters to {"}"} set t to t's text items 1 thru -2 as Unicode text set AppleScript's text item delimiters to astid0 return t -- t = a, which is in Unicode text on error errs number errn set AppleScript's text item delimiters to astid0 error errs number errn end try end try end to_sGood luck,
H
-
Jun 25, 2016 12:45 PM in response to Hirotoby alexanderPL,Thanks! It works!
Can texedit app do with this text additionally? e.q. write it in the some rules (five numbers in string, for example)


