Resize Images in on-rev folder via lc script?

Alex Tweedly alex at
Sun Mar 12 20:24:17 EDT 2017

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 
different purposes.

-- 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
       lock screen
       set the width of pImageID to tProportionalWidth
       set the height of pImageID to pHeight
       unlock screen
       lock screen
       set the width of pImageID to pWidth
       set the height of pImageID to tProportionalHeight
       unlock screen
    end if
end setAreaProportional

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

    delete img "Im2"
    delete img "Im1"

    return empty      -- "Done resize" & ":" & tt & ":" && pFile && pOutfile
end resizeImageFile

-- Alex.

On 12/03/2017 22:29, JOHN PATTEN via use-livecode wrote:
> Hi All,
> 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.
> Is it possible using lc scripts on the on-rev server to resize the images? I can do the resize easily via a stack using the example here, <> , but I’m not sure how that could be applied to a folder on the server using .lc scripts?
> Thank you!
> John Patten
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the use-livecode mailing list