Audio and Video Creator via Media Browsing Image Background Email Tutorial

Audio and Video Creator via Media Browsing Image Background Email Tutorial

Audio and Video Creator via Media Browsing Image Background Email Tutorial

Yesterday’s Audio and Video Creator via Media Browsing Image Background Tutorial added functionality “creating” something (in HTML). When this happens, it may be that it is not only you who is interested in your creation. In other words you may want to share this, via an email attachment, with somebody else who might be on the other side of the wooooooorrrrrlllllddd!

Continuing on with yesterday’s “hardcoding” changes, we change that second “submit” button’s functionality regarding any Audio or Video inputs and allow the user the opportunity to share their creation with another email recipient. The data-URI data we store certainly suits this Ajax/FormData “midair” email sharing approach …


function ewell() {
var etois='';
if (usualclick == 0) {
etois=prompt('Please enter email address to send this to', '');
if (etois == null) { etois=''; }
if (etois.indexOf('@') != -1) {
var scrst='<head><script type="text/javascript"> var vcur=2, imn=-1; ';
scrst+=" function playseq() { var ass='asong'; ass=ass.concat(vcur.toString()); ";
scrst+=" if (document.getElementById(ass)) { ";
scrst+=" if (document.getElementById(ass).title != '') { "
scrst+=" setTimeout(playseq, Math.floor(eval(eval(document.getElementById(ass).title) * 1000))); ";
scrst+=" if (eval(vcur.toString()) != 2) { document.getElementById(ass).play(); } ";
scrst+=' vcur-=imn; ';
scrst+=' } ';
scrst+=' } else { ';
scrst+=' vcur=2; ';
scrst+=' } ';
scrst+=' } ';
scrst+='</scri' + 'pt></head>';
var zbigstr='<html>' + '<body>' + scrst + document.getElementById('song').outerHTML.replace(/\&quot\;/g,"'").replace('<audio ','<audio onplay=" vcur=2; playseq(); " ') + '</body>' + '</html>';
var zzhr = new XMLHttpRequest();
var zzform=new FormData();
zzform.append('to', etois);
zzform.append('subj', 'My Audio/Video Presentation');
if (etois == etois.toUpperCase()) {
zzform.append('inline', '');
}
zzform.append('tdhuhta', encodeURIComponent(zbigstr));
zzhr.open('post', '//www.rjmprogramming.com.au/PHP/emailhtml.php', true);
zzhr.send(zzform);
}
}
}

And so a changed PHP tutorial_to_animated_gif.php animated GIF creator (and so much more) web application could be worth trying, to share your thoughts.


Previous relevant Audio and Video Creator via Media Browsing Image Background Tutorial is shown below.

Audio and Video Creator via Media Browsing Image Background Tutorial

Audio and Video Creator via Media Browsing Image Background Tutorial

The recent Audio and Video Creator via Media Browsing Multiple Forms Tutorial involved …

  • user means by which Audio and Video media inputs could be catered for … but today we attend to two other implications of this, those being …
    1. web application “Tutorial Slideshow” and “Image” hardcodings to other wording as applicable
    2. cater for scenarios of some (but not all) Audio or Video inputs, in which case the last image data-URI helps form a background image to the Audio/Video presentation created with the other media files, as per

      <script type='text/javascript'>
      var lastnav='';

      function dotval(tval) {
      if (('' + tval).indexOf('ata:image/') != -1) {
      vst++;
      vsti++;
      lastnav=tval;
      }
      }


      if (vsti != 0 && eval(vstv + vsta) != 0) {
      document.getElementById('song').style.display='inline-block';
      document.getElementById('song').style.backgroundImage='linear-gradient(rgba(255,255,255,0.7),rgba(255,255,255,0.7)),URL(' + lastnav + ')';
      document.getElementById('song').style.backgroundSize='contain';
      document.getElementById('song').style.backgroundRepeat='no-repeat';
      return false;
      }


      </script>
      <img style='display:none;' title='slideshow' id='myimghere' src='' onerror="iready=true;" onload=" if (this.src.length > 0) { iwidths.push(this.width); iheights.push(this.height); document.getElementById(this.title).setAttribute('data-wh',selitize('' + this.width + ',' + this.height)); iready=true; dotval(this.src); } "></img>

As far as web application “Tutorial Slideshow” and “Image” hardcodings to other wording as applicable work goes, throughout the code at applicable “hardcoding” places change them to span elements, as per


var tusl='Tutorial Slideshow'; // initial setting overridden by 'Background' if Audio or Video media is detected
fo.innerHTML+="<span id=ours" + icnt + ">" + tusl + " Image</span> " + icnt + " <input title='Please note a minus between numericals can define a URL range of image URLs' placeholder='Append #comment[~second line] for animated GIF watermarks (that are red if first slide has such a comment) ... {[unicode]} for some emojis' onblur='maybemore(this.value, this.id, this);' style='width:" . $seventypc . ";' data-wh='' type='text' id='slideshow" + icnt + "' name='slideshow" + icnt + "' value=''></input><br><br><div id='fdiv" + icnt + "'></div>";

… and later in function “maybemore” …


if (('' + tval).indexOf('ata:audio/') != -1) {
vsta++;
tusl='Background';
sps=document.getElementsByTagName('span');
for (isps=0; isps<sps.length; isps++) {
if (sps[isps].innerHTML.indexOf('Tutorial Slideshow') != -1) {
sps[isps].innerHTML=sps[isps].innerHTML.replace('Tutorial Slideshow', 'Background');
}
}
inps=document.getElementsByTagName('input');
for (isps=0; isps<inps.length; isps++) {
if (('' + inps[isps].value).indexOf('Tutorial Slideshow to ') == 0) {
inps[isps].value=inps[isps].value='Play and/or Synchronize Media';
}
}
if (document.getElementById('ours' + eval(-1 + eval('' + ('' + tid).replace('slideshow',''))))) {
document.getElementById('ours' + eval(-1 + eval('' + ('' + tid).replace('slideshow','')))).innerHTML='Audio';
}

var ais=document.createElement('audio');
ais.type='audio/' + ('' + tval).split('ata:audio/')[1].split(':')[0].split(';')[0];
ais.src=tval.replace('#song','');
ais.style.verticalAlign='top';
ais.title='';
ais.controls='controls';
ais.id='asong' + ('' + tid).replace('slideshow','');
if (document.getElementById('song').innerHTML == '') { document.getElementById('song').innerHTML='<br><br>Play Audio/Video Sequentially below if Start of Play is first bit of media ...<br>'; vcur=eval(('' + tid).replace('slideshow','')); ais.onplay=function (event){ playseq(); }; setTimeout(asongit, 3000); }
document.getElementById('song').appendChild(ais);
} else if (('' + tval).indexOf('ata:video/') != -1) {
vstv++;
tusl='Background';
sps=document.getElementsByTagName('span');
for (isps=0; isps<sps.length; isps++) {
if (sps[isps].innerHTML.indexOf('Tutorial Slideshow') != -1) {
sps[isps].innerHTML=sps[isps].innerHTML.replace('Tutorial Slideshow', 'Background');
}
}
inps=document.getElementsByTagName('input');
for (isps=0; isps<inps.length; isps++) {
if (('' + inps[isps].value).indexOf('Tutorial Slideshow to ') == 0) {
inps[isps].value=inps[isps].value='Play and/or Synchronize Media';
}
}
if (document.getElementById('ours' + eval(-1 + eval('' + ('' + tid).replace('slideshow',''))))) {
document.getElementById('ours' + eval(-1 + eval('' + ('' + tid).replace('slideshow','')))).innerHTML='Video';
}

var vis=document.createElement('video');
vis.type='video/' + ('' + tval).split('ata:video/')[1].split(':')[0].split(';')[0];
vis.title='';
vis.style.verticalAlign='top';
vis.src=tval.replace('#song','');
vis.controls='controls';
vis.id='asong' + ('' + tid).replace('slideshow','');
if (document.getElementById('song').innerHTML == '') { document.getElementById('song').innerHTML='<br><br>Play Audio/Video Sequentially below if Start of Play is first bit of media ...<br>'; vcur=eval(('' + tid).replace('slideshow','')); vis.onplay=function (event){ playseq(); }; setTimeout(asongit, 3000); }
document.getElementById('song').appendChild(vis);
}

… so that a user is better informed of the multipurpose nature of this changed PHP tutorial_to_animated_gif.php animated GIF creator (and so much more) web application.


Previous relevant Audio and Video Creator via Media Browsing Multiple Forms Tutorial is shown below.

Audio and Video Creator via Media Browsing Multiple Forms Tutorial

Audio and Video Creator via Media Browsing Multiple Forms Tutorial

Automating yesterday’s Audio and Video Creator via Media Browsing Tutorial “not user apparent” Audio/Video PHP web application processing functionality, whereby we used a URL like …

https://www.rjmprogramming.com.au/PHP/animegif/tutorial_to_animated_gif.php?allowaudio=y&allowvideo=y

… to allow this additional functionality in an “internal use only” type of approach. Turning this into a user controlling initial approach, among a phalanx of different approaches we might show, we are going to show a very traditional idea, using multiple HTML method=GET form elements, the 3 used in an HTML table corresponding to the three combinations of possibilities with the GET arguments above. This new HTML looks like …


<table style="display:inline-block;">
<tbody>
<tr>
<td>
<form method="GET" action="./tutorial_to_animated_gif.php" style="display:inline-block;">
<input name="allowaudio" value="y" type="hidden">
<input type="submit" style="border:1px solid yellow;" value="Audio">
</form>
</td>
<td>
<form method="GET" action="./tutorial_to_animated_gif.php" style="display:inline-block;">
<input name="allowaudio" value="y" type="hidden">
<input name="allowvideo" value="y" type="hidden">
<input title="Both, in addition to Images, always" type="submit" value="/">
</form>
</td>
<td>
<form method="GET" action="./tutorial_to_animated_gif.php" style="display:inline-block;">
<input name="allowvideo" value="y" type="hidden">
<input type="submit" style="border:1px solid yellow;" value="Video">
</form>
</td>
</tr>
</tbody>
</table>

We use the “table” to keep the forms inline.

We use the “form method=GET action=./tutorial_to_animated_gif.php” to navigate back to simulate the possibilities behind that first URL way above.

Pretty fundamental, boring, but effective, HTML navigational functionality that adds user control into the picture.

Feel free to (re-)try the changed tutorial_to_animated_gif.php animated GIF creator web application.


Previous relevant Audio and Video Creator via Media Browsing Tutorial is shown below.

