Gimp Guillotine Image Based Canvas Editing Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Gimp Guillotine Image Based Canvas Editing Tutorial

Gimp Guillotine Image Based Canvas Editing Tutorial

The recent code developments that happened with Emoji Borders and Backgrounds Canvas Annotation Tutorial set us to thinking that that tutorialโ€™s work could have been improved, in scope, by creating an external Javascript that can work with other RJM Programming web applications that could benefit with HTML canvas editing capabilities via a single line (within their head element) change like โ€ฆ



<script type='text/javascript' src='/canvas_svg.js'></script>

And so we found ourselves harkening back to Gimp Guillotine Image File Browse Windows Intranet Video Tutorialโ€˜s โ€œGimp Guillotine Follow Upโ€ PHP web application, where the user can be presented with an image based HTML canvas element, and there wasnโ€™t already a canvas editing piece of functionality happening, until ourchanged gimp_guillotine_followupโšซphp Gimpโœ‚Guillotine Follow Up PHP web application.

Todayโ€™s tutorial animated GIF shows this in action using the first draft canvas_svgโšซjs external Javascript helper โ€ฆ



// canvas_svg.js

// RJM Programming

// January, 2022

// Change a canvas via user_of_signature_signature.htm canvas



var ejcanvases=document.getElementsByTagName('canvas');

var ejcanvas;

var ejprechash='', ejchash='';

var ejuoss=null;

var ejpasseddu='', ejorigpasseddu='';

var ejtextcss=location.search.split('textcss=')[1] ? decodeURIComponent(location.search.split('textcss=')[1].split('&')[0]) : '';

var ejimagecss=location.search.split('imagecss=')[1] ? decodeURIComponent(location.search.split('imagecss=')[1].split('&')[0]) : '';

var ejcss=location.search.split('css=')[1] ? decodeURIComponent(location.search.split('css=')[1].split('&')[0]) : '';




function ejsetup() {

ejcanvases=document.getElementsByTagName('canvas');

if (eval('' + ejcanvases.length) > 0) {

ejcanvas = document.querySelector('canvas');




if (!document.getElementById('gstyle')) {

var odivio=document.createElement('div');

odivio.id='gstyle';

odivio.innerHTML='';

document.getElementsByTagName('body')[0].appendChild(odivio);

}



if (ejcss != '') {

var ejgstyleis='';

if (ejcss == ejtextcss) {

ejgstyleis=' <style> </style> ';

ejgstyleis=ejgstyleis.replace('</style', ' img, canvas { ' + ejtextcss + ' } </style');

if (ejimagecss != '') { ejgstyleis=ejgstyleis.replace(' } </style', ' ' + ejimagecss + ' } </style'); }

} else if (ejcss == ejimagecss) {

ejgstyleis=' <style> </style> ';

ejgstyleis=ejgstyleis.replace('</style', ' img, canvas { ' + ejimagecss + ' } </style');

if (ejtextcss != '') { ejgstyleis=ejgstyleis.replace(' } </style', ' ' + ejtextcss + ' } </style'); }

} else {

ejgstyleis=' <style> </style> ';

ejgstyleis=ejgstyleis.replace('</style', ' img, canvas { ' + ejcss + ' } </style');

if (ejtextcss != '') { ejgstyleis=ejgstyleis.replace(' } </style', ' ' + ejtextcss + ' } </style'); }

if (ejimagecss != '') { ejgstyleis=ejgstyleis.replace(' } </style', ' ' + ejimagecss + ' } </style'); }

}

if (ejgstyleis != '') { document.getElementById('gstyle').innerHTML=ejgstyleis; }

}



if (document.getElementById('gstyle')) {

if (document.getElementById('gstyle').innerHTML.indexOf('canvas {') != -1) {

ejprechash=document.getElementById('gstyle').innerHTML.split('canvas {')[1].split('}')[0];

}

}

if (ejcanvases[0].outerHTML.indexOf(' style="') != -1) {

ejchash='#' + encodeURIComponent(ejprechash + ejcanvases[0].outerHTML.split(' style="')[1].split('"')[0]);

}

if (('' + ejcanvases[0].title) != 'Click me for canvas annotation editing (discrete click shapes and freeform scribbling) functionality in new window.') {

ejcanvases[0].title='Click me for canvas annotation editing (discrete click shapes and freeform scribbling) functionality in new window.';

if (ejcanvases[0].outerHTML.indexOf(' onclick=') == -1) {

ejcanvases[0].onclick=function() { if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } } if (!ejuoss) { setTimeout(ejmonitoru,6000); ejorigpasseddu=ejcanvases[0].toDataURL('image/png'); ejpasseddu=ejorigpasseddu; ejuoss=window.open('/HTMLCSS/user_of_signature_signature.htm' + ejchash,'_blank','top=20,left=20,width=' + eval(0.9 * eval('' + screen.width)) + ',height=' + eval(0.8 * eval('' + screen.height)) + ''); } else { ejuoss.focus(); } };

} else if (ejcanvases[0].outerHTML.indexOf('down=') == -1) {

ejcanvases[0].onmousedown=function() { if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } } if (!ejuoss) { setTimeout(ejmonitoru,6000); ejorigpasseddu=ejcanvases[0].toDataURL('image/png'); ejpasseddu=ejorigpasseddu; ejuoss=window.open('/HTMLCSS/user_of_signature_signature.htm' + ejchash,'_blank','top=20,left=20,width=' + eval(0.9 * eval('' + screen.width)) + ',height=' + eval(0.8 * eval('' + screen.height)) + ''); } else { ejuoss.focus(); } };

ejcanvases[0].ontouchdown=function() { if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } } if (!ejuoss) { setTimeout(ejmonitoru,6000); ejorigpasseddu=ejcanvases[0].toDataURL('image/png'); ejpasseddu=ejorigpasseddu; ejuoss=window.open('/HTMLCSS/user_of_signature_signature.htm' + ejchash,'_blank','top=20,left=20,width=' + eval(0.9 * eval('' + screen.width)) + ',height=' + eval(0.8 * eval('' + screen.height)) + ''); } else { ejuoss.focus(); } };

}

}

}

}




function ejmonitoru() {

if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } }

if (ejuoss) {

if (ejuoss.document.getElementById('topcbutton').innerHTML.indexOf(' ') != -1) {

ejuoss.document.getElementById('topcbutton').innerHTML=ejuoss.document.getElementById('topcbutton').innerHTML.replace(' ','');

window.focus();

}

var ejthispdu=ejuoss.document.getElementById('topcanvas').toDataURL('image/png');

if (ejpasseddu != ejthispdu) {

if (document.getElementById('antiu')) {

document.getElementById('antiu').style.display='inline-block';

}

ejpasseddu=ejthispdu;

var ejxnewimg=document.createElement('img');

ejxnewimg.onload = function() {

// draw the image onto the canvas

ejcanvas.getContext('2d').drawImage(ejxnewimg, 0, 0);

}

ejxnewimg.src = ejpasseddu;

}

setTimeout(ejmonitoru, 6000);

}

}




function ejuossc() {

if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } }

if (!ejuoss) {

setTimeout(ejmonitoru,6000);

ejorigpasseddu=ejcanvases[0].toDataURL('image/png');

ejpasseddu=ejorigpasseddu;

//ejuoss=window.open('//www.rjmprogramming.com.au/HTMLCSS/user_of_signature_signature.htm' + ejchash,'_blank','top=20,left=20,width=' + eval(0.9 * eval('' + screen.width)) + ',height=' + eval(0.8 * eval('' + screen.height)) + '');

ejuoss=window.open('/HTMLCSS/user_of_signature_signature.htm' + ejchash,'_blank','top=20,left=20,width=' + eval(0.9 * eval('' + screen.width)) + ',height=' + eval(0.8 * eval('' + screen.height)) + '');

} else {

ejuoss.focus();

}

}




function ejantiuossc() {

if (ejuoss) { if (ejuoss.closed) { ejuoss=null; } }

if (ejuoss) {

var ejznewimg=document.createElement('img');

ejznewimg.onload = function() {

// draw the image onto the canvas

ejcanvas.getContext('2d').drawImage(ejznewimg, 0, 0);

ejpasseddu=ejuoss.document.getElementById('topcanvas').toDataURL('image/png');

}

ejznewimg.src = ejorigpasseddu;

}

}



