Fwd: [FYI] Using Graphic Commands on Server
stephen barncard
stephenREVOLUTION2 at barncard.com
Sun Jun 30 16:05:34 EDT 2013
I am sad to report that it does not seem possible to use templates to do
group snapshots yet.
This would require the ability to manipulate graphic objects rather than
their templates.
here is my code for scaling (there may some pointless garbage in the code):
<?rev
/*
TEST OF ABILITY TO IMPORT,
SCALE AND EXPORT IMAGE ON LIVECODE SERVER
uses URL for input:
test.iRev?imagename=DSC00004.JPG&percent=50
SQB 20130630
*/
-- get parameters from URL
put $_GET[imagename] into pFilename
put $_GET[percent] into pScalePercent
-- confirm input
put pFilename & "<br>" & pScalePercent
-- converts and saves image
convertImage pFilename,pScalePercent
/*
importing and scaling images on server
*/
on convertImage pSourceName,pScalePercent
importTImage pSourceName
if the result is not empty
then
-- report if the file is not there
put the result
exit to top
end if
scaleTImage pSourceName,pScalePercent
exportTImage
end convertImage
on importTImage pFileName
if there is a file pFileName
then
set the filename of the templateImage to ""
wait .1 second with messages
set the filename of the templateImage to pFileName
put the rect of the templateImage into tRect
set the cOriginalRect of the templateImage to tRect
set the cOriginalWidth of the templateImage to the width of the
templateImage
set the cOriginalHeight of the templateImage to the height of the
templateImage
set the topLeft of the templateImage to "38,132"
else
return "file not found"
end if
end importTImage
on scaleTImage pIname,pScalePCT
put the cOriginalWidth of the templateImage into a
put the cOriginalHeight of the templateImage into b
put round((a*pScalePCT)/100) into a
put round((b*pScalePCT)/100) into b
set the width of the templateImage to a
set the height of the templateImage to b
set the topLeft of the templateImage to "38,132"
end scaleTImage
on exportTImage
put randomname("image_",".png") into x
export the templateImage to file x as PNG
end exportTImage
function randomName preamble,postamble
-- put randomname("image_",".png")
put randombytes(2) into a
repeat for each char cCH in a
put charToNum(cCH) into x
put baseconvert(x,10,16) after tOut
end repeat
return preamble & tOut & postamble
end randomName
?>
On Sat, Jun 29, 2013 at 10:44 PM, stephen barncard <
stephenREVOLUTION2 at barncard.com> wrote:
> got it. An overlay of sorts. Very useful. Good idea..
>
> I would need to use templateField and position it.
>
> I'll give it a try...
>
> sqb
>
>
> On Sat, Jun 29, 2013 at 10:40 PM, Richard Gaskin <
> ambassador at fourthworld.com> wrote:
>
>> stephen barncard wrote:
>>
>> > On Sat, Jun 29, 2013 at 10:21 PM, Richard Gaskin wrote:
>> >> Do we have the ability to export objects other than images in
>> >> that build?
>> >>
>> >> Once we can export groups we have custom greeting cards and a
>> >> whole lot more...
>> >>
>> > Richard,
>> >
>> > Help me out here - scratching my head...
>> > what grouped objects would be useful on server?
>>
>> Suppose for example you want to make customized greeting cards. So you
>> have a selection of pictures, and let the user enter text, which will be
>> embedded in the image.
>>
>> If you had to calculate the pixel positions for every letter and insert
>> them by monkeying with the imageData, it would be tedious, error-prone, and
>> probably look horrible.
>>
>> Much simpler would be to have a script that takes the input from the
>> user, sets the text of a field, and exports a snapshot of a group which
>> contains the field and the original picture, generating a composite JPEG
>> which can be sent back to the browser or emailed.
>>
>> There are all sorts of things we can do by combining vector objects to
>> create raster ouput - provided, of course, that the latest LC server now
>> has its image rendering sufficiently factored from the UI routines that
>> it's at long last possible.
>>
>>
>> --
>> Richard Gaskin
>> Fourth World Systems
>> Software Design and Development for Desktop, Mobile, and Web
>> ______________________________**______________________________
>> Ambassador at FourthWorld.com http://www.FourthWorld.com
>>
>> ______________________________**_________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>>
>
>
>
> --
>
>
>
> Stephen Barncard
> San Francisco Ca. USA
>
> more about sqb <http://www.google.com/profiles/sbarncar>
>
--
Stephen Barncard
San Francisco Ca. USA
more about sqb <http://www.google.com/profiles/sbarncar>
More information about the use-livecode
mailing list