Audio and Video Creator via Media Browsing Tutorial

Audio and Video Creator via Media Browsing Tutorial

A couple of days ago with TextArea to Speech via macOS iTunes Tutorial we surmised …

We can feel some PHP “audio functionality” ideas coming on … perhaps we need to take a Bex and have a lie down.

… and so today we take the first steps in our “idea set”.

Our last mention of our Animated GIF creator PHP web application was with Animated Gif Creator Variable Slide Delays Tutorial and, today, we expand its capabilities, at this stage hidden to the user, of being able to accept …

  • (its usual) image media (that creates Animated GIF images) … but, also, new as of today …
  • audio media browsed for file(s)
  • video media browsed for file(s)

… the latter two, if the whole is the some of the parts, being able to be sequenced if the user chooses to play the first audio/video media file first. Another “synchronization” effort to add to our list!

The changed tutorial_to_animated_gif.php animated GIF creator web application can also be a audio/video creator web application which calls on a changed client_browsing.htm HTML/Javascript media browsing helper.

Feel free to (re-)try the changed tutorial_to_animated_gif.php animated GIF creator web application.


Previous relevant Animated Gif Creator Variable Slide Delays Tutorial is shown below.

Animated Gif Creator Variable Slide Delays Tutorial

Animated Gif Creator Variable Slide Delays Tutorial

When thinking about the animated GIFs produced by the PHP (writes PHP) web application of the recent Animated Gif Creator Image Filters Tutorial compared to videos … well, we can’t help you with the soundtrack, but how about that way a video can transfix us with a “lingering view” (notice how we don’t use the word “slide”)? But what if we could have a mechanism by which an animated GIF presentation could have its version of a “lingering view” …

an increased delay applied after the slide (for lingering) being currently displayed in the animated GIF

… being so catchy, huh?!

We actually readied some parts of the PHP code for this when we interfaced the Inhouse Animated GIF Creator’s involvement with our Haiku web application of Haiku Multimedia via Media Record Genericization Tutorial, but must have forgotten to follow through on the idea for non-Haiku scenarios (those rare occasions in life?!).

The recent Animated Gif Creator Image Filters Tutorial did us a huge favour here “PHP code organization wise” when we introduced that “function ingif($php_content_of_php)” last gasp way of making amendments to that second phase PHP which goes on to create the animated GIF for you (that is, if you don’t ask too much of it resource wise).

So now, where the first phase asks for a delay value, via a textbox, that textbox’s advice now goes along the lines of …

Comma separated list noticed, with first value being default for undefined ones. Plus and minus values do delays relative to previous delay.

… to work with the new PHP code within the changed tutorial_to_animated_gif.php animated GIF creator web application, as per …

<?php

function ingif($gp) {
global $foundtitle, $wtsuffix, $atext, $filteretc, $enumber, $ow, $oh, $owend, $ohend, $diffow, $diffoh, $delay, $vdy;
$indelay=$delay;
if (isset($_GET['delay'])) { $indelay=str_replace(" ","+",urldecode($_GET['delay'])); }
if (isset($_POST['delay'])) { $indelay=str_replace(" ","+",urldecode($_POST['delay'])); }
if (strpos($indelay, ",") !== false) {
if (strpos($gp, ("framed" . "[" . "]=" . $vdy . ";")) !== false) {
$gpf=explode("framed" . "[" . "]=" . $vdy . ";", $gp)[0];
$gp=str_replace($gpf . "framed" . "[" . "]=" . $vdy . ";", $gpf . "framed" . "[" . "] = " . $vdy . ";", $gp); //, 1);
$delaysare=explode(",", $indelay);
for ($iuy=1; $iuy<sizeof($delaysare); $iuy++) {
if (strpos($gp, ("framed" . "[" . "]=" . $vdy . ";")) !== false) {
$gpf=explode("framed" . "[" . "]=" . $vdy . ";", $gp)[0];
if (trim($delaysare[$iuy]) == '') {
$gp=str_replace($gpf . "framed" . "[" . "]=" . $vdy . ";", $gpf . "framed" . "[" . "] = " . $vdy . ";", $gp); //, 1);
} else if (strpos($delaysare[$iuy], "+") !== false) {
$delaysare[$iuy]='' . ($delaysare[-1 + $iuy] + substr($delaysare[$iuy],1));
$gp=str_replace($gpf . "framed" . "[" . "]=" . $vdy . ";", $gpf . "framed" . "[" . "] = " . $delaysare[$iuy] . ";", $gp); //, 1);
} else if (strpos($delaysare[$iuy], "-") !== false) {
$delaysare[$iuy]='' . ($delaysare[-1 + $iuy] - substr($delaysare[$iuy],1));
$gp=str_replace($gpf . "framed" . "[" . "]=" . $vdy . ";", $gpf . "framed" . "[" . "] = " . $delaysare[$iuy] . ";", $gp); //, 1);
} else {
$gp=str_replace($gpf . "framed" . "[" . "]=" . $vdy . ";", $gpf . "framed" . "[" . "] = " . $delaysare[$iuy] . ";", $gp); //, 1);
}
}
}
}
}

$enbit="";
$outgp=$gp;
//
// Rest of last gasp changes (of recent times) follows ...
//
}

?>

… enabling you to refine your animated GIF aesthetics, we personally being of the belief that an animated GIF loses a lot of nuance if its delays between slides are all the same. It can feel quite robotic at times.


Previous relevant Animated Gif Creator Image Filters Tutorial is shown below.

Animated Gif Creator Image Filters Tutorial

Animated Gif Creator Image Filters Tutorial

On top of the functionality of yesterday’s Animated Gif Creator Image Dimensions Tutorial we want to offer …


PHP GD library imagefilter functionality

Here’s our table of context for the changed tutorial_to_animated_gif.php animated GIF creator web application …

Comes into play as a recall PHP execution receives HTML form data
<?php

$filteretc="";
$fhc="Image";
if (isset($_GET['filteretc'])) {
$filteretc=str_replace("+"," ",urldecode($_GET['filteretc']));
$fhc=str_replace(explode("IMG_",$filteretc)[1] . '"',explode("IMG_",$filteretc)[1] . '" selected',('<select title="Image" onchange="filteretcit(this);" id="sfilteris"><option value="">Image</option><option value=" imagefilter($image, IMG_FILTER_EMBOSS); ">Embossed Image(s)</option><option value=" imagefilter($image, IMG_FILTER_NEGATE); ">Negated Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 255, 0, 0); ">Red Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 0); ">Green Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, -127.12, -127.98, 127); ">Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 0, 0, 255); ">Blue Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_PIXELATE, 3); ">Pixellated Image(s)</option><option value=" imagefilter($image, IMG_FILTER_SMOOTH, -1924.124); ">Smoothed Image(s)</option><option value=" imagefilter($image, IMG_FILTER_CONTRAST, -90); ">Contrasted Image(s)</option><option value=" imagefilter($image, IMG_FILTER_BRIGHTNESS, 98); ">Brightened Image(s)</option><option value=" imagefilter($image, IMG_FILTER_MEAN_REMOVAL); ">Mean Removal Image(s)</option></select>'));
} else if (isset($_POST['filteretc'])) {
$filteretc=str_replace("+"," ",urldecode($_POST['filteretc']));
$fhc=str_replace(explode("IMG_",$filteretc)[1] . '"',explode("IMG_",$filteretc)[1] . '" selected',('<select title="Image" onchange="filteretcit(this);" id="sfilteris"><option value="">Image</option><option value=" imagefilter($image, IMG_FILTER_EMBOSS); ">Embossed Image(s)</option><option value=" imagefilter($image, IMG_FILTER_NEGATE); ">Negated Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 255, 0, 0); ">Red Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 0); ">Green Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, -127.12, -127.98, 127); ">Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_COLORIZE, 0, 0, 255); ">Blue Colourized Image(s)</option><option value=" imagefilter($image, IMG_FILTER_PIXELATE, 3); ">Pixellated Image(s)</option><option value=" imagefilter($image, IMG_FILTER_SMOOTH, -1924.124); ">Smoothed Image(s)</option><option value=" imagefilter($image, IMG_FILTER_CONTRAST, -90); ">Contrasted Image(s)</option><option value=" imagefilter($image, IMG_FILTER_BRIGHTNESS, 98); ">Brightened Image(s)</option><option value=" imagefilter($image, IMG_FILTER_MEAN_REMOVAL); ">Mean Removal Image(s)</option></select>'));
}

?>
Again as PHP writes out the PHP to create the animated GIF, an example
<?php echo ”

$eachone=" if (\$randomizematch == '' || \$randomizematch == \"\$randomizeloopcnt\") {

\$progtext='';
\$text='';

// Open the first source image and add the text.
\$image = imagecreatefromjpeg('source01.jpg');
" . $setwh . "
\$text_color = imagecolorallocate(\$image, " . $r200 . ", " . $g200 . ", " . $b200 . ");
\$black = imagecolorallocatealpha(\$image, 254, 254, 254, 0);
if (98 == 97) { \$progtext=\$progtext; }
imagestring(\$image, 5, 5, 5, \$text, \$text_color);
if (\$progtext != '') {
if (strpos(\$progtext, ' ') !== false) {
imagettftext(\$image, 6, 0, (strlen(\$text) * 12), 21, \$text_color, realpath('DejaVuSansMono.ttf'), \$progtext);
} else if (strpos(\$progtext, ' ') !== false) {
imagettftext(\$image, 10, 0, (strlen(\$text) * 12), 21, \$text_color, realpath('DejaVuSansMono.ttf'), \$progtext);
} else {
imagettftext(\$image, 20, 0, (strlen(\$text) * 12), 21, \$text_color, realpath('DejaVuSansMono.ttf'), \$progtext);
}
}

// Generate GIF from the $image
// We want to put the binary GIF data into an array to be used later,
// so we use the output buffer.
ob_start();
imagegif(\$image);
\$frames[]=ob_get_contents();
\$framed[]=40; // Delay in the animation.
ob_end_clean();
// And again..
}
";

“; ?>
Used as PHP writes PHP in this way
<?php

function ingif($gp) {
global $foundtitle, $wtsuffix, $atext, $filteretc;
$outgp=$gp;
if ($wtsuffix != '' || $filteretc != '') {
//$bits=explode("\$image = ", $gp);
$bits=explode("if (98 == 97)", $gp);
if (sizeof($bits) > 1) {
$outgp="";
for ($ii=0; $ii<(-1 + sizeof($bits)); $ii++) {
$outgp.=lastcountidea($ii, (-1 + sizeof($bits)), $wtsuffix, $bits[$ii] . "\n " . $filteretc . "\n if (98 == 97)");
}
$outgp.=$bits[-1 + sizeof($bits)];
}
}
return $outgp;
}