setTimeout(ejsetup, 3000);



Previous relevant Gimp Guillotine Image File Browse Windows Intranet Video Tutorial is shown below.

Gimp Guillotine Image File Browse Windows Intranet Video Tutorial

Gimp Guillotine Image File Browse Windows Intranet Video Tutorial

Yesterdayโ€™s Gimp Guillotine Image File Browse Windows MAMP Tutorial work was preceded with Gimp Guillotine Image File Browse Windows Client Tutorial by a slightly confusing โ€ฆ

the MAMP HTTP://localhost:8888/ $_SERVER[โ€˜DOCUMENT_ROOTโ€™] will not work on a Windows client, weโ€™ve decided, and so now test for a Window client scenario โ€ฆ

โ€ฆ ambiguous statement, todayโ€™s work would want to amend to โ€ฆ



the MAMP HTTP://localhost:8888/ $_SERVER['DOCUMENT_ROOT'] will not work on a Windows client, we've now decided, and so now test for a Window client called from a public RJM Programming domain URL, for the purposes of creating Video content scenario ...

So, back to yesterdayโ€™s premise, yes, with web applications, especially PHP ones, thereโ€™s a client side then thereโ€™s a server side to the web application, and today, we worry about a hybrid feeling โ€ฆ



Public RJM Programming domain URL call of a Windows MAMP incarnation, for the purposes of creating Video content, in a pretty seamless way to the Public RJM Programming domain URL (without that Public RJM Programming domain needing to have ffmpeg installed, but the Windows MAMP environment does)

โ€ฆ which we like to think of, at least in our mind, as โ€œIntranet Videoโ€, that you can see โ€œthe early days of this conceptโ€ information from Animated GIF Creator Video Intranet Tutorial.

What needs particular attention in this โ€œIntranet Video for Windows Clientโ€ scenario? Most obviously, it is MAMPโ€™s port (that 8888 on macOS or Mac OS X and 80 on Windows (and 80 being a default means no need for :[portNumber] syntax in URLs)).

The look and feel of code below gives you a feel for some โ€œsetting tweaking feelingโ€ PHP code, here โ€ฆ

<?php


$vend='/PHP/animegif/video.mov';

if (isMobile()) { $vend='/PHP/animegif/video.m4v'; }

$vmime='mp4';

$ronly="";

$thetemp="/tm" . "p/";

$theztemp=$thetemp;

$videopath="";

$immogpath="";

$fiext="";

if (!is_dir($thetemp) || strpos($thetemp, substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,0,1)) === false) {

$thetemp=str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, sys_get_temp_dir() . DIRECTORY_SEPARATOR);

$thetemp=str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, str_replace("C:","",$_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR);

$theztemp='C:' . str_replace('/', substr('\\',0,1), $thetemp);

$thetemp=str_replace(substr('\\',0,1),substr('\\',0,1) . substr('\\',0,1), substr($theztemp,2));

$fiext=".exe";

$videopath="C:\\PROGRA~1\\IMAGEM~1.0-Q\\";

$immogpath="C:\\PROGRA~1\\IMAGEM~1.0-Q\\";

}

$lportbit=":8888";



$impreexe="magick";

if (strpos($thetemp, '/') !== false) {

$impreexe="convert";

$immogpath='/usr/local/Cellar/imagemagick/7.1.0-10_1/bin/';

if (file_exists('/home/virtfs/rjmprogr/usr/local/cpanel/3rdparty/bin/mogrify')) {

$immogpath='/home/virtfs/rjmprogr/usr/local/cpanel/3rdparty/bin/';

} else if (file_exists('/usr/local/Cellar/imagemagick/7.1.0-10_1/bin/mogrify')) {

$sleept="";

$immogpath='/usr/local/Cellar/imagemagick/7.1.0-10_1/bin/';

} else if ('/usr/local/bin/mogrify') {

$immogpath='/usr/local/bin/';

}

}



if (strpos($thetemp, '/') !== false) {

$videopath="/usr/local/bin/";

if (file_exists('/usr/local/bin/ffmpeg')) {

$videopath="/usr/local/bin/";

}

}



$user_agent = $_SERVER["HTTP_USER_AGENT"];

function getOS() { // thanks to https://www.daniweb.com/programming/web-development/threads/495588/getting-users-os-info-out-of-server-http-user-agent

global $user_agent, $lportbit;

$os_platform = "win Unknown OS Platform";

$os_array = array(

'/windows nt 10/i' => 'Windows 10',

'/windows nt 6.3/i' => 'Windows 8.1',

'/windows nt 6.2/i' => 'Windows 8',

'/windows nt 6.1/i' => 'Windows 7',

'/windows nt 6.0/i' => 'Windows Vista',

'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',

'/windows nt 5.1/i' => 'Windows XP',

'/windows xp/i' => 'Windows XP',

'/windows nt 5.0/i' => 'Windows 2000',

'/windows me/i' => 'Windows ME',

'/win98/i' => 'Windows 98',

'/win95/i' => 'Windows 95',

'/win16/i' => 'Windows 3.11',

'/macintosh|mac os x/i' => 'Mac OS X',

'/mac_powerpc/i' => 'Mac OS 9',

'/linux/i' => 'Linux',

'/ubuntu/i' => 'Ubuntu',

'/iphone/i' => 'iPhone',

'/ipod/i' => 'iPod',

'/ipad/i' => 'iPad',

'/android/i' => 'Android',

'/blackberry/i' => 'BlackBerry',

'/webos/i' => 'Mobile'

);



foreach ($os_array as $regex => $value) {



if (preg_match($regex, $user_agent)) {

$os_platform = $value;

}



}



return $os_platform;

}



if (substr(strtoupper(getOS()),0,3) === 'WIN') { $lportbit=""; if (1 == 3) { $vend='/' . ggserver_remote_addr() . 'video.mov'; $vmime='webm'; } }


?>

โ€ฆ which ends up suiting (all of) โ€ฆ

  • Public Apache/PHP RJM Programming domain URL call using a macOS or Mac OS X client
  • Local Apache/PHP MAMP URL call using a macOS or Mac OS X client
  • Publicโœ‚Apache/PHP RJM Programming domain URL call using a Windows client
  • Local Apache/PHP MAMP URL call using a Windows client

โ€ฆ usages, todayโ€™s work embellishing the โ€œsmartsโ€ (possibly) of that third scenario above, adding โ€œIntranet Videoโ€ smarts, as long as you do not ask for too much input (file browsed) image data to become involved, for thischange to โ€œparentโ€ gimp_guillotine_followupโšซphpโ€˜s Gimpโœ‚Guillotine Follow Up PHP web application that is supervising the โ€œchildโ€ thechanged PHP Animated GIF creator tutorial_to_animated_gifโšซphp helper.

So letโ€™s revisit the MAMP environment installing inhouse Windows advice list โ€ฆ

  1. in that public RJM Programming mode of use above โ€ฆ but even better can be โ€ฆ
  2. download relevant code to macOS or Windows MAMP local web server places off /Applications/MAMP/htdocs/ or C:\MAMP\htdocs\ $_SERVER[โ€˜DOCUMENT_ROOTโ€™] places (Windows uses โ€œ\โ€ rather than โ€œ/โ€ below) โ€ฆ

    โ€ฆ and check the code for the validity of any ImageMagick paths โ€ฆ and if not all these conditions, simulate the same and cobble it together in the code

โ€ฆ teamed with gimp_guillotine_followupโšซphp to โ€œPHP/โ€


Previous relevant Gimp Guillotine Image File Browse Windows MAMP Tutorial is shown below.

Gimp Guillotine Image File Browse Windows MAMP Tutorial

Gimp Guillotine Image File Browse Windows MAMP Tutorial

As with many issues with web applications thereโ€™s the โ€ฆ

In addressing the Windows server side to the issues, we address, today, straight โ€œlocalhostโ€ URL ways of navigating to the โ€œGimp Guillotine Follow Upโ€ web application you might remember would be โ€ฆ

