Image file handling with LC on server?

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 301
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Image file handling with LC on server?

Post by thatkeith » Sat Aug 29, 2020 6:23 pm

I have LC set up on one of my servers and I've managed to get myself into first gear (as it were) with very basic operations: returning HTML with logic-based content, and driving exiftool using shell(). But I'm still struggling to understand the core concepts and differences between LC running on regular devices (GUI and all) and LC on a server.

I'm honestly not trying to get someone to do this for me, but all pointers, comments and suggestions will be eagerly read and pondered!
Okay... with the sticking points/confusion points in bold, I'd like to be able to:
  1. Upload a JPEG
  2. Get its pixel dimensions
  3. Resize it to a thumbnail (to be shown in a web page) <- this is where I really hit the headscratching point
  4. Add some metadata
  5. Zip the image
  6. Make it available for download
Some details about these points...

1: Uploading a JPEG. I can do this easily enough with PHP, but for personal satisfaction I'd appreciate suggestions for how (and if) I should approach this in a more LC-centric way.

2: Getting pixel dimensions. I have this sorted using shell() to call exiftool, which I also use for [4]. As with [1] I'm interested in how I might do this in LC, but it's not a sticking point.

3: Resizing the image. For a regular LC stack I could simply set the filename of an image to the JPEG file, scale it as appropriate, then export a fresh JPEG which can be referenced by HTML. But the LC Dictionary lists the export command as being for desktop and mobile platforms; it doesn't list server. How should I approach using LC on a server to resize an image?
I could use a different server tool, but I want to do as much as I can with LC! It should help me learn this aspect of LC, I think and hope.

4: Adding metadata. Got this working fine using exiftool called from shell().

5: Zip. Not tried it yet but I'm reasonably confident with the zip entries in the Dictionary. :)

6: Offering the zip for download. This is easy stuff.

I realise allowing file uploads on a public server is a potentially very risky thing to do. I'm very happy to read any thoughts about this too. :|

Keith
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
360 VR media specialist

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8016
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Image file handling with LC on server?

Post by FourthWorld » Sat Aug 29, 2020 6:51 pm

thatkeith wrote:
Sat Aug 29, 2020 6:23 pm
...the LC Dictionary lists the export command as being for desktop and mobile platforms; it doesn't list server.
"Platforms" shows "desktop,web":
https://livecode.com/resources/api/#liv ... th_palette

That doesn't seem right either, since "web" should probably be "server", and "mobile" is missing there.

The functionality you're looking for is definitely available. See this Lesson:

"How do I use LiveCode graphics features server-side?"
http://lessons.livecode.com/m/15262/l/1 ... erver-side
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 301
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Image file handling with LC on server?

Post by thatkeith » Sat Aug 29, 2020 10:51 pm

Hi Richard,

Thanks! I've just read through some of this and it is *definitely* going to help!

Wow. [grins widely]

k
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
360 VR media specialist

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 923
Joined: Fri Aug 15, 2008 7:15 am

Re: Image file handling with LC on server?

Post by bangkok » Sun Aug 30, 2020 10:46 am


thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 301
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Image file handling with LC on server?

Post by thatkeith » Sun Aug 30, 2020 10:38 pm

[bows in thanks] :D
Senior Lecturer, LCC (University of the Arts London)
Technical Editor, MacUser (1996-2015)
360 VR media specialist

Post Reply

Return to “CGIs and the Server”