“; ?>
And in order to correctly set the value of that new span element (ready to host a dropdown (select) element for image filtering that replaces a hardcoded “Image” word with Image Filtering dropdown options presented for user interaction) in a recall scenario, in this PHP writes Javascript code snippet change
<?php echo ”

Tutorial Slideshow <a style='cursor:pointer;text-decoration:none;' onclick=\" if (document.getElementById('slideshow').value.toLowerCase().indexOf('.htm') != -1) { window.open(document.getElementById('slideshow').value,'_blank'); } \">HTML</a> or <span id=ifilter>" . $fhc . "</span> <input title='Please note a minus between numericals can define a URL range of image URLs and that an Audio URL or Video URL (or browsed for above) causes the resultant Animated GIF to be its background image' placeholder='Append #comment[~second line] for animated GIF watermarks (that are red if first slide has such a comment) ... {[unicode]} for some emojis and an Audio URL or Video URL (or browsed for above) causes the resultant Animated GIF to be its background image' onblur=\"maybemore(this.value, 'slideshow1', this);\" style='width:70%;' data-wh='' type='text' id='slideshow' name='slideshow' value='" . $url . "'></input><br><br>

“; ?>
And the PHP writes HTML new HTML form type=hidden fields that navigate up to the recalled PHP as well as the iframe element that will help gather animated GIF image slide dimensions
<?php echo ”

<input name=filteretc id=filteretc value=\"" . $filteretc . "\" type=hidden></input>

“; ?>
Used by that select onchange logic’s PHP writing Javascript called (and other) functions
<?php echo ”

function filteretcit(oself) {
var xsuffis='';
if (oself.value.indexOf('imagefilter(') != -1) {
document.getElementById('filteretc').value=oself.value;
for (var i=0; i<oself.options.length; i++) {
if (oself.options[i].selected) {
if (oself.options[i].value != '') {
xsuffis=' ... ' + oself.options[i].innerText;
}
}
}
oself.title=oself.value + xsuffis;
} else {
document.getElementById('filteretc').value=oself.value;
document.getElementById('filteretc').title='Image';
}
//oself.value='';
}

function selitize(thiswh) {
if (thiswh.trim() != '') {
if (document.getElementById('selwhs').outerHTML.indexOf(thiswh) == -1) {
document.getElementById('selwhs').style.display='inline-block';
document.getElementById('selwhs').innerHTML+='<option value=\"' + thiswh + '\">' + thiswh.replace(',',' x ') + '</option>';
if (document.getElementById('selwhs').outerHTML.indexOf('?') == -1) {
if (thiswh.indexOf(',') != -1) {
document.getElementById('fow').value=thiswh.split(',')[0];
document.getElementById('foh').value=thiswh.split(',')[1];
}
document.getElementById('selwhs').innerHTML+='<option value=\"?\">You Enter Width,Height</option>';
document.getElementById('ifilter').innerHTML='<select title=\"Image\" onchange=filteretcit(this); id=sfilteris><option value=\"\">Image</option></select>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_EMBOSS); \">Embossed Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_NEGATE); \">Negated Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_COLORIZE, 255, 0, 0); \">Red Colourized Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_COLORIZE, 0, 255, 0); \">Green Colourized Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_COLORIZE, -127.12, -127.98, 127); \">Colourized Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_COLORIZE, 0, 0, 255); \">Blue Colourized Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_PIXELATE, 3); \">Pixellated Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_SMOOTH, -1924.124); \">Smoothed Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_CONTRAST, -90); \">Contrasted Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_BRIGHTNESS, 98); \">Brightened Image(s)</option>';
document.getElementById('sfilteris').innerHTML+='<option value=\" imagefilter(\$image, IMG_FILTER_MEAN_REMOVAL); \">Mean Removal Image(s)</option>';

}
}
}
return thiswh;
}

“; ?>

Did you know?

As progress, also, we’ve added to the second presentation part of your created animated GIF the “click” ability to download the animated GIF to your local device or computer. Here on this MacBook Pro (using macOS Mojave), to further open that downloaded animated GIF did something very interesting. Even though the downloaded file was downloaded into the Downloads folder as “my_rjm_gif.gif” as a default application to use with a “click” on it (ie. its “association” application) we were surprised it opened in Preview (usually the preserve of all things PDF) and displayed like a PDF with all the images making up its “slides” showing as “slides” in Preview. Cute, huh?!


Previous relevant Animated Gif Creator Image Dimensions Tutorial is shown below.

Animated Gif Creator Image Dimensions Tutorial

Animated Gif Creator Image Dimensions Tutorial

You can’t really claim to have a fully tailorable image creation process if you can’t allow the user to have some control over the final …


width x height

… image dimensions. As you develop webpages you will find requirements to fit images into set spaces, and that is all okay if the images suit those dimensions exactly, or proportionally. And that is where the PHP GD library imagescale function can come in handy.

So, on our quest to improve on the Animated GIF Creator web application of yesterday’s Animated Gif Creator Watermark Display Mode Tutorial there is a one PHP codeline of difference to make this animated GIF dimensions be user controllable …

<?php echo ”

$eachone=" if (\$randomizematch == '' || \$randomizematch == \"\$randomizeloopcnt\") {

\$text='';

// Open the first source image and add the text.
\$image = imagecreatefromjpeg('source01.jpg');
" . $setwh . "
\$text_color = imagecolorallocate(\$image, " . $r200 . ", " . $g200 . ", " . $b200 . ");
imagestring(\$image, 5, 5, 5, \$text, \$text_color);

// Generate GIF from the $image
// We want to put the binary GIF data into an array to be used later,
// so we use the output buffer.
ob_start();
imagegif(\$image);
\$frames[]=ob_get_contents();
\$framed[]=40; // Delay in the animation.
ob_end_clean();
// And again..
}
";

“; >

… but am guessing you’d want some context around that, wouldn’t you, for the changed tutorial_to_animated_gif.php animated GIF creator web application?!

Comes into play as a recall PHP execution receives HTML form data
<?php

$setwh="";
$ow=-1;
$oh=-1;
$setwhd="none";
$setwhihs="";
if (isset($_GET['ow']) && isset($_GET['oh'])) {
if (strlen(urldecode($_GET['ow'])) != 0 && strpos(urldecode($_GET['ow']), "-") === false) {
$ow=trim(str_replace("+"," ",urldecode($_GET['ow'])));
if (strlen(urldecode($_GET['oh'])) != 0 && strpos(urldecode($_GET['oh']), "-") === false) {
$oh=trim(str_replace("+"," ",urldecode($_GET['oh'])));
}
$setwh="\n \$image=imagescale(\$image, " . $ow . ", " . $oh . "); \n";
$setwhd="inline-block";
if (isset($_GET['fow']) && isset($_GET['foh'])) {
$setwhihs="<option value='" . trim(str_replace("+"," ",urldecode($_GET['fow']))) . "," . trim(str_replace("+"," ",urldecode($_GET['foh']))) . "'>" . trim(str_replace("+"," ",urldecode($_GET['fow']))) . " x " . trim(str_replace("+"," ",urldecode($_GET['foh']))) . "</option><option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option><option value=?>You Enter Width,Height</option>";
} else {
$setwhihs="<option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option>";
}
} else if (strlen(urldecode($_GET['oh'])) != 0 && strpos(urldecode($_GET['oh']), "-") === false) {
$oh=trim(str_replace("+"," ",urldecode($_GET['oh'])));
$setwh="\n \$image=imagescale(\$image, " . $ow . ", " . $oh . "); \n";
$setwhd="inline-block";
if (isset($_GET['fow']) && isset($_GET['foh'])) {
$setwhihs="<option value='" . trim(str_replace("+"," ",urldecode($_GET['fow']))) . "," . trim(str_replace("+"," ",urldecode($_GET['foh']))) . "'>" . trim(str_replace("+"," ",urldecode($_GET['fow']))) . " x " . trim(str_replace("+"," ",urldecode($_GET['foh']))) . "</option><option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option><option value=?>You Enter Width,Height</option>";
} else {
$setwhihs="<option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option>";
}
}
} else if (isset($_POST['ow']) && isset($_POST['oh'])) {
if (strlen(urldecode($_POST['ow'])) != 0 && strpos(urldecode($_POST['ow']), "-") === false) {
$ow=trim(str_replace("+"," ",urldecode($_POST['ow'])));
if (strlen(urldecode($_POST['oh'])) != 0 && strpos(urldecode($_POST['oh']), "-") === false) {
$oh=trim(str_replace("+"," ",urldecode($_POST['oh'])));
}
$setwh="\n \$image=imagescale(\$image, " . $ow . ", " . $oh . "); \n";
$setwhd="inline-block";
if (isset($_POST['fow']) && isset($_POST['foh'])) {
$setwhihs="<option value='" . trim(str_replace("+"," ",urldecode($_POST['fow']))) . "," . trim(str_replace("+"," ",urldecode($_POST['foh']))) . "'>" . trim(str_replace("+"," ",urldecode($_POST['fow']))) . " x " . trim(str_replace("+"," ",urldecode($_POST['foh']))) . "</option><option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option><option value=?>You Enter Width,Height</option>";
} else {
$setwhihs="<option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option>";
}
} else if (strlen(urldecode($_POST['oh'])) != 0 && strpos(urldecode($_POST['oh']), "-") === false) {
$oh=trim(str_replace("+"," ",urldecode($_POST['oh'])));
$setwh="\n \$image=imagescale(\$image, " . $ow . ", " . $oh . "); \n";
$setwhd="inline-block";
if (isset($_POST['fow']) && isset($_POST['foh'])) {
$setwhihs="<option value='" . trim(str_replace("+"," ",urldecode($_POST['fow']))) . "," . trim(str_replace("+"," ",urldecode($_POST['foh']))) . "'>" . trim(str_replace("+"," ",urldecode($_POST['fow']))) . " x " . trim(str_replace("+"," ",urldecode($_POST['foh']))) . "</option><option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option><option value=?>You Enter Width,Height</option>";
} else {
$setwhihs="<option value='" . $ow . "," . $oh . "' selected>" . $ow . " x " . $oh . "</option>";
}
}
}

?>
Again as PHP writes out the PHP to create the animated GIF
<?php echo ”

$eachone=" if (\$randomizematch == '' || \$randomizematch == \"\$randomizeloopcnt\") {