MAMP on macOS or Mac OS X โ€ฆ
HTTP://localhost:8888/PHP/gimp_guillotine_followup.php
MAMP on Windows โ€ฆ
HTTP://localhost/PHP/gimp_guillotine_followup.php

โ€ฆ the reason for issues primarily โ€ฆ

  • file delimitation is different
  • temporary file place changes ( and we ended up choosing $_SERVER[โ€˜DOCUMENT_ROOTโ€™] โ€ฆ C:\MAMP\htdocs\ )
  • ImageMagick setup is different, as are the command line switches and syntax
  • ffmpeg setup is different, as are the command line switches and syntax

โ€ฆ for thischange to โ€œparentโ€ gimp_guillotine_followupโšซphpโ€˜s Gimpโœ‚Guillotine Follow Up PHP web application that is supervising the โ€œchildโ€ thechanged PHP Animated GIF creator tutorial_to_animated_gifโšซphp helper.

Did you know?

We worked on this blog posting on a Windows 10 laptop initially with no ImageMagick nor ffmpeg installed. We were gobsmacked installing ImageMagick on this laptop that ffmpeg came packaged up in the install as well, and meant the path code below was the go โ€ฆ

<?php


$videopath="C:\\PROGRA~1\\IMAGEM~1.0-Q\\";

$immogpath="C:\\PROGRA~1\\IMAGEM~1.0-Q\\";


?>

Why the โ€œ8dot3โ€ (back to the really old days of DOS accessible via โ€œDIR /Xโ€) path representations? Well, it means the need for double quote worry is lessened in the code.

More on this tomorrow.


Previous relevant Gimp Guillotine Image File Browse Windows Client Tutorial is shown below.

Gimp Guillotine Image File Browse Windows Client Tutorial

Gimp Guillotine Image File Browse Windows Client Tutorial

Moving on from yesterdayโ€™s Gimp Guillotine Image File Browse Intranet Video Tutorialโ€˜s progress, today, we test the Gimp Guillotine Follow Up web application on some Windows web browsers, and fix issues not immediately apparent when your main testing platform is macOS or Mac OS X.

Some issues found were โ€ฆ

  • HTML iframe overflowing the nesting โ€œtdโ€ (table cell) element had scroll bars we did not enjoys, with Windows client web browsers โ€ฆ the fix being โ€ฆ


    <h4>Input Images</h4></td><td style='height:100px;overflow:auto;'><iframe id=ggif style='display:inline-block;height:100%;width:95px;' scrolling=no frameborder=0 src='/PHP/animegif/tutorial_to_animated_gif.php?huhv=y&calledbygg=" . $ru . "'></iframe></td></tr></table>

  • the MAMP HTTP://localhost:8888/ $_SERVER[โ€˜DOCUMENT_ROOTโ€™] will not work on a Windows client, weโ€™ve decided, and so now test for a Window client scenario โ€ฆ
    <?php


    $eeee="y";




    $user_agent = $_SERVER["HTTP_USER_AGENT"];

    function getOS() { // thanks to https://www.daniweb.com/programming/web-development/threads/495588/getting-users-os-info-out-of-server-http-user-agent

    global $user_agent;

    $os_platform = "win Unknown OS Platform";

    $os_array = array(

    '/windows nt 10/i' => 'Windows 10',

    '/windows nt 6.3/i' => 'Windows 8.1',

    '/windows nt 6.2/i' => 'Windows 8',

    '/windows nt 6.1/i' => 'Windows 7',

    '/windows nt 6.0/i' => 'Windows Vista',

    '/windows nt 5.2/i' => 'Windows Server 2003/XP x64',

    '/windows nt 5.1/i' => 'Windows XP',

    '/windows xp/i' => 'Windows XP',

    '/windows nt 5.0/i' => 'Windows 2000',

    '/windows me/i' => 'Windows ME',

    '/win98/i' => 'Windows 98',

    '/win95/i' => 'Windows 95',

    '/win16/i' => 'Windows 3.11',

    '/macintosh|mac os x/i' => 'Mac OS X',

    '/mac_powerpc/i' => 'Mac OS 9',

    '/linux/i' => 'Linux',

    '/ubuntu/i' => 'Ubuntu',

    '/iphone/i' => 'iPhone',

    '/ipod/i' => 'iPod',

    '/ipad/i' => 'iPad',

    '/android/i' => 'Android',

    '/blackberry/i' => 'BlackBerry',

    '/webos/i' => 'Mobile'

    );




    foreach ($os_array as $regex => $value) {




    if (preg_match($regex, $user_agent)) {

    $os_platform = $value;

    }




    }




    return $os_platform;

    }




    if (substr(strtoupper(getOS()),0,3) === 'WIN') { $eeee=""; }


    ?>
    โ€ฆ and switch off Intranet Video functionality if Windows, as a client, is detected โ€ฆ
    <?php echo โ€


    var evalcmd='';



    function imselset() {

    if (document.getElementById('imsel')) {

    if (document.getElementById('imsel').innerHTML.indexOf('video') != -1) {

    if (document.getElementById('imsel').value != 'video') {

    if (document.URL.indexOf('localhost') == -1) {

    evalcmd='" . $eeee . "'; // evalcmd='y';

    }

    } else {

    setTimeout(imselset, 1000);

    }

    } else {

    setTimeout(imselset, 1000);

    }

    } else {

    setTimeout(imselset, 1000);

    }

    }



    setTimeout(imselset, 1000);


    โ€œ; ?>

โ€ฆ and along the way we โ€ฆ

  • introduced a โ€œreadonlyโ€ attribute to the main textbox on a ?filespec=/tmp/ggblahblahblahtmp*.*&andgo=y scenario
  • stop Animated GIF image distortion, by removing height CSS styling

โ€ฆ for thischange to โ€œparentโ€ gimp_guillotine_followupโšซphpโ€˜s Gimpโœ‚Guillotine Follow Up PHP web application that is supervising the โ€œchildโ€ thechanged PHP Animated GIF creator tutorial_to_animated_gifโšซphp helper.


Previous relevant Gimp Guillotine Image File Browse Intranet Video Tutorial is shown below.

Gimp Guillotine Image File Browse Intranet Video Tutorial

Gimp Guillotine Image File Browse Intranet Video Tutorial

If you were paying uncompromising attention to yesterdayโ€™s Gimp Guillotine Image File Browse Animated GIF Tutorial you may have tweaked to and or piqued to โ€ฆ

slideshow, PDF, video (maybe)

โ€ฆ and then maybe even recalled a couple of things explained in Animated GIF Creator Video Intranet Tutorial (channelling Animated GIF Creator Video Revisit Tutorial) โ€ฆ

โ€ฆ one reason being that we do not want to install the wonderful ffmpeg (command line video creation tool) on the RJM Programming domain, but, in macOS, here with MAMP, we are quite happy to live with the Homebrew (Terminal applicationโ€™s) install โ€ฆ

โ€ฆ setting up what could be โ€œlost functionalityโ€, but today, we come around to either adding a new โ€ฆ



Convert to Video


โ€ฆ dropdown option should all be ritchy ditch, and if not, often we will add new โ€œAdviceโ€ dropdown options to remind the user what theyโ€™d need to arrange to get to a โ€œConvert to Videoโ€ scenario.

โ€ฆ all this referring to our current Gimp Guillotine Follow Up web application projectโ€™s Animated GIF Creator web application helper. So, why donโ€™t we give our Gimp Guillotine Follow Up web application aficionados who have installed a local Apache web server like MAMP (most likely on macOS or Mac OS X) and the wonderful ffmpeg command line the chance to turn (maybe) into (likely) (given small amounts of image data involved) via โ€œIntranetโ€ feeling methodologies?

In order to make thischange to โ€œparentโ€ gimp_guillotine_followupโšซphpโ€˜s Gimpโœ‚Guillotine Follow Up PHP web application that is supervising the โ€œchildโ€ thechanged PHP Animated GIF creator tutorial_to_animated_gifโšซphp we need to โ€ฆ

Have the public RJM Programming domain parent webโœ‚application call the (public RJM Programming domain) child in a slightly different way โ€ฆ


