Phaethon Solutions LightenIt! Processor. Example of use

Image upload dialog layout (clickable)

Suggested business process

1. User upload an image.
2. Immediately after uploading image we launch Phaethon Solutions LightenIt! Processor on web-server (in the background, to avoid any delay felt by the user) and get enhanced image.
3. The user is requested to enhance the uploaded image. Dialog contains the original image and a checkbox “Enhance image”. Clicking on checkbox causes immediate switching the images. Delay does not occur because the enhanced image is already ready.
4. User press OK button. Uploaded image – original or enhanced, depending on the checkbox state – is saved, dialog is closed.

Note that the user does not experience a delay caused by using of the image enhancement.

Code samples

Launching Phaethon Solutions LightenIt! Processor in the background (step #2 of the business process), PHP

exec(./imgproc original.jpg <parameters> enhanced.jpg > /dev/null &)

* Instead of “original.jpg” and “enhanced.jpg” use real image file names with path
** “/dev/null &” postfix is used to launch processing in the background

Image upload dialog (step #3 of the business process), HTML

<img id="image" src="original.jpg" />
<label><input id="checkbox" type="checkbox" onclick="OnCheckboxClick(this.checked)" />Enhance image</label>
<input type="submit" value="OK" onclick="OnButtonClick(document.getElementById('checkbox').checked)" />

* element <label> is used to response clicking on the checkbox title

“Enhance image” checkbox handler (step #3 of the business process), Javascript

function OnCheckboxClick(checked) {
	var img = document.getElementById('image');
	if (checked) {img.src='enhanced.jpg'} else {img.src='original.jpg'};

* Instead of “original.jpg” and “enhanced.jpg” use real image file names with path

“OK” button handler (step #4 of the business process), Javascript

function OnButtonClick(use_enhanced_image) {
	// Do asynchronous POST/GET request to server pass checkbox "Enhance image" state ("use_enhanced_image" function parameter) as request parameter
	// Close dialog