\$text='';

// Open the first source image and add the text.
\$image = imagecreatefromjpeg('source01.jpg');
" . $setwh . "
\$text_color = imagecolorallocate(\$image, " . $r200 . ", " . $g200 . ", " . $b200 . ");
imagestring(\$image, 5, 5, 5, \$text, \$text_color);

// Generate GIF from the $image
// We want to put the binary GIF data into an array to be used later,
// so we use the output buffer.
ob_start();
imagegif(\$image);
\$frames[]=ob_get_contents();
\$framed[]=40; // Delay in the animation.
ob_end_clean();
// And again..
}
";

“; ?>
And in order to correctly set the value of that new dropdown (select) element in a recall scenario, in this PHP writes Javascript code snippet change
<?php echo ”

<h1 id='myh1' align='center'>Tutorial Slideshow to Animated GIF <select onchange=owoh(this); style='display:" . $setwhd . ";' id=selwhs><option value=''>Size of First Slide (as below)</option>" . $setwhihs . "</select>" . $moreh1 . " ... or ... <div style='display:inline-block;width:95px;height:30px;overflow:hidden;border-top:1px solid black;border-bottom:1px solid black;border-left:2px solid yellow;border-right:1px solid yellow;'><iframe id=cbi frameborder=0 style='width:173px;height:228px;margin-top:-194px;' src='../../HTMLCSS/client_browsing.htm?d=" . rand(0,18765432) . "'></iframe></div></h1>

“; ?>
And the PHP writes HTML new HTML form type=hidden fields that navigate up to the recalled PHP as well as the iframe element that will help gather animated GIF image slide dimensions
<?php echo ”

<input name=fow id=fow value='-1' type=hidden></input><input name=foh id=foh value='-1' type=hidden></input>
<input name=ow id=ow value='-1' type=hidden></input><input name=oh id=oh value='-1' type=hidden></input>
<img style='display:none;' title='slideshow' id='myimghere' src='' onerror=\"iready=true;\" onload=\" if (this.src.length > 0) { iwidths.push(this.width); iheights.push(this.height); document.getElementById(this.title).setAttribute('data-wh',selitize('' + this.width + ',' + this.height)); iready=true; } \"></img>

“; ?>
And example of changed PHP writes HTML image slide textboxes whereby a new global data attribute called “data-wh” helps out the user with their newly presented “image dimensions choice” dropdown
<?php echo ”

$scris.="\n if (fo.id == 'slideshow') { fo.value='" . $urlminus . "'; } else { fo.innerHTML+=\"Tutorial Slideshow Image \" + icnt + \" <input title='Please note a minus between numericals can define a URL range of image URLs' onblur='maybemore(this.value, this.id, this);' style='width:70%;' data-wh='' type='text' id='slideshow\" + icnt + \"' name='slideshow\" + icnt + \"' value='" . $urlminus . "'></input><br><br><div id='fdiv\" + icnt + \"'></div>\"; } \n";

“; ?>
Used by that iframe onload logic’s PHP writing Javascript called (and other) functions
<?php echo ”

var iwidths=[], iheights=[];
var iready=true;

function selitize(thiswh) {
if (thiswh.trim() != '') {
if (document.getElementById('selwhs').outerHTML.indexOf(thiswh) == -1) {
document.getElementById('selwhs').style.display='inline-block';
document.getElementById('selwhs').innerHTML+='<option value=\"' + thiswh + '\">' + thiswh.replace(',',' x ') + '</option>';
if (document.getElementById('selwhs').outerHTML.indexOf('?') == -1) {
if (thiswh.indexOf(',') != -1) {
document.getElementById('fow').value=thiswh.split(',')[0];
document.getElementById('foh').value=thiswh.split(',')[1];
}
document.getElementById('selwhs').innerHTML+='<option value=\"?\">You Enter Width,Height</option>';
}
}
}
return thiswh;
}

function owoh(thisselis) {
var askwh='';
if (thisselis.value.indexOf(',') != -1) {
document.getElementById('ow').value='' + thisselis.value.split(',')[0];
document.getElementById('oh').value='' + thisselis.value.split(',')[1];
} else if (thisselis.value='?') {
askwh=prompt('Please comma separate a width and height (eg. 750,1334) where a -1 for one lets it be proportional', '');
if (askwh == null) { askwh=''; } else { askwh=askwh.replace(/\ /g,''); }
if (askwh.indexOf(',') != -1 && eval('' + askwh.split('-').length) <= 2) {
if (askwh.indexOf('-1,') == 0) {
document.getElementById('ow').value='' + Math.round(eval('' + thisselis.outerHTML.split(' x ')[0].split('>')[eval(-1 + thisselis.outerHTML.split(' x ')[0].split('>').length)]) * eval('' + askwh.split(',')[1]) / eval('' + thisselis.outerHTML.split(',')[1].split('\"')[0].split(\"'\")[0]));
askwh=askwh.replace('-1,', document.getElementById('ow').value + ',');
document.getElementById('oh').value='' + askwh.split(',')[1];
} else {
document.getElementById('ow').value='' + askwh.split(',')[0];
document.getElementById('oh').value='' + askwh.split(',')[1];
}
if (thisselis.outerHTML.indexOf(askwh) == -1) {
thisselis.style.display='inline-block';
thisselis.innerHTML+='<option value=\"' + askwh + '\">' + askwh.replace(',',' x ') + '</option>';
}
} else {
askwh='';
document.getElementById('ow').value='-1';
document.getElementById('oh').value='-1';
}
thisselis.value=askwh;
} else {
document.getElementById('ow').value='-1';
document.getElementById('oh').value='-1';
}
}

setTimeout(startmonitoringwh, 3000);

“; ?>


Previous relevant Animated Gif Creator Watermark Display Mode Tutorial is shown below.

Animated Gif Creator Watermark Display Mode Tutorial

Animated Gif Creator Watermark Display Mode Tutorial

It’s not just …

  • the watermark colour of yesterday’s Animated Gif Creator Watermark Colour Tutorial that can help with an animated GIF being more self explanatory (in a display sense) … it is today’s new …
  • watermark display mode out of …
    1. Title Just on First
    2. Title on First and Count on Others
    3. Title With a Count on All
    4. No Watermark

… that can help us know where we are up to, given the use of the middle options above, again, doing a little to “bridge” the gap between a video presentation and an animated GIF one we can create with the changed tutorial_to_animated_gif.php animated GIF creator web application.

This new functionality interfaces to the online user via a new dropdown (select) element replacement for the hardcoded “Title” word of one of the headers. More and more, we start to see the benefits of involving “option” subelements with that “select” hosting one being given IDs as you can surmise from the initial HTML (via PHP) …

<?php echo ”

Tutorial Slideshow <select style='display:inline-block;width:80px;' onchange='watermarkchange(this);' id='watermarkmode' name='watermarkmode'><option id=watermarkoption value=''>Title</option><option value=''>Title Just on First</option><option value=' '>Title on First and Count on Others</option><option value=' '>Title With a Count on All</option><option id=optnow value=\"\\n\">No Watermark</option></select>

“; ?>

… referencing user interface “onchange” Javascript logic …

<?php echo ”

function watermarkchange(oselwater) {
var ovalis=oselwater.value
if (ovalis == ' ') {
document.getElementById('watermarkoption').innerHTML='Title on First and Count on Others';
document.getElementById('watermarkoption').value=ovalis;
} else if (ovalis == ' ') {
document.getElementById('watermarkoption').innerHTML='Title With a Count on All';
document.getElementById('watermarkoption').value=ovalis;
} else if (ovalis.length == 0) {
document.getElementById('watermarkoption').innerHTML='Title Just on First';
document.getElementById('watermarkoption').value=ovalis;
} else {
document.getElementById('watermarkoption').innerHTML='No Watermark';
document.getElementById('watermarkoption').value=ovalis;
}
}

“; ?>

… and because this new dropdown (select) element is within an HTML form and contributes to messaging sent to recalls of the PHP, all the following PHP and Javascript snippets are interesting too …

Comes into play as a recall PHP execution receives HTML form data
<?php

$foundtitle=" ";
$wtsuffix="";
$setwm="";
if (isset($_GET['watermarkmode'])) {
$wtsuffix=str_replace("+"," ",urldecode($_GET['watermarkmode']));
if ($wtsuffix == ' ') {
$setwm="\n document.getElementById('watermarkmode').value=' '; \n";
} else if ($wtsuffix == ' ') {
$setwm="\n document.getElementById('watermarkmode').value=' '; \n";
} else if ($wtsuffix != '') {
$setwm="\n document.getElementById('watermarkmode').value=document.getElementById('optnow').value; \n";
}
} else if (isset($_POST['watermarkmode'])) {
$wtsuffix=str_replace("+"," ",urldecode($_POST['watermarkmode']));
if ($wtsuffix == ' ') {
$setwm="\n document.getElementById('watermarkmode').value=' '; \n";
} else if ($wtsuffix == ' ') {
$setwm="\n document.getElementById('watermarkmode').value=' '; \n";
} else if ($wtsuffix != '') {
$setwm="\n document.getElementById('watermarkmode').value=document.getElementById('optnow').value; \n";
}
}

?>
Again as PHP writes out the PHP to create the animated GIF
<?php echo ”

function lastcountidea($thiscounter,$totalcount,$suffixwatermarkmode,$sofarphp) {
global $foundtitle, $wtsuffix, $atext;
$ft="";
$ourdelim="'";
if (strpos($sofarphp, "\$text=") !== false) {
$sofars=explode("\$text=", $sofarphp);
$ourdelim=substr($sofars[1],0,1);
$ft=explode($ourdelim,substr($sofars[1],1))[0];
}
if ($foundtitle == " ") {
if (strpos($sofarphp, "\$text=") !== false) {
$sofars=explode("\$text=", $sofarphp);
$foundtitle=$ft;
}
}
if ($suffixwatermarkmode == ' ') {
if ($thiscounter == 0) {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . $foundtitle . " ... 1 of " . $totalcount . $ourdelim, $sofarphp);
} else {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . "" . (1 + $thiscounter) . " of " . $totalcount . $ourdelim, $sofarphp);
}
} else if ($suffixwatermarkmode == ' ') {
if ($thiscounter == 0) {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . $foundtitle . " ... 1 of " . $totalcount . $ourdelim, $sofarphp);
} else {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . $foundtitle . " ... " . (1 + $thiscounter) . " of " . $totalcount . $ourdelim, $sofarphp);
}
} else if (strlen($suffixwatermarkmode) != 0) {
if ($thiscounter == 0) {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . $ourdelim, $sofarphp);
} else {
$sofarphp=str_replace_first("\$text=" . $ourdelim . $ft . $ourdelim, "\$text=" . $ourdelim . $ourdelim, $sofarphp);
}
}
return $sofarphp;
}