<h4>Input Images</h4></td><td style='height:100px;'><iframe id=ggif style='display:inline-block;height:100%;width:95px;' frameborder=0 src='/PHP/animegif/tutorial_to_animated_gif.php?huhv=y&calledbygg=" . $ru . "'></iframe></td></tr></table>

Have the child, then, look out for the tests that make the โ€œConvert to Videoโ€ dropdown โ€˜imselโ€™ option happen (only when Intranet suitable), and flag it (where function dolhsh is called at document.bodyโ€™s โ€œonloadโ€ event) โ€ฆ


var cbggis=location.search.split('called' + 'bygg=')[1] ? decodeURIComponent(location.search.split('called' + 'bygg=')[1]).split('&')[0] : '';

var evalcmd='';



function imselset() {

if (document.getElementById('imsel')) {

if (document.getElementById('imsel').innerHTML.indexOf('video') != -1) {

if (document.getElementById('imsel').value != 'video') {

if (document.URL.indexOf('localhost') == -1) {

evalcmd='y'; //document.getElementById('imsel').value='video';

}

} else {

setTimeout(imselset, 1000);

}

} else {

setTimeout(imselset, 1000);

}

} else {

setTimeout(imselset, 1000);

}

}



function dolhsh() {

if (cbggis != '' && documentURL.indexOf('huhv=') != -1) { setTimeout(imselset, 1000); }

// blah blah blah

}

And just before the work of yesterday arrange for a local Apache web server Javascript window.open window open with a local Apache web server incarnation of the child โ€ฆ


if (evalcmd.length != 0) {

document.getElementById('imsel').value='video';

imadd(document.getElementById('imsel'));

}


document.getElementById('delay').value='400';

document.getElementById('myform').target='zzlocit';

document.getElementById('mysubmit').click();


The video is, hopefully, created in that new local Apache web server windowโ€™s incarnation of the child, and just before we โ€œclobberโ€ the whole shebang with a new incarnation of the parent we flag its approach by introduction a new GET argument โ€˜andvgoโ€™ in its URL call โ€ฆ
<?php echo โ€


var andvgo='';

if (evalcmd.length != 0) {

andvgo='&andvgo=y';

}


top.location.href=cbggis.split('?')[0].split('#')[0] + '?filespec=/tmp/" . ggserver_remote_addr() . "tmp*.*&andgo=y' + andvgo;


โ€œ; ?>
And back at the newly minted parent we flag the existence of an Intranet video, as required (that $pdfabit variable used later to contribute to PHP writing out of webpage content)
<?php


if (isset($_POST['andgo'])) {

$pdfvb='';

$andtwotwo="<input name=andgo value=y type=hidden></input>";

if (isset($_POST['andvgo'])) {

$andtwotwo.="<input name=andvgo value=y type=hidden></input>"; // remembered through the navigations because used later to contribute to PHP writing out of webpage content

}


$andoneone=" && 1 == 3";

if (file_exists('/tmp/' . ggserver_remote_addr() . 'pdftmp.pdf')) {

$adatam="";

$pdfabit='<br> or <details onclick="document.getElementById(' . "'" . 'aobjpdf' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(255,0,0,0.2);><a target=objpdf id=aobjpdf style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=pdf>PDF (all original slides)</a></summary><br><iframe name=objpdf id=objpdf style="width:100%;height:900px;" data-type="application/pdf" srcdoc="<embed data-type=application/pdf style=width:100%;height:900px; src=data:application/pdf;base64,' . base64_encode(file_get_contents('/tmp/' . ggserver_remote_addr() . 'pdftmp.pdf')) . '></embed>"></iframe></details>';

}

if (file_exists('/tmp/' . ggserver_remote_addr() . 'video.mov')) {

$pdfabit.='<br> or <details onclick="document.getElementById(' . "'" . 'aobjvideo' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);><a target=objvideo id=aobjvideo style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=video>Video (all original slides)</a></summary><br><iframe name=objvideo id=objvideo style="width:100%;height:900px;" data-type="video/mp4" srcdoc="<video type=video/mp4 style=width:100%;height:900px;><source type=video/mp4 src=data:video/mp4;base64,' . base64_encode(file_get_contents('/tmp/' . ggserver_remote_addr() . 'video.mov')) . '></source></video>"></iframe></details>';

} else if (isset($_POST['andvgo'])) {

$pdfvb='<div id=divlocalvideo style=display:block;> or <details style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);>Video (all original slides shows in another local web server window as well)</summary><video controls><source type=video/mp4 src=HTTP://localhost:8888/PHP/animegif/video.mov></source></video></details></div>';

} else {

$pdfvb='<div id=divlocalvideo style=display:none;> or <details style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);>Video (all original slides shows in another local web server window as well)</summary><video controls><source type=video/mp4 src=HTTP://localhost:8888/PHP/animegif/video.mov></source></video></details></div>';

}

if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'PHP' . DIRECTORY_SEPARATOR . 'animegif' . DIRECTORY_SEPARATOR . server_remote_addr() . '.gif')) {

$pdfabit.='<br> or <details onclick="document.getElementById(' . "'" . 'aobjgif' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(0,255,0,0.2);><a target=objgif id=aobjgif style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=gif>Animated GIF (all original slides)</a></summary><br><iframe name=objgif id=objgif style="width:100%;height:900px;" data-type="gif/mp4" srcdoc="<img type=image/gif style=width:100%;height:900px; src=data:image/gif;base64,' . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'PHP' . DIRECTORY_SEPARATOR . 'animegif' . DIRECTORY_SEPARATOR . server_remote_addr() . '.gif')) . '></img>"></iframe></details>';

}

$pdfabit.=$pdfvb;

} else if (isset($_GET['andgo'])) {

$pdfvb='';

$andoneone=" && 1 == 1";

$andtwotwo="<input name=andgo value=y type=hidden></input>";

if (isset($_GET['andvgo'])) {

$andtwotwo.="<input name=andvgo value=y type=hidden></input>"; // remembered through the navigations because used later to contribute to PHP writing out of webpage content

}


if (file_exists('/tmp/' . ggserver_remote_addr() . 'pdftmp.pdf')) {

$adatam="";

$pdfabit='<br> or <details onclick="document.getElementById(' . "'" . 'aobjpdf' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(255,0,0,0.2);><a target=objpdf id=aobjpdf style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=pdf>PDF (all original slides)</a></summary><br><iframe name=objpdf id=objpdf style="width:100%;height:900px;" data-type="application/pdf" srcdoc="<embed data-type=application/pdf style=width:100%;height:900px; src=data:application/pdf;base64,' . base64_encode(file_get_contents('/tmp/' . ggserver_remote_addr() . 'pdftmp.pdf')) . '></embed>"></iframe></details>';

}

if (file_exists('/tmp/' . ggserver_remote_addr() . 'video.mov')) {

$pdfabit.='<br> or <details onclick="document.getElementById(' . "'" . 'aobjvideo' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);><a target=objvideo id=aobjvideo style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=video>Video (all original slides)</a></summary><br><iframe name=objvideo id=objvideo style="width:100%;height:900px;" data-type="video/mp4" srcdoc="<video type=video/mp4 style=width:100%;height:900px;><source type=video/mp4 src=data:video/mp4;base64,' . base64_encode(file_get_contents('/tmp/' . ggserver_remote_addr() . 'video.mov')) . '></source></video>"></iframe></details>';

} else if (isset($_GET['andvgo'])) {

$pdfvb='<div id=divlocalvideo style=display:block;> or <details style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);>Video (all original slides shows in another local web server window as well)</summary><video controls><source type=video/mp4 src=HTTP://localhost:8888/PHP/animegif/video.mov></source></video></details></div>';

} else {

$pdfvb='<div id=divlocalvideo style=display:none;> or <details style=display:inline-block;width:95%;><summary style=background-color:rgba(255,255,0,0.2);>Video (all original slides shows in another local web server window as well)</summary><video controls><source type=video/mp4 src=HTTP://localhost:8888/PHP/animegif/video.mov></source></video></details></div>';

}

