[!]********** include Function file here ******************************[/!] [include IMFunctions.inc] [!]********** SANDBOX VERSION ******************************[/!] [!]********** See read me file for more info ***************[/!] [!] *** Delete the file [/!] [showif [kill]=t] [deletefile [f]/[filename]] [/showif] [!] *** Rename the file [/!] [showif [renamethisfile]=t] [text]uploadmessage=File renamed to [tofile].[/text] [movefile from=uploads/[fromfile]&to=uploads/[tofile]] [/showif] [text multi=t&secure=f]uploadmessage=&W=&h=[/text] [!] *** default variables; may be overridden by formvariables (secure=f) ****[/!] [!] *** universal -- source and destination files [/!] [text multi=t]filein=[f]/[filename]&fileout=images/[tofile][/text] [!] *** for imImprintText [/!] [text multi=t&secure=f]font=Arial&textstring=Copyright [date %Y] Your Name Here&textsize=12&textcolor=#FFFFFF&textloc=southeast&offsetX=10&offsetY=20[/text] [!] *** for imRotate [/!] [text secure=f]rotation=0[/text] [!] *** for imMirror [/!] [!] *** flop=mirrored reversal; flip=upside-down reversal [/!] [text secure=f]whichway=flop[/text] [!] *** for imResizeImage [/!] [text multi=t&secure=f]maxWidth=500&maxHeight=500[/text] [!] *** for imMakeThumb [/!] [text multi=t&secure=f]maxTHwidth=100&maxTHheight=100&THtype=jpg&THext=_th&ThFileOut=images/[tothfile][/text] ImageMagick Manipulation [!]********** IMAGE UPLOAD PROCESSING ****************************** ********** because the image upload uses ****************************** ********** enctype="multipart/form-data" in the
tag, *********** ********** we have to deal with the formvariables differently ********[/!] [formvariables] [!]********* correct ordinary incoming variables; pull out name/values ***************[/!] [showif [url][name][/url]^[url]name="[/url]] [hideif [url][name][/url]^[url]filename="[/url]] [text][Middle StartAfter=name="&endbefore="][name][/Middle]=[value][/Text] [/hideif] [/showif] [!]********* pull out values of file upload - both the filename ([name]), ********* and the binary data itself ([value]) Some OSes send the complete pathname to the file; some send just the filename. ********** So we have to peel away the leading directories to end up with just the filename. [/!] [showif [url][name][/url]^[url]filename="[/url]] [Text]fullfilename=[Middle StartAfter=filename="&endbefore="][name][/Middle][/Text] [listwords words=[fullfilename]&delimiters=:/\] [text]origfilename=[word][/text] [/listwords] [!]***** write the file to upload dir *****************[/!] [hideif [fullfilename]=] [writefile file=uploads/[origfilename]&secure=F][value][/writefile] [text]uploadmessage=[origfilename] was added to the uploads folder.[/text] [/hideif] [showif [fullfilename]=] [text]uploadmessage=No file was chosen to upload.[/text] [/showif] [/showif] [/formvariables] [!]********************************************[/!] [!]***************** TABLE *******************[/!] [!]********************************************[/!] [!] ********** ImageMagick Operations **********[/!] [!] *********** chained functions *********** [/!] [!] *********** chained functions *********** [/!] [!] *********** chained functions *********** [/!] [showif [IMOps]=t] [!] *********** IM PROCESS IMAGES *********** [/!] [showif [submit]=process image] [!] ****** reset fileIn after each step so we add the next process to the latest file ****** [/!] [showif [chgformat]=t][imChangeFormat FileIn=[filein]&FileOut=[fileout]&fileform=[fileform]] [text]fileout=[getchars start=4&from=end][FileOut][/getchars][fileform][/text] [text]filein=[fileout][/text][/showif] [showif [resize]=t][imResizeImage FileIn=[FileIn]&maxWidth=[maxWidth]&maxHeight=[maxHeight]&FileOut=[FileOut]] [text]filein=[fileout][/text][/showif] [showif [rotate]=t][imRotate FileIn=[filein]&FileOut=[FileOut]&rotation=[rotation]] [text]filein=[fileout][/text][/showif] [showif [mirror]=t][imMirror FileIn=[filein]&FileOut=[FileOut]&whichway=[whichway]] [text]filein=[fileout][/text][/showif] [showif [thumbnail]=t][imMakeThumb FileIn=[filein]&FileOut=[FileOut]&maxTHwidth=[maxTHwidth]&maxTHheight=[maxTHheight]&THtype=[THtype]] [/showif] [showif [imprint]=t][imImprintText FileIn=[filein]&FileOut=[FileOut]&textstring=[textstring]&textsize=[textsize]&textcolor=[textcolor]&textloc=[textloc]&offsetX=[offsetX]&offsetY=[offsetY]][/showif] [/showif] [!] *** END [submit]=process image *** [/!] [!] *********** MAKE CHOICES *********** [/!] [/showif] [!] **** END IMOps = t **** [/!] [!]********** File lists IMAGE folder **********[/!] [!]********** File lists IMAGE folder **********[/!] [listfiles images] [/listfiles] [!]********** File list UPLOAD folder **********[/!] [!]********** File list UPLOAD folder **********[/!] [listfiles uploads] [/listfiles] [!]************* upload form *************[/!] [!]************* upload form *************[/!]
[uploadmessage]
ImageMagick Manipulation   RESET PAGE
[showif [thumbnail]=t]
[ThFileOut]
[FileInfo file=[ThFileOut]] [if "[filename]"^".jpg" | "[filename]"^".jpeg" | "[filename]"^".gif" ][then][ImageWidth] x [ImageHeight] [/then][/if]([format thousands .0f][math][Size]/1000[/math][/format]K)[/FileInfo] [/showif]
[if "[resize]"="t" | "[rotate]"="t" | "[mirror]"="t"| "[chgformat]"="t"| "[imprint]"="t" ][then]
[FileOut]
[FileInfo file=[fileout]] [if "[filename]"^".jpg" | "[filename]"^".jpeg" | "[filename]"^".gif" ][then][ImageWidth] x [ImageHeight] [/then][/if]([format thousands .0f][math][Size]/1000[/math][/format]K)[/FileInfo] [/then][/if]
Source file:

[f]/[filename]

[FileInfo file=[f]/[filename]] [if "[filename]"^".jpg" | "[filename]"^".jpeg" | "[filename]"^".gif" ][then][ImageWidth] x [ImageHeight] [/then][/if]([format thousands .0f][math][Size]/1000[/math][/format]K)[/FileInfo]
[!] f=folder; i.e., uploads or images [/!] Destination Name for Main Image:
(change if you like; will go in Images folder)
Change File Type
Format:
Resize Image
MaxW: MaxH: (image will not be enlarged, only reduced)
Rotate Image
Rotate:
Reverse (Mirror) Image
Reverse:
Imprint Text
Text: Size: Color:
Location: OffsetX: OffsetY:
Make Thumbnail
MaxW: MaxH: Name:
Image Folder
[filename]   ImageMagick
[FileInfo file=images/[filename]] [if "[filename]"^".jpg" | "[filename]"^".jpeg" | "[filename]"^".gif" ][then][ImageWidth] x [ImageHeight] [/then][/if]([format thousands .0f][math][Size]/1000[/math][/format]K)[/FileInfo] delete
Upload Folder
[filename]   ImageMagick
[FileInfo file=uploads/[filename]] [if "[filename]"^".jpg" | "[filename]"^".jpeg" | "[filename]"^".gif" ][then][ImageWidth] x [ImageHeight] [/then][/if]([format thousands .0f][math][Size]/1000[/math][/format]K)[/FileInfo] [!] delete[/!]
File Upload