function ingif($gp) {
global $foundtitle, $wtsuffix, $atext;
$outgp=$gp;
if ($wtsuffix != '') {
$bits=explode("\$image = ", $gp);
if (sizeof($bits) > 1) {
$outgp="";
for ($ii=0; $ii<(-1 + sizeof($bits)); $ii++) {
$outgp.=lastcountidea($ii, (-1 + sizeof($bits)), $wtsuffix, $bits[$ii] . "\$image = ");
}
$outgp.=$bits[-1 + sizeof($bits)];
}
}
return $outgp;
}


“; ?>
<?php

// PHP writes PHP later, and onto that PHP can create the animated GIF data, as below ...
file_put_contents(server_remote_addr() . "_preview.php", ingif($gifphp) . $rltsuffix . $lastbit);
file_put_contents(server_remote_addr() . ".php", ingif($gifphp) . str_replace($lastbitfrom, str_replace("'animegif.gif'", "'" . server_remote_addr() . ".gif" . "'", $lastbitto), ($rltsuffix . $lastbit)));

?>
And in order to correctly set the value of that new dropdown (select) element in a recall scenario, in this PHP writes Javascript code snippet change
<?php echo ”

function dolhsh() {
" . $setwm . "
if (('' + window.location.hash).replace('#','') != '') {
//alert(45);
document.getElementById('lhsh').innerHTML=window.location.hash.substring(1);
document.getElementById('dhash').innerHTML='<input type=hidden name=ihash value=\"' + window.location.hash.substring(1) + '\"></input>';
document.getElementById('cbi').src=document.getElementById('cbi').src + '0' + window.location.hash.replace(/\ /g,'%20');
//alert(document.getElementById('lhsh').innerHTML);
var gsu='" . $gfn . "';
//alert(gsu);
document.getElementById('dgfn').innerHTML='<input type=hidden name=gfn value=\"' + document.URL.split('tutorial_to_animated_gif.')[0] + gsu + '\"></input>';
if (window.parent) {
if (parent.document.getElementById('agifn')) {
// alert(gsu);
parent.document.getElementById('agifn').value=document.URL.split('tutorial_to_animated_gif.')[0] + gsu;
}
}
} else if (parent.window) {
if (parent.document.URL.indexOf('client_browsing.htm') != -1) {
if (parent.document.getElementById('lhsh')) {
if (parent.document.getElementById('lhsh').innerHTML != '') {
document.getElementById('lhsh').innerHTML=parent.document.getElementById('lhsh').innerHTML;
//alert('000:' + document.getElementById('lhsh').innerHTML);
document.getElementById('dhash').innerHTML='<input type=hidden name=ihash value=\"' + parent.document.getElementById('lhsh').innerHTML + '\"></input>';
document.getElementById('cbi').src=document.getElementById('cbi').src + '0#' + parent.document.getElementById('lhsh').innerHTML.replace(/\ /g,'%20');
var gsux='" . $gfn . "';
//alert(gsu);
document.getElementById('dgfn').innerHTML='<input type=hidden name=gfn value=\"' + document.URL.split('tutorial_to_animated_gif.')[0] + gsux + '\"></input>';
}
}
}
}
//else {
//alert(65);
//}
}

“; ?>


Previous relevant Animated Gif Creator Watermark Colour Tutorial is shown below.

Animated Gif Creator Watermark Colour Tutorial

Animated Gif Creator Watermark Colour Tutorial

We’re revisiting the Animated Gif Creator web application last looked at with the recent Haiku Multimedia via Media Record Genericization Tutorial on a quest to “bridge” the gap between …

  • video … and ….
  • animated GIF

… as presentation tools, that “bridge” being the operative word, as animated GIFs cannot match video even respecting the audio capabilities of videos, but there are things we can think of with our web application to improve it. And today’s start of this quest is to allow for user defined watermark (ie. text) colour on that first slide.

This control may mean that the first slide stands out enough to distinguish it enough from others to tell the user, especially on a rerun of the animated GIF presentation, that the user is at the start of the presentation. Of course, with the video HTML element, this “we are at the start of the presentation” is pretty obvious by the look of the controls.

The changed tutorial_to_animated_gif.php animated GIF creator uses and incorporates a new input type=color colour picker.


Previous relevant Haiku Multimedia via Media Record Genericization Tutorial is shown below.

Haiku Multimedia via Media Record Genericization Tutorial

Haiku Multimedia via Media Record Genericization Tutorial

Coming at yesterday’s Haiku Multimedia via Media Record Background Tutorial

  • we start to allow a comma separated list of user entered image URLs into the Background URL textbox as a possibility …
  • along the way getting into some “Data-URI http error 414″ problems we needed “console.log” to help us out debugging … hence today’s tutorial picture … and …
  • a new genericization strategy …

… with a familiar idea, for us, that being …

change a hardcoding into a dynamic HTML concept

… that dynamic HTML concept being the most “hands on” genericization tool we could think of as far as “user control” goes. The hardcoding is pretty obvious for this current “Haiku Creation” web application, that being …


(the noun) "Haiku"

… and the most “hands on” genericization tool we could think of being a favourite of ours …


<h1><div onblur=titlefix(); style="display:inline-block;border:2px solid transparent;" id=subjectword contenteditable=true title='Can change this'>Haiku</div> Animated GIF Creator</h1>

… the HTML div element attribute contenteditable=true … teamed up with the Javascript …


function titlefix() {
var dgebiswih=document.getElementById('subjectword').innerHTML;
var dgebiswihtwo=dgebiswih;
if (dgebiswihtwo == "") { dgebiswihtwo="-"; }
document.title=document.title.replace(lastword, dgebiswihtwo);
document.getElementById('bag').value=document.getElementById('bag').value.replace(lastword, dgebiswihtwo);
document.getElementById('bemail').value=document.getElementById('bemail').value.replace(lastword, dgebiswihtwo);
document.getElementById('bsms').value=document.getElementById('bsms').value.replace(lastword, dgebiswihtwo);
document.getElementById('aemail').href=document.getElementById('aemail').href.replace(encodeURIComponent(lastword), encodeURIComponent(dgebiswihtwo));
prefix=prefix.replace('stitle=' + encodeURIComponent('My ' + lastword), 'stitle=' + encodeURIComponent(('My ' + dgebiswih + '`').replace('My `','').replace('`','')));
lastword=dgebiswihtwo;
}

But why the border:2px solid transparent; CSS styling? Well, that “Haiku” hardcoding replacement could be “nothing” (ie. a blank string, effectively like an implied English “a” article to reach a web application title of “Animated GIF Creator”, and here we leave off any topic line annotations, if that swings the bargain for you). But how to change from “nothing” back to “something”? That 2px transparent border gives you a way to find your elusive …


<h1><div onblur=titlefix(); style="display:inline-block;border:2px solid transparent;" id=subjectword contenteditable=true title='Can change this'></div> Animated GIF Creator</h1>

… again.

So, on top of yesterday’s Haiku Multimedia via Media Record Share Tutorial we changed …


Previous relevant Haiku Multimedia via Media Record Background Tutorial is shown below.

Haiku Multimedia via Media Record Background Tutorial

Haiku Multimedia via Media Record Background Tutorial

Yesterday’s Haiku Multimedia via Media Record Share Tutorial helped with the “Haiku feel” to our Haiku Creation web application. The thing is, though, as we found with the video and YouTube API interfacing talents of our (ostenbibly) Karaoke web application, there is good reason to envisage this Haiku Creation web application fitting the bill for other possibilities. With that in mind, we decided to …

  • fix the positioning of the animated GIF in the lower art of the webpage … and …
  • allow the Choose File(s) local browsing functionality …
    1. browse for a single image file that could be the background image behind every (could be Haiku) animated GIF “slide” … or …
    2. browse for multiple image files that could be sequenced background images behind corresponding (could be Haiku) animated GIF “slide” with its (could be Haiku based) textarea derived corresponding record line overlayed annotation for that “slide” … a pretty apt use for multiple property

      <input type=file accept="image/*,video/*,audio/*" capture multiple></input>

    … still supporting yesterday’s progress supporting audio and/or video foreground data and email sharing

As you might surmise from this, we are opening the “Haiku feel” up to lots more data than represented by a Haiku (5, 7, 5) syllable of text data arrangement. We’ll see if the “genericization drive” continues?!

On top of yesterday’s Haiku Multimedia via Media Record Share Tutorial we changed …


Previous relevant Haiku Multimedia via Media Record Share Tutorial is shown below.

Haiku Multimedia via Media Record Share Tutorial

Haiku Multimedia via Media Record Share Tutorial

Everybody is somebody’s child. And often, in a modular I.T. woooooorrrrlllld a piece of code can be another’s child, even though they have an identity as a parent in their own right. It was the latter role we said goodbye to (developing further, right now) with yesterday’s Media Mix Play Audio Video Mix Concatention Tutorial but we found, returning to our recent Haiku web application, this “Voiceover Ideas” middle child in its …

  • iframe “child” window (especially where all participants reside on the RJM Programming domain) …
  • popup “child” window (especially where participants reside on a local web server)

… and other “childlike” Ajax/FormData or “navigation to via HTML form” guises may still need development to satisfy integration requirements (of the Haiku web application, in all its guises).

So working on top of where we left off Haiku work with the recent Haiku Multimedia via Media Record Capture Tutorial we implemented …


Previous relevant Haiku Multimedia via Media Record Capture Tutorial is shown below.

Haiku Multimedia via Media Record Capture Tutorial

Haiku Multimedia via Media Record Capture Tutorial

Let’s semi-drop the “macOS” on our “media capture” functionality we’re developing currently, because over the last two days it has jumped out of this restrictive thought pattern, either through the “voiceover” idea of …

  • non-mobile Adobe Flash Player plugin audio recording (Speech to Audio) … as well as …
  • input type=file capture mobile browsing and/or creating (iOS video) and non-mobile browsing of media with an audio (Speech to Audio) capability … on top of that original …
  • macOS or Mac OS X “say” command line command Text to Audio original “voiceover” idea

… onto yesterday’s MacOS and Other Mobile Media Record Tutorial you can join the story with, below.