if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'PHP' . DIRECTORY_SEPARATOR . 'animegif' . DIRECTORY_SEPARATOR . server_remote_addr() . '.gif')) {

$pdfabit.='<br> or <details onclick="document.getElementById(' . "'" . 'aobjgif' . "'" . ').click();" style=display:inline-block;width:95%;><summary style=background-color:rgba(0,255,0,0.2);><a target=objgif id=aobjgif style=text-decoration:none; href=./gimp_guillotine_followup.php?getme=gif>Animated GIF (all original slides)</a></summary><br><iframe name=objgif id=objgif style="width:100%;height:900px;" data-type="gif/mp4" srcdoc="<img type=image/gif style=width:100%;height:900px; src=data:image/gif;base64,' . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'PHP' . DIRECTORY_SEPARATOR . 'animegif' . DIRECTORY_SEPARATOR . server_remote_addr() . '.gif')) . '></img>"></iframe></details>';

}

$pdfabit.=$pdfvb;

}


?>

โ€ฆ trying to help create a couple more woooooorrrrrrllllldddd videos!


Previous relevant Gimp Guillotine Image File Browse Animated GIF Tutorial is shown below.

Gimp Guillotine Image File Browse Animated GIF Tutorial

Gimp Guillotine Image File Browse Animated GIF Tutorial

Onto yesterdayโ€™s Gimp Guillotine Image File Browse Media Tutorial media functionality additions of โ€ฆ

  • slideshow, PDF, video (maybe) โ€ฆ today we wanted to add โ€ฆ
  • animated GIF

โ€ฆ into the mix. Considering ourchanged gimp_guillotine_followupโšซphp Gimpโœ‚Guillotine Follow Up PHP web application is supervising ourchanged PHP Animated GIF creator tutorial_to_animated_gifโšซphp, how hard can that be? In our defence, it took us a day to get around how to have that โ€ฆ



top.location.href=cbggis.split('?')[0].split('#')[0] + '?filespec=/tmp/" . ggserver_remote_addr() . "tmp*.*&andgo=y';

โ€ฆ Javascript codeline not put a stop to our ambition, clobbering any further inhouse work that the child PHP Animated GIF Creator web application does creating any animated GIFs (which navigates away in order to do this). But the (albeit pretty obvious, but neat) idea did finally dawn on us, enabling us to have our cake and eat it too, several seconds ahead of the execution of the Javascript codeline above, timing โ€ฆ



document.getElementById('myform').target='zzlocit';

document.getElementById('mysubmit').click();

โ€ฆ to be setting the navigation target to be a PHP helper webpage existent iframe element named โ€˜zzlocitโ€™ be mapped to the formโ€™s target attribute and clicking that formโ€™s submit button programmatically to create the required animated GIF before we navigate away (with no clobbering or other ancillary violence).

Along the way, we personalized, via a userโ€™s IP address and web browser type, the names of media files so that it is less likely any user will clobber any other userโ€™s work, nor see work of another user, when using the web application.


Previous relevant Gimp Guillotine Image File Browse Media Tutorial is shown below.

Gimp Guillotine Image File Browse Media Tutorial

Gimp Guillotine Image File Browse Media Tutorial

Yesterdayโ€™s Gimp Guillotine Image File Browse Tutorial introduced file browsing, of local files, as an input data possibility with our inhouse Gimp Guillotine Follow Up web application.

That opens the door to other media output possibilities, those being, at least for today โ€ฆ

It can be hard achieving cross-domain PDF presentations in the โ€œclient onlyโ€ wooooooooorrrrrrrllllllllldddd, so we took advantage of the PHP โ€œserverโ€ woooooooooorrrrrrrrlllllllllldddddโ€™s โ€ฆ

<?php


if (isset($_POST['getme'])) {

if (file_exists('/tmp/ggpdftmp.pdf') && $_POST['getme'] == 'pdf') {

header("Content-type:application/pdf");

echo file_get_contents('/tmp/ggpdftmp.pdf');


}

if (file_exists('/tmp/ggvideo.mov') && $_POST['getme'] == 'video') {

echo '<html><body><video style=width:100%;height:900px; type=video/mp4 controls><source type=video/mp4 src=data:video/mp4;base64,' . base64_encode(file_get_contents('/tmp/ggvideo.mov')) . '></source></video></body></html>';

}

exit;

} else if (isset($_GET['getme'])) {

if (file_exists('/tmp/ggpdftmp.pdf') && $_GET['getme'] == 'pdf') {

header("Content-type:application/pdf");

echo file_get_contents('/tmp/ggpdftmp.pdf');


}

if (file_exists('/tmp/ggvideo.mov') && $_GET['getme'] == 'video') {

echo '<html><body><video style=width:100%;height:900px; type=video/mp4 controls><source type=video/mp4 src=data:video/mp4;base64,' . base64_encode(file_get_contents('/tmp/ggvideo.mov')) . '></source></video></body></html>';

}

exit;

}


?>

โ€ฆ approach, getting better results cross-domain.

Yes, letโ€™s face it, and letโ€™s narrow it down, without code changes, to macOS or Mac OS X or Linux or Unix operating system underpinnings, given the /tmp/ hardcodings we have going, so far, is the environment best suited to this code.


Previous relevant Gimp Guillotine Image File Browse Tutorial is shown below.

Gimp Guillotine Image File Browse Tutorial

Gimp Guillotine Image File Browse Tutorial

The input data arrangements for our inhouse โ€œGimp Guillotine Followupโ€ PHP web application of Gimp Guillotine Marquee Placeholder Tutorial involved โ€ฆ

  • relative or absolute image URL(s) โ€ฆ pretty unwieldy and not inviting for so many users โ€ฆ but today we extend functionality and allow for โ€ฆ
  • image file browsing โ€ฆ via the wonderful File API (though all that is more or less set in stone as distinct from the integrations to get to use it)

