REVO2700Image Drag and drop2 Q&/* Image Drag and Drop Stack By Eric Chatonet 2/20/05 http://www.sosmartsoftware.com/ */ on preOpenStack if the short name of me <> the short name of this stack then exit preOpenStack set the style of this stack to "modeless" set the loc of this stack to the screenLoc end preOpenStack CX+#005 How to drag and drop and store images ULucida Grande ULucida Grande WLucida Grande ULucida Grande cREVGeneral debugObjects breakpointsbreakpointstatesbreakpointconditionsstackfileversion2.7 P ]on dragEnter if "image" is in the target then set the acceptDrop to true -- then dragdrop message will be sent to any image end dragEnter ------------------------------- on dragDrop -- send to an image when the user drags and drop a file onto it local tFilePath ----- -- is the dragged and dropped file a valid image file? put the dragData into tFilePath switch GetExtension(tFilePath) -- see this function that returns the file extension extracted from the file path below case "error: could not find extension" -- may happen with MacOS switch the platform case "MacOS" -- the file has no extension: we try to get its file type (MacOS only) if FileInfo(tFilePath,"type") is not among the items of "JPEG,GIFf,PNGf,PICT,BMP " then AnswerErr tFilePath -- see this function below else ImportImage tFilePath,the hilitedButton of grp "Method" -- -- the hilitedButton of grp "Method" specifies here the method: see ImportImage handler below break ----- default AnswerErr tFilePath -- end switch break ----- case "JPG" case "png" case "gif" case "bmp" -- main image types supported for display into Revolution images -- more types can be used with players ImportImage tFilePath,the hilitedButton of grp "Method" -- break ----- default AnswerErr tFilePath -- end switch end dragDrop --------------------------------- on ImportImage pFilePath,pMethod constant kMaxDim = 200 -- max width or max height of any imported image in pixels (value for our demo) local tCurImg,tWidth,tHeight,tRect,tImageData,tImageFolder,tNewFilePath,tOriginalSize,tTempFilePath,tNewSize ----- set the cursor to watch put the long ID of the target into tCurImg -- always better to work with a complete reference ----- -- initialization: lock screen set the text of tCurImg to empty set the height of tCurImg to kMaxDim set the width of tCurImg to kMaxDim ----- set the filename of tCurImg to pFilePath ----- -- sets the right dimensions, proportions and the loc of the image put the formattedWidth of tCurImg into tWidth put the formattedHeight of tCurImg into tHeight if tWidth > tHeight then set the height of tCurImg to round(tHeight * (kMaxDim/tWidth)) else set the width of tCurImg to round(tWidth * (kMaxDim/tHeight)) set the loc of tCurImg to the loc of the owner of tCurImg -- centers image into its own group unlock screen -- in fact, these first lines are method 1 ----- switch pMethod case 1 -- links to the original file -- the job is already done! -- following code is for demo purpose only: put FileInfo(pFilePath,"size") into tOriginalSize -- answer info "

Method 1

" & cr & "

" & cr & "

Image is only linked to the original file:" & cr \ & "

The size of the stack does not change.

" & cr & "

File size:" && tOriginalSize &"

" as sheet break ----- case 2 -- stores optimized image into current stack -- method 2 adds the following procedure to method 1: set the JPEGQuality to the thumbpos of scrollbar "CompBar" -- jpeg quality (between 1 and 100 : 50/60 is a good average) put GlobalObjRect(the rect of tCurImg) into tRect -- see this function below ----- export snapshot from rect tRect to tImageData as JPEG -- exports the image data to a variable set the text of tCurImg to tImageData -- sets image data ----- -- following code is for demo purpose only: put FileInfo(pFilePath,"size") into tOriginalSize -- put the defaultFolder & slash & "tempFile" into tTempFilePath put tImageData into url("binfile:" & tTempFilePath) put FileInfo(tTempFilePath,"size") into tNewSize -- delete file tTempFilePath answer info "

Method 2

" & cr & "

" & cr & "

Image is stored into the stack.

" & cr \ & "

Original image:" && tOriginalSize & ".

" & cr & "

Optimized stored image:" && tNewSize & ".