And way back at Mac OS X Text to English Speech Primer Tutorial we can revisit the “synchronicity of media” ideas we are so keen about. Our conduit idea to get us there has been a revisit of the Haiku creation work of Haiku Animated Gif Creator Tutorial where we allow either a …

  • audio data-URI … or …
  • video data-URI

… form the “foreground” for an animated GIF (Haiku wording) “background” easy to show the user creating it, and shareable via an email HTML attachment approach, on some email clients (eg. Gmail webmail).

Along the way we repurposed the “dishevelment” of yesterday into more programmatically restrictive web application functionality to come up with …

  • today’s changed haiku_animated_gif.html‘s Haiku creation and sharing web application live run link’s Ajax/FormData email sending …

    function waitforalatr() { // features Ajax/FormData techniques to send email via inhouse PHP email helper
    if (document.getElementById('iurl').value == '') {
    setTimeout(waitforalatr, 2000);
    } else {
    alatr();
    altsubject='My Haiku ...';
    var tois=prompt('Who do you want to email to? Optionally hashtag (#) separate your own personal subject line to the email (eg. theemail@theemailplace.com#Hello there, it is moi.)', '');
    if (tois == null) { tois=''; }
    if (tois.indexOf('@') != -1) {
    var alts=tois.split('#');
    if (alts.length > 1) { altsubject=alts[1]; tois=alts[0]; }
    //var text=document.getElementById('result').innerHTML;
    //document.getElementById('ifem').innerHTML="<iframe onload=checkz(this); src='//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php?to=" + encodeURIComponent(tois) + '&subj=' + thisencodeURIComponent(altsubject) + ' ... ') + '&sliceminusten=' + encodeURIComponent(text.slice(-10)) + "' style=width:500px;height:600px;></iframe>";

    var zhr = new XMLHttpRequest();
    var zform=new FormData();
    //zform.append('inline', '');
    zform.append('to', tois);
    zform.append('subj', altsubject + ' ... ');
    zform.append('tdhuhta', '<html><body>' + document.getElementById('bpalette').innerHTML.replace('<audio ','<audio loop ').replace('<video ','<video loop ').replace('position:absolute;','').replace('left:','margin-left:0.').replace('top:','margin-top:0.') + '</body></html>');
    zhr.open('post', '//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php', true);
    zhr.send(zform);
    document.getElementById('iurl').value='';
    alert('Email sent with downloadable HTML attachment.');
    }
    }
    }

    … workings …
  • calls on a changed macos_say_record.php live run link … and also …
  • calls the HTML/Javascript the changed client_browsing.htm child web application to handle this HTML input capture usage and interfacing to (now various) parent.window scenarios … along the way also involving …
  • recently changed tutorial_to_animated_gif.php animated GIF creator … and …
  • Inhouse HTML Email helper/creator’s key interfacing code now goes …
    <?php

    $smt="";
    if (isset($_GET['sliceminusten'])) { $smt=' (' . str_replace(" ","+",urldecode($_GET['sliceminusten'])) . ')'; }
    $honesmt="Paste to lightgreen here (already copied from lightgreen there (but recopy and repaste yourself if last characters" . $smt . " do not match) and click yellow button to Email off this Audio player ...";
    if (strlen($smt) == 13 && strpos(str_replace("+"," ",('' . urldecode($_GET['to']))),"@") !== false && str_replace("+"," ",('' . urldecode($_GET['subj']))) != '') {
    echo "<html><head><script type='text/javascript'>
    var smt=('" . $smt . "').substring(2).substring(0,10), smts='';
    function onsm() {
    var wpr=null;
    var wp=window.parent;
    if (wp) { wpr=parent.document.getElementById('result'); }
    if ((window.opener && window.opener !== window) || (wp && wpr)) {
    if (5 == 5) { // window.opener.document.getElementById('result')) {
    document.getElementById('divplace').innerHTML='Email sent' + smts + '.';
    //alert(window.opener.document.getElementById('result').slice(-10) + ' vs ' + smt);
    return true;
    } else {
    document.getElementById('divplace').innerHTML='Other green textbox not detected.';
    return false;
    }
    } else {
    document.getElementById('divplace').innerHTML='Not a popup window.';
    return false;
    }
    }
    function fixta() {
    if (document.getElementById('taready').value.indexOf('#') == -1 && ((document.getElementById('taready').value.indexOf('data:audio/') == 0 || document.getElementById('taready').value.indexOf('data:video/') == 0) || document.getElementById('taready').value == '')) {
    if (document.getElementById('taready').value == '' || (' ' + document.getElementById('taready').value).slice(-10) == smt) {
    if (document.getElementById('taready').value != '') {
    var midbit=document.getElementById('taready').value.split('data:')[1].split(';')[0] + ' src=' + \"'\";
    document.getElementById('taready').value='<body><' + midbit.substring(0,5) + ' id=thisaudio controls><source type=' + midbit + document.getElementById('taready').value.replace(/\ /g,'+') + \"'\" + '></source></' + midbit.substring(0,5) + '></body>';
    } else {
    document.getElementById('taready').value='<body><p></p></body>';
    smts=' with the subject only';
    }
    return true;
    } else {
    //document.getElementById('divplace').innerHTML='Copy failed because ' + (' ' + document.getElementById('taready').value).slice(-10) + ' paste does not match ' + smt + ' copy.';
    document.getElementById('divplace').innerHTML='Copy failed because paste does not match copy.';
    return false;
    }
    } else {
    document.getElementById('divplace').innerHTML='Incorrect data';
    return false;
    }
    }
    </script></head><body onload=\"document.getElementById('taready').focus(); if (wpr) { document.getElementById('status').innerHTML='Copy and Paste Done Below ...'; } \"><h1 id=status>" . $honesmt . "</h1>
    <form target=ifplace onsubmit=\"if (fixta()) { return onsm(); } else { return false; }\" action=./emailhtml.php method=POST>
    <input type=hidden name=inline value=''></input>
    To: <input style=width:80%; type=text name=to value='" . str_replace("+"," ",urldecode($_GET['to'])) . "'></input><br>
    Subject: <input style=width:80%; type=text name=subj value='" . str_replace("+"," ",urldecode($_GET['subj'])) . "'></input><br>
    <textarea style=width:100%;background-color:lightgreen; cols=80 rows=10 name=tdhuhta id=taready></textarea><br><br>
    <input id=sub type=submit style=background-color:yellow; value='Email'></input></form><br>
    <iframe style=display:none; name=ifplace id=ifplace src=./emailhtml.php></iframe>
    <div id=divplace></div>
    </body></html>";
    } else {
    echo "<html><body><p>Incorrect usage.</p></body></html>";
    }
    exit;

    ?>

… to pull all this together in that tighter way (so long Colombo) for you to try yourself.


Previous relevant MacOS and Other Mobile Media Record Tutorial is shown below.

MacOS and Other Mobile Media Record Tutorial

MacOS and Other Mobile Media Record Tutorial

We’re letting a little “dishevelment” continue with today’s work on top of yesterday’s MacOS Speech to Flash Player Audio Record Tutorial.

The reason (to our mind) is that involving mobile functionality into a media web application’s sphere of influence is a big step with more than the usual time needed for testing … well, that’s my excuse, anyway. The major reason for this is that the …


<input type=file accept="video/*,audio/*" capture></input>

… is an incredible recent development (allowing dynamic media creation, with “retake” possibilities, all because of that one “capture” property above) separating the mobile (smart device) platforms from the previous laptop media capture capabilities, and at least doubles the amount of unit testing needed to prove the code workings.

And so, for a little while, some users will be annoyed that they see web application functionality not meant for their platform characteristics.

Sometimes “dishevelment” can work, too, or “stewing for a day”, because it turns out a piece of functionality you thought to be impossible with a particular platform amazingly becomes possible the next day?! Hence the adage … “mulling is amazing”!

Code wise …

  • calls (just like Animated GIF Audio or Video Foreground Tutorial did) the HTML/Javascript the changed client_browsing.htm child web application to handle this HTML input capture usage and interfacing to (now various) parent.window scenarios …
  • called by a changed macos_say_record.php live run link … that relies on our …
  • Inhouse HTML Email helper/creator’s key interfacing code now goes …
    <?php

    $smt="";
    if (isset($_GET['sliceminusten'])) { $smt=' (' . str_replace(" ","+",urldecode($_GET['sliceminusten'])) . ')'; }
    if (strlen($smt) == 13 && strpos(str_replace("+"," ",('' . urldecode($_GET['to']))),"@") !== false && str_replace("+"," ",('' . urldecode($_GET['subj']))) != '') {
    echo "<html><head><script type='text/javascript'>
    var smt=('" . $smt . "').substring(2).substring(0,10), smts='';
    function onsm() {
    var wpr=null;
    var wp=window.parent;
    if (wp) { wpr=parent.document.getElementById('result'); }
    if ((window.opener && window.opener !== window) || (wp && wpr)) {
    if (5 == 5) { // window.opener.document.getElementById('result')) {
    document.getElementById('divplace').innerHTML='Email sent' + smts + '.';
    //alert(window.opener.document.getElementById('result').slice(-10) + ' vs ' + smt);
    return true;
    } else {
    document.getElementById('divplace').innerHTML='Other green textbox not detected.';
    return false;
    }
    } else {
    document.getElementById('divplace').innerHTML='Not a popup window.';
    return false;
    }
    }
    function fixta() {
    if (document.getElementById('taready').value.indexOf('#') == -1 && ((document.getElementById('taready').value.indexOf('data:audio/') == 0 || document.getElementById('taready').value.indexOf('data:video/') == 0) || document.getElementById('taready').value == '')) {
    if (document.getElementById('taready').value == '' || (' ' + document.getElementById('taready').value).slice(-10) == smt) {
    if (document.getElementById('taready').value != '') {
    var midbit=document.getElementById('taready').value.split('data:')[1].split(';')[0] + ' src=' + \"'\";
    document.getElementById('taready').value='<body><' + midbit.substring(0,5) + ' id=thisaudio controls loop><source type=' + midbit + document.getElementById('taready').value.replace(/\ /g,'+') + \"'\" + '></source></' + midbit.substring(0,5) + '></body>';
    } else {
    document.getElementById('taready').value='<body><p></p></body>';
    smts=' with the subject only';
    }
    return true;
    } else {
    //document.getElementById('divplace').innerHTML='Copy failed because ' + (' ' + document.getElementById('taready').value).slice(-10) + ' paste does not match ' + smt + ' copy.';
    document.getElementById('divplace').innerHTML='Copy failed because paste does not match copy.';
    return false;
    }
    } else {
    document.getElementById('divplace').innerHTML='Incorrect data';
    return false;
    }
    }
    </script></head><body onload=\"document.getElementById('taready').focus();\"><h1 id=status>Paste to lightgreen here (already copied from lightgreen there (but recopy and repaste yourself if last characters" . $smt . " do not match) and click yellow button to Email off this Audio player ...</h1>
    <form target=ifplace onsubmit=\"if (fixta()) { return onsm(); } else { return false; }\" action=./emailhtml.php method=POST>
    <input type=hidden name=inline value=''></input>
    To: <input style=width:80%; type=text name=to value='" . str_replace("+"," ",urldecode($_GET['to'])) . "'></input><br>
    Subject: <input style=width:80%; type=text name=subj value='" . str_replace("+"," ",urldecode($_GET['subj'])) . "'></input><br>
    <textarea style=width:100%;background-color:lightgreen; cols=80 rows=10 name=tdhuhta id=taready></textarea><br><br>
    <input id=sub type=submit style=background-color:yellow; value='Email'></input></form><br>
    <iframe style=display:none; name=ifplace id=ifplace src=./emailhtml.php></iframe>
    <div id=divplace></div>
    </body></html>";
    } else {
    echo "<html><body><p>Incorrect usage.</p></body></html>";
    }
    exit;

    ?>