You are presented with a new browse button, from which you can select image files that ourchanged gimp_guillotine_followupโšซphp PHPโœ‚Gimp Followup web application which will now integrate with thechanged tutorial_to_animated_gifโšซphp inhouse PHP Animated GIF Creator web application to achieve our aims (where $ru=urlencode(explode(โ€˜#โ€™, explode(โ€˜?โ€™, $_SERVER[โ€˜REQUEST_URIโ€™])[0])[0]); // in work below) โ€ฆ



<table><tr><td>

<h3>RJM Programming - August, 2018</h3>" . $erroris . "

<h4>Input Images</h4></td><td style='height:100px;'><iframe id=ggif style='display:inline-block;height:100%;width:95px;' frameborder=0 src='/PHP/animegif/tutorial_to_animated_gif.php?calledbygg=" . $ru . "'></iframe></td></tr></table>

โ€ฆ that โ€œcalledbyggโ€ used extensively by the Javascript and PHP logic in the PHP Animated GIF Creator web application integrations.

Of interest, too, regarding the data storage arrangements for these integrations โ€ฆ.

  • we use /tmp/ folders to store ggtmp*.* image files โ€ฆ and so โ€ฆ
  • we set up the scenario where GET argument URLs containing โ€ฆ
    HTTP://www.rjmprogramming.com.au/PHP/gimp_guillotine_followup.php?filespec=/tmp/ggtmp*.*&andgo=y
    โ€ฆ for PHPโœ‚Gimp Followup web application usage can be called by the Animated GIF Creator child to climb back up to the web browser address bar for a restart, once the /tmp/ files are created and in place โ€ฆ
  • data URIs are used to get back to HTML img โ€œsrcโ€ attribute friendliness/universality via PHPโœ‚Gimp Followup web applicationโ€˜s PHP โ€ฆ
    <?php


    function datauriit($infn) {

    if (strpos(("~" . $infn), "~/tmp/") !== false) {

    if (file_exists($infn)) {

    return 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $infn)[-1 + sizeof(explode(".", $infn))])) . ';base64,' . base64_encode(file_get_contents($infn));

    }

    }

    return $infn;

    }


    ?>
  • Ajax/FormData โ€œmidairโ€ feeling โ€œself-callingโ€ is used to create the /tmp/ files via PHP Animated GIF Creator web applicationโ€™s PHP โ€ฆ
    <?php


    if (isset($_POST['justuntmpthis']) && !isset($_POST['justtmpthis'])) {

    $fsuff=1;

    $ffsuff=1;

    while ($ffsuff == $fsuff) {

    $ffsuff++;

    foreach (glob('/tmp/ggtmp' . $fsuff . '.*') as $ggfilename) {

    unlink($ggfilename);

    $fsuff=$ffsuff;

    }

    }

    exit;

    }



    if (isset($_POST['justtmpthis'])) {

    if (isset($_POST['justuntmpthis'])) {

    $fsuff=1;

    $ffsuff=1;

    while ($ffsuff == $fsuff) {

    $ffsuff++;

    foreach (glob('/tmp/ggtmp' . $fsuff . '.*') as $ggfilename) {

    unlink($ggfilename);

    $fsuff=$ffsuff;

    }

    }

    }

    $fsuff=1;

    $ffsuff=1;

    while ($ffsuff == $fsuff) {

    $ffsuff++;

    foreach (glob('/tmp/ggtmp' . $fsuff . '.*') as $ggfilename) {

    $fsuff=$ffsuff;

    }

    }

    $datain=str_replace(' ','+',urldecode($_POST['justtmpthis']));

    if (strpos($datain, 'data:') !== false) {

    file_put_contents('/tmp/ggtmp' . $fsuff . '.' . explode(';',explode('/', $datain )[1])[0], base64_decode(explode(';base64,', $datain )[1] ));

    } else if (strpos(strtolower($datain), 'http') !== false) {

    file_put_contents('/tmp/ggtmp' . $fsuff . '.' . explode('#',explode('?',explode('.', $datain)[-1 + sizeof(explode('.', $datain))])[0])[0], file_get_contents($datain));

    } else if (trim($datain) != '') {

    copy($datain, '/tmp/ggtmp' . $fsuff . '.' . explode('#',explode('?',explode('.', $datain)[-1 + sizeof(explode('.', $datain))])[0])[0]);

    }

    exit;

    }



    $cbgg=" align='center'>Tutorial Slideshow to Animated GIF ";

    $cbor=" ... or ... ";

    if (isset($_GET['calledbygg'])) { $cbgg=">"; $cbor=""; }


    ?>
    โ€ฆ and Javascript โ€ฆ
    <?php echo โ€


    var cbggis=location.search.split('called' + 'bygg=')[1] ? decodeURIComponent(location.search.split('called' + 'bygg=')[1]).split('&')[0] : '';

    var ggvals=[], ggvalssuffix='', ggvalslen=0, ggvalgoes=0;



    function maybeggmore() { //tval, tid, tis) {

    if (document.URL.indexOf('calledbygg=') != -1 && document.getElementById('slideshow' + ggvalssuffix).value.indexOf('data:') == 0 && ggvals.length == ggvalslen) {

    ggvals.push(document.getElementById('slideshow' + ggvalssuffix).value);

    if (ggvalssuffix == '') { ggvalssuffix='2'; } else { ggvalssuffix='' + eval(1 + eval('' + ggvalssuffix)); }

    //alert(ggvals[ggvalslen]); //tval + ' ' + tid + ' ' + tis.id);

    ggvalslen=eval('' + ggvals.length);

    ggvalgoes=0;

    iizhr = new XMLHttpRequest();

    iizform=new FormData();

    if (ggvalslen == 1) {

    iizform.append('justuntmpthis', 'y');

    if (parent.document.getElementById('ggif')) {

    parent.document.body.style.cursor='progress';

    }

    }

    iizform.append('justtmpthis', ggvals[eval(-1 + ggvalslen)]);

    iizhr.open('post', './tutorial_to_animated_gif.php?xxx=' + Math.floor(Math.random() * 198756432), true);

    iizhr.send(iizform);

    setTimeout(maybeggmore, 5000);

    } else if (document.URL.indexOf('calledbygg=') != -1 && document.getElementById('slideshow' + ggvalssuffix).value.toLowerCase().indexOf('http') == 0 && ggvals.length == ggvalslen) {

    ggvals.push(document.getElementById('slideshow' + ggvalssuffix).value);

    if (ggvalssuffix == '') { ggvalssuffix='2'; } else { ggvalssuffix='' + eval(1 + eval('' + ggvalssuffix)); }

    ggvalgoes=0;

    //alert('2:' + ggvals[ggvalslen]); //tval + ' ' + tid + ' ' + tis.id);

    ggvalslen=eval('' + ggvals.length);

    iizhr = new XMLHttpRequest();

    iizform=new FormData();

    if (ggvalslen == 1) {

    iizform.append('justuntmpthis', 'y');

    if (parent.document.getElementById('ggif')) {

    parent.document.body.style.cursor='progress';

    }

    }

    iizform.append('justtmpthis', ggvals[eval(-1 + ggvalslen)]);

    iizhr.open('post', './tutorial_to_animated_gif.php?xxx=' + Math.floor(Math.random() * 198756432), true);

    iizhr.send(iizform);

    setTimeout(maybeggmore, 5000);

    } else if (ggvalgoes >= 12 && ggvalslen > 0) {

    top.location.href=cbggis.split('?')[0].split('#')[0] + '?filespec=/tmp/ggtmp*.*&andgo=y';

    } else {

    ggvalgoes++;

    setTimeout(maybeggmore, 5000);

    }

    }



    if (document.URL.indexOf('calledbygg') != -1) { setTimeout(maybeggmore, 5000); }


    โ€œ; ?>

โ€ฆ along the way setting the callerโ€™s parent.document.body.style.cursor=โ€™progressโ€™; so as to forewarn the user the process may take some time.


Previous relevant Gimp Guillotine Marquee Placeholder Tutorial is shown below.

Gimp Guillotine Marquee Placeholder Tutorial

Gimp Guillotine Marquee Placeholder Tutorial

The recent โ€œMarquee Placeholderโ€ ideas have hit a โ€œusefulnessโ€ mark, involving it with the โ€œGimp Guillotine Followupโ€ web application of Gimp Guillotine Local Datetime Token Subject Tutorial.

This โ€œMarquee Placeholderโ€ packs a puch, and over mobile platforms too, as an explainer of a โ€œwordyโ€ requirement. And the โ€œGimp Guillotine Followupโ€ web applicationโ€™s use of its major textbox is quite an involved thaing, because it is asking you to conjoin โ€ฆ

  • a desktop applicationโ€™s (ie. Gimpโ€™s) output โ€ฆ to โ€ฆ
  • an online โ€œGimp Guillotine Followupโ€ web applicationโ€™s input

โ€ฆ all feasible and possible via โ€œURL definitionโ€ or โ€œupload, then downloadโ€ methodologies. Onto previous textbox blurb (within the placeholder attribute) here we add (ie. prefix) โ€ฆ

Our suggestion here is ./mondrian-*.*g*

โ€ฆ because we now feel we can, as it is probable an interested user will want to get the most out of thechanged gimp_guillotine_followupโšซphp that you can try out at this liveโœ‚run link.

To add in the โ€œMarquee Placeholderโ€ we add Javascripting โ€œon the flyโ€ because we donโ€™t want any mixing of code with email attachment HTML, as per, within document.body โ€œonloadโ€ event logic โ€ฆ



var tag = document.createElement('script');

tag.type='text/javascript';

tag.src='/marquee_placeholder.js';

document.head.appendChild(tag);

Cute, huh?!

Stop Press

We found improvement performances โ€œthrottling downโ€ thechanged external Javascript marquee_placeholderโšซjsโ€˜s involvement once the textbox value is being actively entered by the user.


Previous relevant Gimp Guillotine Local Datetime Token Subject Tutorial is shown below.

Gimp Guillotine Local Datetime Token Subject Tutorial

Gimp Guillotine Local Datetime Token Subject Tutorial

Letโ€™s combine work of โ€ฆ

โ€ฆ to try to honour the โ€œtest guinea pigโ€ with a bit of combing, and a colour tint for winter.

The integrationโ€™s โ€œgenericity driveโ€ (feeling a bit more โ€œnext cab off the rankโ€ than โ€œgenericization starโ€) is that much more difficult because there is no โ€œonloadโ€ event โ€œimmediate answerโ€ feel to this โ€œIntlโ€ object client side Javascript work. For the first time we can recall we needed to combine โ€ฆ

  • HTML iframe โ€œonloadโ€ event function โ€ฆ containing a โ€ฆ
  • setTimeout based โ€œrelookโ€ at that iframeโ€™s content that little bit later on

