I have a simple html form that uploads images to a directory on the on-rev server. The images are uploaded at different resolutions. I would like to have the on-rev server resize the width of the images in that folder when users drop them into the server via an html form.
Yes, it is possible - here's the relevant section of the .lc file I used
to use to do it.
(it's from my script-only library that I use on both LCServer and
desktop/IDE, hence the 'lockscreen's
I would use this by uploading the file (usually to a folder called
'originals' or something like that), and then resizing to more
imaginatively named folders such as 'width90' or 'width600' for
-- image handling and resizing
command setAreaProportional pImageID, pWidth, pHeight
local tProportionalWidth, tProportionalHeight, tRatio
put (the formattedWidth of pImageID) / pWidth into tRatio
put (the formattedHeight of pImageID) / tRatio into tProportionalHeight
put (the formattedHeight of pImageID) / pHeight into tRatio
put (the formattedWidth of pImageID) / tRatio into tProportionalWidth
if tProportionalHeight > pHeight then
set the width of pImageID to tProportionalWidth
set the height of pImageID to pHeight
set the width of pImageID to pWidth
set the height of pImageID to tProportionalHeight
function resizeImageFile pFile, pOutFile, pMaxWid, pMaxHeight
local t, tt
import paint from file pFile
put the name of the last image into t
set the name of t to "Im1"
clone img "Im1"
set the name of it to "Im2"
setAreaProportional the long id of img "Im2", pMaxWid, pMaxHeight
export img "Im2" to file pOutFile as jpeg
put the result into tt