Please feel free to try it out yourself, email sharing as you go.


Previous relevant MacOS Speech to Flash Player Audio Record Tutorial is shown below.

MacOS Speech to Flash Player Audio Record Tutorial

MacOS Speech to Flash Player Audio Record Tutorial

Yesterday’s MacOS Text to Audio Share Tutorial involved …

  • local web server (over macOS) text to audio (via macOS say) programmatical input source for “voiceover” aims … and today, still on …
  • local web server (over macOS) (user) we have speech to audio (via Adobe Flash Player plugin) input source for “voiceover” or “dictation” or “voice memo feeling” aims

… all shareable via email. So these are two non-mobile “voiceover” ideas, and we will present a mobile idea into the future, and thereby open a public domain worthy side to the functionality, then. Rereading here, it just tweaked with us that we can offer this “public domain” aspect even today with a changed macos_say_record.php live run link here, and your Flash Player methodology could work as long as you realize it will be later we hide the inapplicable macOS “say” logics for “public domain” usage.

You’ll see in these changes more interplay among …

  • popup window child windows … and
  • iframe child windows that listen out for the (next) Flash Player *.wav file creation event via a recursive … HTML …
    <?php

    <iframe onload=checkff(this); name=checkflash id=checkflash style=display:none; src='./macos_say_record.php?audiosize=y'></iframe>

    ?>

    <?php

    if (isset($_GET['audiosize'])) {
    // if (file_exists('HTTP://www.rjmprogramming.com.au/MarkItUp/html/audio/audio.wav')) {
    if (isset($_GET['getmecontent'])) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'HTTP://www.rjmprogramming.com.au/MarkItUp/html/audio/audio.wav');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    echo "<html><body onload=\" parent.document.getElementById('audioname').value='audiocapture.wav'; parent.document.getElementById('daudiolater').innerHTML='<audio id=thataudio controls autoplay loop><source type=audio/x-wav src=" . "data:audio/x-wav;base64," . base64_encode($output) . "></source></audio> <a style=display:inline-block;text-decoration:none;cursor:pointer; onclick=emailit(); title=Email>📧</a>';\"><p>" . strlen($output) . "</p><div>data:audio/x-wav;base64," . base64_encode($output) . "</div></body></html>";
    } else {
    //$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
    //$ct=file_get_contents('HTTP://www.rjmprogramming.com.au/MarkItUp/html/audio/audio.wav',false,$context);
    //file_put_contents("x.x",strlen($ct));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'HTTP://www.rjmprogramming.com.au/MarkItUp/html/audio/audio.wav');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    echo "<html><body><p>" . strlen($output) . "</p><div></div></body></html>";
    }
    // } else {
    // echo "<html><body><p>-1</p><div></div></body></html>";
    // }
    exit;
    }

    ?>
    … file_get_contents turning out to be so much slower than curl

Without resorting to any passwords we tighten up the interface to the PHP email helper code at the PHP email helper code end by insisting the email only be sent if the user entry into the interim textarea …

  • contains no “#” characters
  • starts with … data:audio/
  • ends with the same 10 characters passed over to the PHP email helper code

… as per …

<?php

$smt="";
if (isset($_GET['sliceminusten'])) { $smt=' (' . str_replace(" ","+",urldecode($_GET['sliceminusten'])) . ')'; }
if (strlen($smt) == 13 && strpos(str_replace("+"," ",('' . urldecode($_GET['to']))),"@") !== false && str_replace("+"," ",('' . urldecode($_GET['subj']))) != '') {
echo "<html><head><script type='text/javascript'>
var smt=('" . $smt . "').substring(2).substring(0,10), smts='';
function onsm() {
if (window.opener && window.opener !== window) {
if (5 == 5) { // window.opener.document.getElementById('result')) {
document.getElementById('divplace').innerHTML='Email sent' + smts + '.';
//alert(window.opener.document.getElementById('result').slice(-10) + ' vs ' + smt);
return true;
} else {
document.getElementById('divplace').innerHTML='Other green textbox not detected.';
return false;
}
} else {
document.getElementById('divplace').innerHTML='Not a popup window.';
return false;
}
}
function fixta() {
if (document.getElementById('taready').value.indexOf('#') == -1 && (document.getElementById('taready').value.indexOf('data:audio/') == 0 || document.getElementById('taready').value == '')) {
if (document.getElementById('taready').value == '' || (' ' + document.getElementById('taready').value).slice(-10) == smt) {
if (document.getElementById('taready').value != '') {
var midbit=document.getElementById('taready').value.split('data:')[1].split(';')[0] + ' src=' + \"'\";
document.getElementById('taready').value='<body><audio id=thisaudio controls loop><source type=' + midbit + document.getElementById('taready').value.replace(/\ /g,'+') + \"'\" + '></source></audio></body>';
} else {
document.getElementById('taready').value='<body><p></p></body>';
smts=' with the subject only';
}
return true;
} else {
//document.getElementById('divplace').innerHTML='Copy failed because ' + (' ' + document.getElementById('taready').value).slice(-10) + ' paste does not match ' + smt + ' copy.';
document.getElementById('divplace').innerHTML='Copy failed because paste does not match copy.';
return false;
}
} else {
document.getElementById('divplace').innerHTML='Incorrect data';
return false;
}
}
</script></head><body onload=\"document.getElementById('taready').focus();\"><h1 id=status>Paste to lightgreen here (already copied from lightgreen there (but recopy and repaste yourself if last characters" . $smt . " do not match) and click yellow button to Email off this Audio player ...</h1>
<form target=ifplace onsubmit=\"if (fixta()) { return onsm(); } else { return false; }\" action=./emailhtml.php method=POST>
<input type=hidden name=inline value=''></input>
To: <input style=width:80%; type=text name=to value='" . str_replace("+"," ",urldecode($_GET['to'])) . "'></input><br>
Subject: <input style=width:80%; type=text name=subj value='" . str_replace("+"," ",urldecode($_GET['subj'])) . "'></input><br>
<textarea style=width:100%;background-color:lightgreen; cols=80 rows=10 name=tdhuhta id=taready></textarea><br><br>
<input id=sub type=submit style=background-color:yellow; value='Email'></input></form><br>
<iframe style=display:none; name=ifplace id=ifplace src=./emailhtml.php></iframe>
<div id=divplace></div>
</body></html>";
} else {
echo "<html><body><p>Incorrect usage.</p></body></html>";
}
exit;

?>


Previous relevant MacOS Text to Audio Share Tutorial is shown below.

MacOS Text to Audio Share Tutorial

MacOS Text to Audio Share Tutorial

In order to share the audio file of yesterday’s MacOS Text to Audio Internationalization Tutorial we cannot use …

  • client based “a” “mailto:” link approaches because …
    1. the size of data is too large
    2. we need to be able to use HTML within Inline HTML Email if we are not happy leaving around RJM Programming web server audio files (which we are not)

    … and so we need to call on …

  • server (public, not local) based code (ie. PHP, for us) that can email Inline HTML Email