โ€ฆ as per โ€ฆ



function postglt() {

var iois=document.getElementById('ifintl');

var fabih='', ewi=0, tzs='';

if (aconto) {

if (iois != null) {

aconto = (iois.contentWindow || iois.contentDocument);

if (aconto != null) {

if (aconto.document) { aconto = aconto.document; }

acontobih=aconto.body.innerHTML;

fabih=acontobih;

if (acontobih.trim().indexOf('var options') != -1) {

eval("options" + acontobih.split('var options')[1].split('<')[0].split(';')[0]);

if (elsewise) { // via div intldiv

if (acontobih.trim().indexOf('<b>') != -1) {

eval("lcode='" + acontobih.split('<b>')[1].split('<')[0] + "';");

//alert("lcode='" + acontobih.split('<b>')[1].split('<')[0] + "';");

d = new Date();

timedatenow = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());

localdatetime = new Intl.DateTimeFormat(lcode, options).format;

//document.title=localdatetime(timedatenow);

if (aconto.getElementById('ejc1').innerHTML) {

if (aconto.getElementById('ejc1').innerHTML.indexOf('timeZone:') != -1) {

tzs=' (' + aconto.getElementById('ejc1').innerHTML.split('timeZone:')[eval(-1 + aconto.getElementById('ejc1').innerHTML.split('timeZone:').length)].split('"')[1].split('"')[0] + ')';

if (tzs.replace(' (UTC)','') == '') { tzs=goodtzs; }

if (window.parent) {

if (document.URL.indexOf('inlineldt') == -1 && document.URL.indexOf('?') != -1 && (document.URL.indexOf('%40') != -1 || document.URL.indexOf('@') != -1)) {

//location.href=document.URL.replace('?', '?inlineldt=' + encodeURIComponent(localdatetime(timedatenow) + tzs.replace(' (UTC)','')) + '&');

document.body.innerHTML+="<iframe style=display:none; src='" + document.URL.replace('?', '?inlineldt=' + encodeURIComponent(localdatetime(timedatenow) + tzs.replace(' (UTC)','')) + '&') + "'></iframe>";

return false;

}

}

}

}

var theforms=document.getElementsByTagName('form');

for (var iiforms=0; iiforms<theforms.length; iiforms++) {

if (theforms[iiforms].innerHTML.indexOf('inlineldt') == -1) {

elsewisea.push('' + Math.floor(Math.random() * 178654));

theforms[iiforms].innerHTML+='<input type=hidden id=inlineldt' + elsewisea[eval(-1 + elsewisea.length)] + ' name=inlineldt value="' + localdatetime(timedatenow) + tzs.replace(' (UTC)','') + '"></input>';

} else {

document.getElementById('inlineldt' + elsewisea[ewi]).value=localdatetime(timedatenow) + tzs.replace(' (UTC)','');

ewi++;

}

}

}

}

} else {

fabih='';

}

if (acontobih.trim().indexOf('<b>') != -1) {

eval("lcode='" + acontobih.split('<b>')[1].split('<')[0] + "';");

} else {

fabih='';

}

acontobih=fabih;

}

}

}

}



function glt(iois) {

var fabih='', ewi=0, tzs='';

if (!aconto) {

if (iois != null) {

aconto = (iois.contentWindow || iois.contentDocument);

if (aconto != null) {

if (aconto.document) { aconto = aconto.document; }

acontobih=aconto.body.innerHTML;

fabih=acontobih;

if (acontobih.trim().indexOf('var options') != -1) {

eval("options" + acontobih.split('var options')[1].split('<')[0].split(';')[0]);

if (elsewise) { // via div intldiv

if (acontobih.trim().indexOf('<b>') != -1) {

eval("lcode='" + acontobih.split('<b>')[1].split('<')[0] + "';");

d = new Date();

timedatenow = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());

localdatetime = new Intl.DateTimeFormat(lcode, options).format;

if (aconto.getElementById('ejc1').innerHTML) {

if (aconto.getElementById('ejc1').innerHTML.indexOf('timeZone:') != -1) {

tzs=' (' + aconto.getElementById('ejc1').innerHTML.split('timeZone:')[eval(-1 + aconto.getElementById('ejc1').innerHTML.split('timeZone:').length)].split('"')[1].split('"')[0] + ')';

goodtzs=tzs.replace(' (UTC)','');

}

}

var theforms=document.getElementsByTagName('form');

for (var iiforms=0; iiforms<theforms.length; iiforms++) {

if (theforms[iiforms].innerHTML.indexOf('inlineldt') == -1) {

elsewisea.push('' + Math.floor(Math.random() * 178654));

theforms[iiforms].innerHTML+='<input type=hidden id=inlineldt' + elsewisea[eval(-1 + elsewisea.length)] + ' name=inlineldt value="' + localdatetime(timedatenow) + tzs.replace(' (UTC)','') + '"></input>';

} else {

document.getElementById('inlineldt' + elsewisea[ewi]).value=localdatetime(timedatenow) + tzs.replace(' (UTC)','');

ewi++;

}

}

}

setTimeout(postglt, 3000);

}

} else {

fabih='';

}

if (acontobih.trim().indexOf('<b>') != -1) {

eval("lcode='" + acontobih.split('<b>')[1].split('<')[0] + "';");

} else {

fabih='';

}

acontobih=fabih;

}

}

}

}

And so we continue on with other scenarios here. Here is โ€ฆ


Previous relevant Colour Systems Localized Internationalized Date Emails Tutorial is shown below.

Colour Systems Inline HTML Email Collaboration Tutorial

Colour Systems Localized Internationalized Date Emails Tutorial

Huh?! Whatโ€™s with โ€œLocalized Internationalizedโ€ in todayโ€™s tutorial title?

Well, weโ€™ve been miffed for a couple of days now putting up with our โ€œdate token email subjectโ€ parts to our emails showing a web server (location) based timestamp. Our web server at RJM Programming, hosted by the wonderful Crazy Domains is located on the other side of our country (as well as our continent), Australia in a timezone called โ€œAustralia/Perthโ€. And as much as we admire Perth, and have to โ€œgirt the loinsโ€ (you might say โ€œmore than somewhatโ€) when Collingwood takes on West Coast in the AFL, when it comes to timezone relevance for us here in Sydney, the subtraction of two or three hours (depending on daylight saving) is all too much for me. So, what to do? There is the quandary โ€ฆ

  • to arrange the inline HTML emails you need a serverside language such as PHP โ€ฆ yet โ€ฆ
  • to obtain a โ€œlocalโ€ timestamp you need Javascript (at the โ€œclientโ€)

โ€ฆ and so, though there are clunky things you can do at the PHP end the more straightforward and less confusing approach is to get between โ€ฆ

  • the existant Ajax/FormData techniques of sending a FormData object to โ€ฆ
  • our PHP email creator

โ€ฆ and make a dual purpose arrangement for our FormData โ€œinlineโ€ (think of it as a โ€œtextbox in midairโ€) that if it contains a โ€ฆ

  • string that contains a โ€œ:โ€ semicolon โ€ฆ and contains โ€ฆ
  • less than or equal to 5 words (space delimited)

โ€ฆ weโ€™re going to say that the parent (HTML/Javascript) has thus indicated to the (hard working duck paddling hard under the water) child (PHP email creator) that the content of the โ€œinlineโ€ โ€œtextbox in midairโ€ is a better timestamp to use for โ€œ[date]โ€ subject token substitutions than any server timestamp.

Thatโ€™s โ€œLocalizedโ€ covered, but whatโ€™s โ€œInternationalizedโ€ about this? Well, at the Javascript (client) end, you may recall how weโ€™ve investigated the great โ€œIntlโ€ object possibilities for Date and Number and Currency Internationalization thoughts (at the client side) when we presented Javascript Internationalization Resolved Options Tutorial. Well, we feel some integration coming on. This previously standalone (top.document thinking) web application needed to be adapted to be useful as a โ€œchild iframeโ€ one as well (ie. integrate but keep all existant top.document thinking to work as before). This is a bit of work to get going, but by the end, we had this integration changing โ€œdate token [date] in subject lineโ€ of emails creating timestamps like โ€ฆ