" as sheet break ----- case 3 -- links to an optimized file created on the fly -- method 3 adds the following procedure to method 1: set the JPEGQuality to the thumbpos of scrollbar "CompBar" -- jpeg quality between 1 and 100 put GlobalObjRect(the rect of tCurImg) into tRect -- see this function below ----- creates an image folder if needed put the defaultFolder & slash & "Images Test" into tImageFolder if there is no folder tImageFolder then create folder tImageFolder set the itemDel to slash put tImageFolder & slash & StripExtension(last item of pFilePath) & ".jpg" into tNewFilePath ----- export snapshot from rect tRect to url("binfile:" & tNewFilePath) as JPEG -- exports the image data to a file set the filename of tCurImg to tNewFilePath -- links the image to the new file ----- -- following code is for demo purpose only: put FileInfo(pFilePath,"size") into tOriginalSize -- put FileInfo(tNewFilePath,"size") into tNewSize -- answer info "

Method 3

" & cr & "

" & cr & "

Image is linked to" && tNewFilePath & ".

" & cr \ & "

Original image:" && tOriginalSize & ".

" & cr & "

Optimized exported image:" && tNewSize & ".

" as sheet end switch ----- end ImportImage ####################################### -- complementary handlers and functions ####################################### on AnswerErr pFilePath answer error pFilePath && "does not appear to be a valid image." with "Sorry" exit to top end AnswerErr --------------------------------- function GlobalObjRect pRect -- this function converts a local rect to a global rect and returns the result return item 1 of pRect + the left of this stack,item 2 of pRect + the top of this stack,item 3 of pRect + the left of this stack,item 4 of pRect + the top of this stack end GlobalObjRect --------------------------------- function GetExtension pFilePath -- this function returns the extension of a file (its path is passed as a parameter) local tFileName ----- set the itemDel to slash put item -1 of pFilePath into tFileName if "." is not in tFileName then return "error: could not find extension" repeat with i = the number of chars of tFileName down to 1 if char i of tFileName = "." then exit repeat end repeat return char (i+1) to (the number of chars of tFileName) of tFileName end GetExtension --------------------------------- function StripExtension pFileName -- this function returns the filename without any extension if "." is not in pFileName then return pFileName repeat with i = the number of chars of pFileName down to 1 if char i of pFileName = "." then exit repeat end repeat return char 1 to (i-1) of pFileName end StripExtension ############################################ -- code below is used for demo purposes only ############################################ function FileInfo pFilePath,pInfo -- this function returns any file size, file creation date, file modification date, file creator or file type whose path is passed as a parameter -- according to a complete file path and the value of pInfo parameter local tDefaultFolder,tFiles,tFilter,tSize,tDate ----- put the defaultFolder into tDefaultFolder set the itemDel to slash set the defaultFolder to item 1 to -2 of pFilePath put urldecode(the long files) into tFiles put last item of pFilePath & "*" into tFilter filter tFiles with tFilter set the defaultFolder to tDefaultFolder ----- set the itemDel to comma switch pInfo case "size" put item 2 of tFiles + item 3 of tFiles into tSize put tSize div 1024 into tSize if tSize > 1000 then set the numberFormat to "0.0" put tSize / 1024 && "Mb" into tSize else put tSize && "Kb" into tSize return tSize break case "creation" put item 4 of tFiles into tDate convert tDate from seconds to system date and system time return tDate break case "modification" put item 5 of tFiles into tDate convert tDate from seconds to system date and system time return tDate break case "type" return char -4 to -1 of tFiles break case "creator" return char -8 to -5 of tFiles end switch end FileInfo X cREVGeneral breakPointsscripteditorvscroll714scripteditorselection1688_`d@_Tabs}oon menuPick pNewTab,pOldTab lock screen hide grp pOldTab show grp pNewTab unlock screen end menuPick  h:Action Discussion cREVGeneral revUniqueID 1108897407452 `Action iV. cREVGeneral revUniqueID 1108897664141,Method ,i0_on mouseUp set the enabled of grp "Compression" to the hilitedButton of me <> 1 end mouseUp ZCMethod: cREVGeneral revUniqueID 1108891894167$Rad1hdwZLink to Original File cREVGeneral revUniqueID 1108891405342 &Rad2hdwpStore Thumbnail into Stack cREVGeneral revUniqueID 1108891409703 'Rad3hdwLink to Optimized New File cREVGeneral revUniqueID 1108891491213 - CompressionisT cREVGeneral revUniqueID 1108892042894)CompBarqWon mouseUp local tPos,tDelta ----- put the thumbPos of me into tPos if tPos < 6 then exit mouseUp ----- put round(tPos mod 5) into tDelta switch tDelta case 5 break case 1 case 2 set the thumbPos of me to tPos - tDelta break default set the thumbPos of me to tPos + (5 - tDelta) end switch end mouseUp w. EtE1100 cREVGeneral revUniqueID 1108891567471 + CompLabel ~ cREVGeneral revUniqueID 1108891807195 JPEG Quality3 TestImage i 0xxxxxxZF cREVGeneral revUniqueID 1108892515374 TestImage `di JFIFC    ' .)10.)-,3:J>36F7,-@WAFLNRSR2>ZaZP`JQROC&&O5-5OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?ѵ${٤eIA[oj]КWk"768Aۍ" &: YfUb!\nesQfVe)HC<|zr;V5<ۃuXcQ8/ḏ38p29<{h2T($MZi#{)7!8?Zպ$%8꼮d#n;oR{MF+w/O[bdߖv)Wre IE%YE%)(aIE%RPiM[?3c_BM#C6?(-%b6gfYhf@򢓒:\5$wSF! 55/ 3yzξ0?$15^;'՗,A+:{3MAԘE?ҟ(\ٌH)!? pd{U!FVR;z{W=oץŸfhXxY|TF8XTYجI~uw NA$vTLnP6ygۯjꭦ9ד]Y !vqiw=c'F;;qJwNH D  A With some minor modifications, this stack, using method 3, can become a thumbnail maker: see my free plugin Thumbnails Picker on my website. @1600  @1606  l p  c `W4fScriptep1on mouseUp edit script of this cd end mouseUp Z1 Show Script cREVGeneral revUniqueID 1108897852368 @ Flche2.png F PNG  IHDR Kpl_ pHYs  gAMA|Q cHRMz%u0`:o_FIDATxb?,Xv$ϯ.?~~e'P#@11 @?~23_k_?V@p /÷>|()%ţ,%-F2\@ *n w JU牓/_ o_ū(II` b`AM]Nk5 _ ,?d+@021~K?@fӬ ~W XXY};w<||| ߿}Kw^W@koǑ74;Gڷo_߿uLL7qe`&Fqϟ_sPuFFfbA8`(10r=zk~ TxNP`=l|,IENDB` cREVGeneral revUniqueID 1108898467510SSS.png  "-PNG  IHDR". pHYs.#.#x?v 9iCCPPhotoshop ICC profilexڝwTTϽwz0z.0. Qf Ml@DEHb!(`HPb0dFJ|yyǽgs{.$O./ 'z8WGбx0Y驾A@$/7z HeOOҬT_lN:K"N3"$F/JPrb[䥟}Qd[Sl1x{#bG\NoX3I[ql2$ 8xtrp/8 pCfq.Knjm͠{r28?.)ɩL^6g,qm"[Z[Z~Q7%" 3R`̊j[~: w!$E}kyhyRm333: }=#vʉe tqX)I)B>== <8Xȉ9yP:8p΍Lg kk Ѐ$t!0V87`ɀ2A. @JPA#h'@8 .: ``a!2D!UH 2 dA>P ECqB**Z:]B=h~L2  5pN:|ó@ QC !H,G6 H9R ]H/r Aw( Q(OTJCm@*QGQ-(j MF+ 6h/*t:].G7Зw7 Xa<1:L1s3bXyeb~19 vGĩp+5qy^ oó|= ?'Htv`Ba3BDxHxE$Չ"XAP44077&9$An0;T2421t.54ld+s;# V]=iY9FgM֚k&=%Ō:nc1gcbcfX.}lGv{c)LŖN퉛w/p+/<j$.$%&㒣OdxTԂԑ4i3|o~C:&S@L u[Uo3C3OfIgwdO|;W-wsz 17jl8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