… and calling on that server (public, not local) based code you can choose to …

  • involve CORS in an Ajax FormData call or an HTML Form method=POST … or …
  • involve window.PostMessage approach (perhaps involving web server audio files that are temporary) … or, as we decided upon …
  • involve popup web server “inhouse” PHP Inline HTML Email creator helper … that …
    • codes allowances for the caller situation (that situation having ensured a data-URI “copy” of the audio content in in the web browser buffer ahead of the popup window appearing, all instigated via a new 📧 email emoji button (&#128231;)) …
    • sets up the PHP code …
      <?php

      echo "<html><head><script type='text/javascript'> function fixta() { if (document.getElementById('taready').value.indexOf('data:') == 0) { var midbit=document.getElementById('taready').value.split('data:')[1].split(';')[0] + ' src=' + \"'\"; document.getElementById('taready').value='<body><audio id=thisaudio controls loop><source type=' + midbit + document.getElementById('taready').value.replace(/\ /g,'+') + \"'\" + '></source></audio></body>'; } } </script></head><body onload=\"document.getElementById('taready').focus();\"><h1 id=status>Paste to lightgreen here (already copied from lightgreen there) and click yellow button to Email off ...</h1>
      <form onsubmit='fixta(); return true;' action=./emailhtml.php method=POST>
      <input type=hidden name=inline value=''></input>
      <input type=hidden name=to value='" . str_replace("+"," ",urldecode($_GET['to'])) . "'></input>
      <input type=hidden name=subj value='" . str_replace("+"," ",urldecode($_GET['subj'])) . "'></input>
      <textarea style=width:100%;background-color:lightgreen; cols=80 rows=10 name=tdhuhta id=taready></textarea><br>
      <input id=sub type=submit style=background-color:yellow; value='Email to " . str_replace("+"," ",urldecode($_GET['to'])) . " ... " . str_replace("+"," ",urldecode($_GET['subj'])) . "'></input></form>
      </body></html>";
      exit;

      ?>
    • awaits the user clicking an interim HTML form submit button … that …
    • recalls itself and really sends the Inline HTML Email containing HTML that includes an audio tag with data-URI content

    … this whole scenario only acceptable in its entirety by iOS Mail apps (but not Gmail Webmail nor macOS Mail (at least with our testing)).

    Again, given the same local web server provisions as outlined on the day before yesterday, feel free to try out a changed macos_say_record.php macOS “say” PHP helper with better email sharing functionality.


    Previous relevant MacOS Text to Audio Internationalization Tutorial is shown below.

    MacOS Text to Audio Internationalization Tutorial

    MacOS Text to Audio Internationalization Tutorial

    Yesterday’s MacOS Text to Audio Primer Tutorial was very “English”, at least hereabouts. We think it would be good to Internationalize the “say” integration with “-v” voices in other languages to choose from.

    That “Internationalization” we have Apple to thank for, because “say” documents …

    $ say -v ‘?’
    Alex en_US # Most people recognize me by my voice.
    Alice it_IT # Salve, mi chiamo Alice e sono una voce italiana.
    Alva sv_SE # Hej, jag heter Alva. Jag är en svensk röst.
    Amelie fr_CA # Bonjour, je m’appelle Amelie. Je suis une voix canadienne.
    Anna de_DE # Hallo, ich heiße Anna und ich bin eine deutsche Stimme.
    Carmit he_IL # שלום. קוראים לי כרמית, ואני קול בשפה העברית.
    Claire nl_NL # Hallo, mijn naam is Claire. Ik ben een Nederlandse stem.
    Damayanti id_ID # Halo, nama saya Damayanti. Saya berbahasa Indonesia.
    Daniel en_GB # Hello, my name is Daniel. I am a British-English voice.
    Diego es_AR # Hola, me llamo Diego y soy una voz española.
    Ellen nl_BE # Hallo, mijn naam is Ellen. Ik ben een Belgische stem.
    Fiona en-scotland # Hello, my name is Fiona. I am a Scottish-English voice.
    Fred en_US # I sure like being inside this fancy computer
    Ioana ro_RO # Bună, mă cheamă Ioana . Sunt o voce românească.
    Joana pt_PT # Olá, chamo-me Joana e dou voz ao português falado em Portugal.
    Jorge es_ES # Hola, me llamo Jorge y soy una voz española.
    Juan es_MX # Hola, me llamo Juan y soy una voz mexicana.
    Kanya th_TH # สวัสดีค่ะ ดิฉันชื่อKanya
    Karen en_AU # Hello, my name is Karen. I am an Australian-English voice.
    Kate en_GB # Hello, my name is Kate. I am a British-English voice.
    Kyoko ja_JP # こんにちは、私の名前はKyokoです。日本語の音声をお届けします。
    Laura sk_SK # Ahoj. Volám sa Laura . Som hlas v slovenskom jazyku.
    Lekha hi_IN # नमस्कार, मेरा नाम लेखा है. मैं हिन्दी में बोलने वाली आवाज़ हूँ.
    Luca it_IT # Salve, mi chiamo Luca e sono una voce italiana.
    Luciana pt_BR # Olá, o meu nome é Luciana e a minha voz corresponde ao português que é falado no Brasil
    Maged ar_SA # مرحبًا اسمي Maged. أنا عربي من السعودية.
    Mariska hu_HU # Üdvözlöm! Mariska vagyok. Én vagyok a magyar hang.
    Mei-Jia zh_TW # 您好,我叫美佳。我說國語。
    Melina el_GR # Γεια σας, ονομάζομαι Melina. Είμαι μια ελληνική φωνή.
    Milena ru_RU # Здравствуйте, меня зовут Milena. Я – русский голос системы.
    Moira en_IE # Hello, my name is Moira. I am an Irish-English voice.
    Monica es_ES # Hola, me llamo Monica y soy una voz española.
    Nora nb_NO # Hei, jeg heter Nora. Jeg er en norsk stemme.
    Oliver en_GB # Hello, my name is Oliver. I am a British-English voice.
    Paulina es_MX # Hola, me llamo Paulina y soy una voz mexicana.
    Samantha en_US # Hello, my name is Samantha. I am an American-English voice.
    Sara da_DK # Hej, jeg hedder Sara. Jeg er en dansk stemme.
    Satu fi_FI # Hei, minun nimeni on Satu. Olen suomalainen ääni.
    Serena en_GB # Hello, my name is Serena. I am a British-English voice.
    Sin-ji zh_HK # 您好,我叫 Sin-ji。我講廣東話。
    Tessa en_ZA # Hello, my name is Tessa. I am a South African-English voice.
    Thomas fr_FR # Bonjour, je m’appelle Thomas. Je suis une voix française.
    Ting-Ting zh_CN # 您好,我叫Ting-Ting。我讲中文普通话。
    Tom en_US # Hello, my name is Tom. I am an American-English voice.
    Veena en_IN # Hello, my name is Veena. I am an Indian-English voice.
    Victoria en_US # Isn’t it nice to have a computer that will talk to you?
    Xander nl_NL # Hallo, mijn naam is Xander. Ik ben een Nederlandse stem.
    Yelda tr_TR # Merhaba, benim adım Yelda. Ben Türkçe bir sesim.
    Yuna ko_KR # 안녕하세요. 제 이름은 Yuna입니다. 저는 한국어 음성입니다.
    Yuri ru_RU # Здравствуйте, меня зовут Yuri. Я – русский голос системы.
    Zosia pl_PL # Witaj. Mam na imię Zosia, jestem głosem kobiecym dla języka polskiego.
    Zuzana cs_CZ # Dobrý den, jmenuji se Zuzana. Jsem český hlas.

    … to go on here, as a help for this level of “Internationalization”. Another “level” again would be to translate the webpage and menu wording, but we’ve decided against that here today.

    So we add a language dropdown and a voice dropdown to help the user explore this Text to Audio functionality accessing a macOS or Mac OS X operating system.

    Also, today, we’ve introduced “.m4a” (audio/mp4) as the default audio file extension to use with the file created via “say” “-o” switch for all but Safari, as this works better for “all but Safari” (absolutely).

    Given the same local web server provisions as outlined yesterday feel free to try out a changed macos_say_record.php macOS “say” PHP helper with better Internationalization functionality, thanks in large part to the great ideas from this useful link.


    Previous relevant MacOS Text to Audio Primer Tutorial is shown below.

    MacOS Text to Audio Primer Tutorial

    MacOS Text to Audio Primer Tutorial

    The previous Mac OS X Text to English Speech Primer Tutorial

    • lauded the …

      Text to English Speech via Mac OS X’s command line say command

    • and today we write some PHP (with its very useful exec conduit to “say”) to make use of the same (macOS) “say” and its Text to Audio talents (via its “-o” switch usage)

    … and it’s at times like this we wish that the RJM Programming domain’s web server had a macOS operating system. Alas, “say” is a macOS and Mac OS X application, but not a Linux one.

    None the less, we integrated …

    … so that if you had a MAMP local Apache/PHP/MySql web server going, and you …

    • downloaded tutorial_to_animated_gif.php to same MAMP subdirectory as …
    • downloaded haiku_animated_gif.html to same MAMP place (which can be the same MAMP document root place as talked about below, in which case HTTP://localhost:8888/haiku_animated_gif.html is what you’d type into the web browser address bar to try this for yourself on a macOS or Mac OS X system) … and …
    • downloaded macos_say_record.php to MAMP document root (for us, equating to URL HTTP://localhost:8888/macos_say_record.php)

    … then you would be in the position to see a Haiku creation scenario (where we used the Safari web browser) like with today’s tutorial picture, interesting, in our view, regarding the integration “tactics” …

    • parent Haiku window opens …
    • child (popup) PHP “say” helper web application … which …
    • passes back to parent …

      window.opener.document.getElementById('aurl').value=document.getElementById('result').value;
      window.opener.atab(window.opener.document.getElementById('aurl'));

    … achieving functionality we often ask HTML iframe elements achieve for our code. HTML iframe does have a role today, though. It uses a favoured “client pre-emptive iframe” approach to determine whether we even try to open that popup window above via …

    • HTML …

      <div id=dif></div>
    • Javascript …

      var mampok=false, mampprefix='';

      if (document.URL.indexOf('/localhost') != -1) {
      mampprefix="HTTP://localhost" + document.URL.split('/localhost')[1].split('/')[0] + "/";
      document.getElementById('dif').innerHTML="<iframe onload='oicheck(this);' style='display:none;' src='HTTP://localhost" + document.URL.split('/localhost')[1].split('/')[0] + "/'></iframe>";
      }

      function oicheck(iois) {
      mampok=false;
      if (iois != null) {
      var aconto = (iois.contentWindow || iois.contentDocument);
      if (aconto != null) {
      if (aconto.document) { aconto = aconto.document; }
      if (aconto.body != null) {
      if (aconto.body.innerHTML.toLowerCase().indexOf('>not found<') == -1 && aconto.body.innerHTML.toLowerCase().indexOf("our home page for your perusal") == -1) { mampok=true; }
      }
      }
      }
      }

      // and then later when the textarea has text and its onblur event is triggered ...
      if (mampok) {
      if (wois) { wois.close(); wois=null; }
      wois=window.open(mampprefix + "macos_say_record.php?saythis=" + encodeURIComponent(document.getElementById('myta').value),"_blank","top=460,left=400,width=700,height=400");
      }

    • Previous relevant Mac OS X Text to English Speech Primer Tutorial is shown below.

      Mac OS X Text to English Speech Primer Tutorial

      Mac OS X Text to English Speech Primer Tutorial

      We’ve got a few new ideas today …

      1. Text to English Speech via Mac OS X’s command line say command used by PHP via exec to make say.php (which is useful as a download to a Mac OS X laptop using MAMP) which, today, does not have a live run because the web server of domain rjmprogramming.com.au is a CentOS Linux server … Linux equivalent of Mac OS X’s say? … read here
      2. Trying to present this brought up the usual movie production problem with iMovie overlaying the audio on top of the video (though you may want to try, and you could start reading with this link) versus QuickTime Player talent to catch both audio and video tracks (and that we ended up using), but not of the “screen goings on”, alas versus MPlayer OSX Extended which can play separately but not two tracks on top and doesn’t do any reconstituting … so …
      3. Improved on our inhouse Video/Audio synchronizing efforts by allowing audio_video.html supervisor (changed in this way) be able to be called to press one of its preconceived synchronization buttons onload which we do with (the newly added) Macbeth Act 1 Scene 1 … in a small celebration of the Bard … who, am thinking (in that Falstaff way), would have got a huge chuckle out of “anonymous” instead of “anon” during the Three Witches scene … we had to do something to say Happy Birthday

      Along the way we tried filming the MacBook Pro with the iPad to a YouTube

      … but weren’t happy with the audio quality, alas (too/two).

      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.


      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 Ajax, eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>