Localized Internationalized Date Timestamp (at client Javascript) Web Server Timestamp (at server PHP)
01/06/2020, 07:56 pm AEST (Australia/Sydney) Monday 1st of June 2020 11:50:24 AM

โ€ฆ a clarity and relevance improvement (to the email subject line) am sure youโ€™d agree. Though itโ€™s clearly not there yet, we saw this integration as a โ€œtest guinea pigโ€ going onto โ€œgenericization afterwardsโ€ case, and so hived off a lot of these changes to a new โ€ฆ

Believe it or not, another job improving on yesterdayโ€™s Colour Systems Inline HTML Email Collaboration Tutorial that took equally as long was figuring out what to do about the HSL Hue unit of measureโ€™s symbol ยฐ for the Apple Mail macOS application email client, where all the encoding combinations we could think of caused a spurious โ€œAโ€ (but gobbledygooky) type of character to preceed the ยฐ to look annoyingly like Aยฐ โ€ฆ ugh! It took a long time to nut out, but eventually we tweaked to โ€ฆ

  • for all the web browser usage incarnations just show the degree symbol via HTML โ€ฆ


    <span id="ds" title="Degrees">&#176;</span>

  • but then on its way to the email clients map that via the relevant Javascript DOM โ€ฆ


    document.getElementById('htmlis').innerHTML='<body>' + document.body.innerHTML.split('<ifr' + 'ame')[0].replace(document.getElementById('ds').outerHTML, "<div title=Degrees style='display:inline-block;max-width:6px;width:6px;max-height:10px;height:10px;overflow:hidden;'><span title=Degrees style='float:right;text-align:right;transform:scaleX(1);'>" + String.fromHtmlEntities(String.fromCodePoint(176)) + "</span></div>"); // many other replace clauses have been left out for clarity purposes


    โ€ฆ to end up with the email client โ€œShow originalโ€ view (of the inline HTML of email) as โ€ฆ


    <div title=Degrees style='display:inline-block;max-width:6px;width:6px;max-height:10px;height:10px;overflow:hidden;'><span title=Degrees style='float:right;text-align:right;transform:scaleX(1);'>ยฐ</span></div>


    โ€ฆ effectively asking good olโ€™ CSS to cover up for our Javascript pickle

Intrigued by โ€œtransform:scaleX(1)โ€? Yes, we experimented with flip โ€œtransform:scaleX(-1)โ€ and flop โ€œtransform:scaleY(-1)โ€ at various stages, but did not seem to need these in the end. But the degree (ยฐ) symbol being that โ€œeven handedโ€ character, we can flip it and flop it, and it remains its old self โ€ฆ if only we had three of them โ€ฆ oh! fancy that?!

We also added any Feedback or Comments into the email subject line, as well as in the โ€œinline HTMLโ€ body section of the email.


Previous relevant Colour Systems Inline HTML Email Collaboration Tutorial is shown below.

Colour Systems Inline HTML Email Collaboration Tutorial

Colour Systems Inline HTML Email Collaboration Tutorial

Yesterdayโ€™s Colour Systems Inline HTML Email Tutorial featured Inline HTML Email functionality, that we find very useful, but almost denuded of personalization. We think adding personalization aspects to a web application should never be mandatory to its functionality, but on the flipside, if you want a web application with โ€œcollaborationโ€ thoughts we figure for โ€ฆ

  • the scenario that the rjmprogramming.com.au mail server serves as an โ€œhonest brokerโ€ between โ€ฆ
  • an emailee (as we established yesterday) โ€ฆ and โ€ฆ
  • an emailer (we allow the user to define (and so not have to bother the users again regarding email addresses), optionally, starting today) โ€ฆ teamed with โ€ฆ
  • a comment or feedback textbox (new today), to add some personalization, into the colour discussion and collaboration and sharing experience (โ€ฆ whatโ€™s come over me!)

โ€ฆ meaning, though, that collaboration can occur between collaborators through (straight at your face content) email.

Today, also, weโ€™ve added another HSL (Hue/Saturation/Lightness) Colour System, and would like to thank this useful link regarding the formulae needed to make this happen.

Try collaboration via thechanged cmyk_rgbโšซhtml liveโœ‚run link yourself, and with a colourful friend!


Previous relevant Colour Systems Inline HTML Email Tutorial is shown below.

Colour Systems Inline HTML Email Tutorial

Colour Systems Inline HTML Email Tutorial

In undertaking the makeover for the Colour Systems web application of Colour Systems Primer Tutorial we were integrating Inline HTML Email functionality via Ajax/FormData techniques (entrenched as a favourite โ€œmidairโ€ feeling email conduit approach) when we were surprised trying something that we did not expect to work. We have intimated that as far as email clients go it is touch and go whether much HTML5 works nor CSS3 when you try to get something going, so when we tried integrating โ€ฆ

  • inline HTML email โ€ฆ with โ€ฆ
  • HTML input type=โ€colorโ€ as per โ€ฆ


    <input onchange="findc(this.value);" style='display:INLINE-BLOCK;' type="color" name="cinput" id="cinput" value="#000000"></input>

โ€ฆ we were really expecting โ€œtears before bedtimeโ€ rather than an approach using the HTML input type=โ€colorโ€ element above that really made it good at the emailee end, in particular, as we โ€ฆ

  • have an emailer startโœ‚the ball rolling (with thechanged cmyk_rgbโšซhtml) at this link โ€ฆ then โ€ฆ
  • set up a colour of interest via any of the following approaches โ€ฆ
    1. fill out Red, Green, Blue โ€ฆ 0 to 255 โ€ฆ RGB Colour System numbers
    2. fill out Cyan, Magenta, Yellow, Key โ€ฆ 0.0000 to 1.0000 โ€ฆ CMYK Colour System numbers
    3. click our new HTML input type=โ€colorโ€ element and follow your nose
  • and then, optionally, collaborate (or just share) with an emailee (textbox) they fill out and press the โ€œEmail to โ€ฆโ€ button โ€ฆ setting off โ€ฆ
  • Ajax/FormData functionality sends off the document.body.innerHTML (heavily amended) HTML data directed via our Inline HTML Email โ€œemailhtml.phpโ€ (usual PHP) helper โ€ฆ
  • email arrives for the emailee who sees a lot of what the emailer last saw โ€ฆ and โ€ฆ
    1. we highly recommend clicking our new HTML input type=โ€colorโ€ element, then follow your nose (picking a colour , not your โ€ฆ ?) then โ€ฆ click RGB to CMYK button
    2. fill out Red, Green, Blue โ€ฆ 0 to 255 โ€ฆ RGB Colour System numbers โ€ฆ click RGB to CMYK button
    3. fill out Cyan, Magenta, Yellow, Key โ€ฆ 0.0000 to 1.0000 โ€ฆ CMYK Colour System numbers โ€ฆ click CMYK to RGB button

    โ€ฆ optionally adjusting the return email (as the original emailerโ€™s email address, more than likely) โ€ฆ back out to โ€œthe netโ€ with โ€ฆ

  • the emaileeโ€™s web browser arrives at theโœ‚same colour systems web application ready to, optionally, send more collaboration or sharing back to the emailer, as required

Colourful discussions can ensue! And donโ€™t we know, lots of people have opinions about colour, even its spelling!


Previous relevant Colour Systems Primer Tutorial is shown below.

Colour Systems Primer Tutorial

Colour Systems Primer Tutorial

We want to talk, today, about Colour (Space) Systems. There are, at least โ€ฆ

  • additive colour systems โ€ฆ used in science โ€ฆ often used to define web colours โ€ฆ red, green and blue are the primary colours
  • subtractive colour systems โ€ฆ used by artists (and often the way we learn colours in early school) โ€ฆ often used with regard to printing โ€ฆ red, yellow and blue are the primary colours
  • the CMYK colour system โ€ฆ used by printing industry โ€ฆ cyan, magenta, yellow and black are the primary colours

You can read more about the comparisons and a description of these three at Colour Systems โ€“ RGB and CYMK.

Weโ€™ve got a small HTML and Javascript conversion program we call cmyk_rgbโšซhtml (and that you can use as a liveโœ‚run) which you can use today to convert a given colour to and from RGB and CYMK colour systems.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *