#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" N resizerMain1on preOpenStack stripAndShip end preOpenStack on stripAndShip set the fileName of img 1 to empty put 200 into fld "theSize" put "" into fld "resizedImgFilePath" end stripAndShip h Ums sans serif UTahomaUTahoma UTahomaUTahomaWTahoma U Courier New U Courier New WTahoma WTahomaWTahoma cREVGeneral debugObjects @ 7NResize Image...Epbon mouseUp --> GET A FILE TO RESIZE answer file "Choose an Image File" if it is empty then exit to top put it into tFilePath set the fileName of img 1 to tFilePath put the result into tResult if tResult is not empty then answer warning tResult &cr& "This could be because the image is not the correct format." exit mouseUp end if --> GET THE RESIZE PARAMETERS put the label of btn "resizeMode" into tMode put the fld "theSize" into tSize if not isNumber(tSize) then answer warning "Please enter a valid number to resize to." exit to top end if if tMode is "Maximize Width" then put "MaxWidth" into tMode else put "MaxHeight" into tMode end if --> CHOOSE DESTINATION FILEPATH set itemDel to "/" put last item of tFilePath into tFileName ask file "Save as:" with tFileName if it is empty then exit to top put it into tFilePathToSave put it into fld "resizedImgFilePath" --> RESIZE THE IMAGE start using stack "altResizeImgLib" altResizeImage tFilePath,tFilePathToSave,tSize,tMode,90 stop using stack "altResizeImgLib" end mouseUp R cREVGeneral revUniqueID 1089225849047 Image 1 @ cREVGeneral revUniqueID 1089225901589 resizeMode eMaximize HeightMaximize Width Maximize Height cREVGeneral revUniqueID 1089226194859 theSize)`JZ cREVGeneral revUniqueID 1089226244549  200 Open ViewerEp.on mouseUp open stack "viewer" end mouseUp .R cREVGeneral revUniqueID 1089229457467 Field 1 z cREVGeneral revUniqueID 1089230278167 Image to Resize (not to scale) resizedImgFilePath |0 cREVGeneral revUniqueID 1089230327897 Field 1 z~ cREVGeneral revUniqueID 1089230331713 Resized Image Filepath 7Field 2  cREVGeneral revUniqueID 1089232306099 altResizeImgLib  by Chipp Walters, Altuit, inc.   This library allows you to resize and save an image with the 'best' resizeQuality of the engine while maintaining the aspect ratio. It can save in PNG, JPEG or GIF formats (if you have purchased the GIF unlock code from RR).   This DEMO stack   Press the Resize Image button and you are prompted for an image to open. Then you are asked for a filename to save as. Next, the altResizeImage command is called with the parameters specified by Maximum Height/Maximum Width and the pixel value.   k  f  `If you set the control to Maximize Height, then the image height will be set to the height value specified with the width being whatever it needs to be to maintain proportions. If you set the control to Maximize Width, then the image width will be set to the width value specified with the height being whatever it needs to be to maintain proportions. _  UYou can press the Open Viewer button to browse for and view the newly resized image.    7  How to install:   @Make the stack "altResizeImg" as a substack of your main stack. ?  Then use the commands:   $start using stack "altResizeImgLib" # >altResizeImage tFilePath,tFilePathToSave,tSize,tMode,tJpgQual = #stop using stack "altResizeImgLib" "  Where:  ,tFilePath IS THE ORIGINATING IMAGE FILEPATH   "  ,tFilePathToSave IS THE DESTINATION FILEPATH    NOTE: THIS HANDLER WILL LOOK AT THE EXTENSION OF THE FILE IN tFilePathToSave TO DETERMINE WHAT FILE TYPE TO SAVE AS. IF NO EXTENSION THEN DEFAULT IS "JPEG"   TtSize IS THE MAXWIDTH OR MAXHEIGHT IN PIXELS. ALL IMAGES ARE RESIZED PROPORTIONALLY   N  UtMode IS EITHER "MaxHeight" or "MaxWidth" AND TELL THE HANDLER WHICH ONE TO OPTIMIZE   O  JtJpgQual IS OPTIONAL AND TELLS WHAT JPEGQUALITY TO SAVE AS. DEFAULT IS 90  A  8 `@  Nvers on mouseUp if the shiftKey is down then ask "New Version:" with me if it is empty then exit mouseUp put it into me end if end mouseUp $ cREVGeneralscriptChecksumfZck|K/ bookmarks revUniqueID 1089234803136 handlerListmouseUp prevHandlermouseUp tempScriptscriptSelectionchar 129 to 128script,

on mouseUp

if the shiftKey is down then

ask "New Version:" with me

if it is empty then exit mouseUp

put it into me

end if

end mouseUp

v0.9altResizeImgLib1 on altResizeImage pFilePath,pFilePathToSave,pSize,pMode,pJpgQual --> pFilePath IS THE ORIGINATING IMAGE FILEPATH --> pFilePathToSave IS THE DESTINATION FILEPATH --> NOTE: THIS HANDLER WILL LOOK AT THE EXTENSION OF THE FILE IN pFilePathToSave --> TO DETERMINE WHAT FILE TYPE TO SAVE AS. IF NO EXTENSION THEN DEFAULT IS "JPEG" --> pSize IS THE MAXWIDTH OR MAXHEIGHT IN PIXELS. ALL IMAGES ARE RESIZED PROPORTIONALLY --> pMode IS EITHER "MaxHeight" or "MaxWidth" AND TELL THE HANDLER WHICH ONE TO OPTIMIZE --> pJpgQual IS OPTIONAL AND TELLS WHAT JPEGQUALITY TO SAVE AS. DEFAULT IS 90 if pJpgQual is empty then put 90 into pJpgQual set the jpegQuality to pJpgQual set the resizeQuality of img "altImg" of stack "altResizeImgLib" to "best" put imageFileDimensions(pFilePath) into tDims put item 1 of tDims into tWidth put item 2 of tDims into tHeight put the screenRect into tRect put item 3 of the screenRect into tMaxWidth put item 4 of the screenRect into tMaxHeight if pSize > tMaxWidth or pSize > tMaxHeight then answer warning "Trying to scale up larger than the screen!" exit to top end if lock screen if pMode is "MaxWidth" then put pSize/tWidth * tHeight into tY if tY > tMaxHeight then answer warning "Trying to scale up larger than the screen!" exit to top end if set the rect of stack "altResizeImgLib" to 0,0,pSize,tY set the rect of img "altImg" of stack "altResizeImgLib" to 0,0,pSize,tY else --> pMode is "MaxHeight" put pSize/tHeight * tWidth into tX if tX > tMaxWidth then answer warning "Trying to scale up larger than the screen!" exit to top end if set the rect of stack "altResizeImgLib" to 0,0,tX,pSize set the rect of img "altImg" of stack "altResizeImgLib" to 0,0,tX,pSize end if #set the resizeQuality of img "altImg" of stack "altResizeImgLib" to "best" set the filename of image "altImg" of stack "altResizeImgLib" to pFilePath set the loc of stack "altResizeImgLib" to the screenloc unlock screen palette "altResizeImgLib" #put the windowID of stack "altResizeImgLib" into tWID --> GET FILETYPE set itemDel to "/" put last item of pFilePathToSave into tFileName set itemDel to "." put last item of tFileName into tExtension switch tExtension case ".png" export snapshot from rect the rect of stack "altResizeImgLib" to file pFilePathToSave as PNG break case ".gif" export snapshot from rect the rect of stack "altResizeImgLib" to file pFilePathToSave as GIF break case ".jpg" case ".jpeg" export snapshot from rect the rect of stack "altResizeImgLib" to file pFilePathToSave as JPEG break default export snapshot from rect the rect of stack "altResizeImgLib" to file pFilePathToSave as JPEG end switch put the result into tResult if tResult is not empty then answer tResult #wait for 1000 milliseconds with messages close stack "altResizeImgLib" end altResizeImage function imageFileDimensions theFilePath lock screen -- so user doesn't see the following shenanigans lock error dialogs -- prevent error window if import fails import paint from file theFilePath -- creates a new image unlock error dialogs put the width of last image into myWidth put the height of last image into myHeight delete last image -- get rid of image we created unlock screen return myWidth,myHeight end imageFileDimensions on errorDialog -- executed if the import causes a script error beep answer "There was a problem accessing the file data."\ & return & return & \ "Picture files must be in one of the following formats:" & return & \ "PNG, JPEG, GIF, PICT, BMP, XWD/XBM/XPM, or PBM/PGM/PPM." exit to top end errorDialog on preOpenStack end preOpenStack on closeStack set the filename of img "altImg" to empty end closeStack on openStack end openStack on resizeStack end resizeStack TXX  Ums sans serif cREVGeneral breakPoints @XXaltImg @XX cREVGeneral revUniqueID 1089227046649viewer10on preOpenStack set the filename of img 1 of this stack to empty set the width of this stack to 200 set the height of this stack to 200 set the loc of this stack to the screenloc end preOpenStack on closeStack end closeStack on openStack end openStack on resizeStack end resizeStack TXX  Ums sans serif cREVGeneral @XXImage 1 P&on mouseUp answer file "choose image" if it is empty then exit to top set the filename of me to it set the topLeft of me to 0,0 set the width of this stack to the width of me set the height of this stack to the height of me set the loc of this stack to the screenloc end mouseUp XXNC:/Documents and Settings/Chipp/My Documents/My Pictures/finance/7253696a.jpg cREVGeneral revUniqueID 1089228677119 Field 1 R( cREVGeneral revUniqueID 1089229561918 Click Here to View an Image