Today we incorporate “cow.txt” URL data items into the functionality of our Country Data web application, on top of the progress up to yesterday’s Country Data Long Hover Tutorial.
We’ve decided to present these as …
Emoji Button Links
… a term we use because …
the look is a bit like a button, courtesy of the artistry of the emoji (which is really text, to a webpage … just ask one?!)
the HTML is in the form of an “a” link
All simple, huh?! But there’s the issue, we found, with the URL relevance, on occasions. So we funnel the proposed URL through PHP file_get_contents to determine whether we …
add to existing Wikipedia links off the SVG buttons of the Google Geo Charts that are presented in English … with, today …
allowing for Wikipedia links presented in the selected Google Translate translation language of choice associated with the Country dropdowns and Capital City table cell
But, the question for us was, how best to design that “association”? We decided a “long hover” approach could do, and we intervened, event wise, at …
Non mobile
Mobile
Interest in 8 seconds time? ( ie. “long hover” on non-mobile or “long hold” on mobile )
onmouseover
ontouchstart
Yes
onmouseoout
ontouchend
No
… as per Javascript event code call (for dropdown example) …
limits to Google Translate timings related to Javascript DOM (element populating in particular) can result in half done translations
… within yesterday’s Country Data Geodata Tutorial‘s web application’s design has had us needing to involve PHP into the mix as we try to add “cow.txt” derived country language codes of interest into the Google Translate friendly thanks functionality of our recent and ongoing Country Data web application.
We get help from another language code lookup source, thanks, today, we allow for Language Code presentations that are not just a pretty unfriendly code, only.
an RJM Programming PHP URL equivalent is mapped to a Google Translate one … via …
dot ( ie . ) parts of domain name are replaced by minus ( ie – )
straight after domain name .translate.goog is placed
&_x_tr_tl= GET argument ( eg &_x_tr_tl=ru means translate from “?_x_tr_sl=en” English to Russian )
&data_cc= GET argument is an inhouse construct (yes, you can append your own GET arguments and use a “top.location.href” approach to updating a Google Translate URL ) ( eg &data_cc=AR means display “cow.txt” data relating to Country Code AR which is Argentina )
We use a special blank language code to revert back to an RJM Programming URL from a Google Translate URL using language code EN which is English. Otherwise, once within a Google Translate URL the user generally stays there.
This Google Translate approach does a much more thorough translation job of all the “cow.txt” derived data above the “geodata” HTML mapping iframes, allowing …
Country names
Capital City names
… be translated into many languages that “cow.txt” is not designed to address.
Of particular importance, now, in the revised code, is the use made of the global HTML element attribute “translate” …
The translate attribute specifies whether the content of an element should be translated or not.
… and we use translate=”no” for data “code” elements and translate=”yes” for data “display text (of that code)” elements, so as to Internationalize what this web application is capable of.
great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link
… start to our endeavours without referencing “geodata”. But there is “geodata” in “cow.txt”, and so it behoves us to represent that in a … in a … anyone, anyone? Yes, Anaximander, son of Praxiades … or is that Praximander, son of Anaxiades … please, in future, can you separate or one of you take the town drain home … we can plot positions on a map.
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
add to existing Wikipedia links off the SVG buttons of the Google Geo Charts that are presented in English … with, today …
allowing for Wikipedia links presented in the selected Google Translate translation language of choice associated with the Country dropdowns and Capital City table cell
But, the question for us was, how best to design that “association”? We decided a “long hover” approach could do, and we intervened, event wise, at …
Non mobile
Mobile
Interest in 8 seconds time? ( ie. “long hover” on non-mobile or “long hold” on mobile )
onmouseover
ontouchstart
Yes
onmouseoout
ontouchend
No
… as per Javascript event code call (for dropdown example) …
limits to Google Translate timings related to Javascript DOM (element populating in particular) can result in half done translations
… within yesterday’s Country Data Geodata Tutorial‘s web application’s design has had us needing to involve PHP into the mix as we try to add “cow.txt” derived country language codes of interest into the Google Translate friendly thanks functionality of our recent and ongoing Country Data web application.
We get help from another language code lookup source, thanks, today, we allow for Language Code presentations that are not just a pretty unfriendly code, only.
an RJM Programming PHP URL equivalent is mapped to a Google Translate one … via …
dot ( ie . ) parts of domain name are replaced by minus ( ie – )
straight after domain name .translate.goog is placed
&_x_tr_tl= GET argument ( eg &_x_tr_tl=ru means translate from “?_x_tr_sl=en” English to Russian )
&data_cc= GET argument is an inhouse construct (yes, you can append your own GET arguments and use a “top.location.href” approach to updating a Google Translate URL ) ( eg &data_cc=AR means display “cow.txt” data relating to Country Code AR which is Argentina )
We use a special blank language code to revert back to an RJM Programming URL from a Google Translate URL using language code EN which is English. Otherwise, once within a Google Translate URL the user generally stays there.
This Google Translate approach does a much more thorough translation job of all the “cow.txt” derived data above the “geodata” HTML mapping iframes, allowing …
Country names
Capital City names
… be translated into many languages that “cow.txt” is not designed to address.
Of particular importance, now, in the revised code, is the use made of the global HTML element attribute “translate” …
The translate attribute specifies whether the content of an element should be translated or not.
… and we use translate=”no” for data “code” elements and translate=”yes” for data “display text (of that code)” elements, so as to Internationalize what this web application is capable of.
great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link
… start to our endeavours without referencing “geodata”. But there is “geodata” in “cow.txt”, and so it behoves us to represent that in a … in a … anyone, anyone? Yes, Anaximander, son of Praxiades … or is that Praximander, son of Anaxiades … please, in future, can you separate or one of you take the town drain home … we can plot positions on a map.
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
limits to Google Translate timings related to Javascript DOM (element populating in particular) can result in half done translations
… within yesterday’s Country Data Geodata Tutorial‘s web application’s design has had us needing to involve PHP into the mix as we try to add “cow.txt” derived country language codes of interest into the Google Translate friendly thanks functionality of our recent and ongoing Country Data web application.
We get help from another language code lookup source, thanks, today, we allow for Language Code presentations that are not just a pretty unfriendly code, only.
an RJM Programming PHP URL equivalent is mapped to a Google Translate one … via …
dot ( ie . ) parts of domain name are replaced by minus ( ie – )
straight after domain name .translate.goog is placed
&_x_tr_tl= GET argument ( eg &_x_tr_tl=ru means translate from “?_x_tr_sl=en” English to Russian )
&data_cc= GET argument is an inhouse construct (yes, you can append your own GET arguments and use a “top.location.href” approach to updating a Google Translate URL ) ( eg &data_cc=AR means display “cow.txt” data relating to Country Code AR which is Argentina )
We use a special blank language code to revert back to an RJM Programming URL from a Google Translate URL using language code EN which is English. Otherwise, once within a Google Translate URL the user generally stays there.
This Google Translate approach does a much more thorough translation job of all the “cow.txt” derived data above the “geodata” HTML mapping iframes, allowing …
Country names
Capital City names
… be translated into many languages that “cow.txt” is not designed to address.
Of particular importance, now, in the revised code, is the use made of the global HTML element attribute “translate” …
The translate attribute specifies whether the content of an element should be translated or not.
… and we use translate=”no” for data “code” elements and translate=”yes” for data “display text (of that code)” elements, so as to Internationalize what this web application is capable of.
great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link
… start to our endeavours without referencing “geodata”. But there is “geodata” in “cow.txt”, and so it behoves us to represent that in a … in a … anyone, anyone? Yes, Anaximander, son of Praxiades … or is that Praximander, son of Anaxiades … please, in future, can you separate or one of you take the town drain home … we can plot positions on a map.
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
limits to Google Translate timings related to Javascript DOM (element populating in particular) can result in half done translations
… within yesterday’s Country Data Geodata Tutorial‘s web application’s design has had us needing to involve PHP into the mix as we try to add “cow.txt” derived country language codes of interest into the Google Translate friendly thanks functionality of our recent and ongoing Country Data web application.
We get help from another language code lookup source, thanks, today, we allow for Language Code presentations that are not just a pretty unfriendly code, only.
an RJM Programming PHP URL equivalent is mapped to a Google Translate one … via …
dot ( ie . ) parts of domain name are replaced by minus ( ie – )
straight after domain name .translate.goog is placed
&_x_tr_tl= GET argument ( eg &_x_tr_tl=ru means translate from “?_x_tr_sl=en” English to Russian )
&data_cc= GET argument is an inhouse construct (yes, you can append your own GET arguments and use a “top.location.href” approach to updating a Google Translate URL ) ( eg &data_cc=AR means display “cow.txt” data relating to Country Code AR which is Argentina )
We use a special blank language code to revert back to an RJM Programming URL from a Google Translate URL using language code EN which is English. Otherwise, once within a Google Translate URL the user generally stays there.
This Google Translate approach does a much more thorough translation job of all the “cow.txt” derived data above the “geodata” HTML mapping iframes, allowing …
Country names
Capital City names
… be translated into many languages that “cow.txt” is not designed to address.
Of particular importance, now, in the revised code, is the use made of the global HTML element attribute “translate” …
The translate attribute specifies whether the content of an element should be translated or not.
… and we use translate=”no” for data “code” elements and translate=”yes” for data “display text (of that code)” elements, so as to Internationalize what this web application is capable of.
great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link
… start to our endeavours without referencing “geodata”. But there is “geodata” in “cow.txt”, and so it behoves us to represent that in a … in a … anyone, anyone? Yes, Anaximander, son of Praxiades … or is that Praximander, son of Anaxiades … please, in future, can you separate or one of you take the town drain home … we can plot positions on a map.
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link
… start to our endeavours without referencing “geodata”. But there is “geodata” in “cow.txt”, and so it behoves us to represent that in a … in a … anyone, anyone? Yes, Anaximander, son of Praxiades … or is that Praximander, son of Anaxiades … please, in future, can you separate or one of you take the town drain home … we can plot positions on a map.
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
The other day we came upon a great Open Licence data source concerning a country data “cow.txt” flat file with semicolon column separators, thanks to the heads up at this great link.
With today’s blog posting we start out writing a Javascript and HTML web application using “cow.txt” hosted in an HTML iframe element arrangement, and relying on its “onload” event Javascript language …
PdfImages PDF Output Media Zipping via PHP Tutorial
We’ve both tailored and taken an interest (in the first place) with incorporating PHP’s talents with zipping (via *.zip files) ever since we started PDF to HTML Pdftohtml usage, in today’s work. Why? Well, well, well, we think sharing the resultant HTML (webpage creating) files (and there are usually a lot) created in a new subfolder off MAMP‘s Document Root is quite unwieldy, as the thought of many email attachments is pretty unfriendly for the user. But if we had a PHP created *.zip file encapsulating the contents of this subfolder then the sharing of this *.zip could be much more friendly. Yes, this zip file could be huge, and be too big for emailing purposes, but even so, the Web Share API “AirDrop” option, relevant on macOS, might serve a purpose. It’s up to the user, at some point, but we think it is worth contemplation, and the user has two minutes or more to make up their mind on this …
In a similar line of thinking as with yesterday’s Pdftohtml PDF to HTML via PHP Tutorial we discovered the “brew install poppler” also gave us macOS command line access to the Pdfunite way of concatenating PDFs …
pdfunite(1) General Commands Manual pdfunite(1)
NAME
pdfunite – Portable Document Format (PDF) page merger
DESCRIPTION
pdfunite merges several PDF (Portable Document Format) files in order
of their occurrence on command line to one PDF result file.
Neither of the PDF-sourcefile1 to PDF-sourcefilen should be encrypted.
… which we can incorporate into the PHP logic we use to glean from the user the “path” and “name” of an input PDF. For this, the user would best make two browsing choices via two browsing sessions, and then we offer the user a checkbox checking way they can concatenate those two PDFs into a single one. Should they choose to go down this route, where are we placing this “Pdfunite” created amalgamated single PDF? Well, we’re going to use the PHP sys_get_temp_dir() folder here, and its use forms part of the validation when deciding when the Ajax POSTed data arrives …
… because, as we cannot stress enough, PHP is a powerful bee stingbeasting, able to access operating systems via command line commands. So, please, risk assess all exec and shell_exec and passthru type of code, our call assembled by the Javascript Ajax code …
<?php echo ”
function commandit(whatc) {
var zhr = new XMLHttpRequest();
var zform=new FormData();
zform.append('pdfunitec', whatc);
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
installing Pdfimages on macOS via …
brew install poppler
using a macOS command line (via Terminal application) issued command …
pdfimages -j "September 22 record.pdf" ideas -png
… to extract the 242 images (curiously, as jpeg images) contained within our input PDF.
That “brew install poppler” is the hint, it not being “brew install pdfimages” that there is a lot more than “Pdfimages” to that install (as anybody viewing the relevant animated GIF presentation might attest). We took a look at Oracle’s Pdfimages blurb, and saw nearby the intriguing Pdftohtml writeup, and tried “pdftohtml” on the macOS command line, to realize what could be possible here … spolier alert … lots! Thanks, because converting PDF to HTML (or XML) is very useful functionality in our books … and even our pamphlettes this time?!
So, still under macOS, so far, we interfaced the PHP to Pdftohtml (especially with that -c switch …
can help define email and SMS wording via &wording=[title and text words]
call child external Javascript, and if supervised, can resize grandparent iframe and when file(s) selected can move Web Share API button just below File API button into the iframe “view”, ready for a click that activates Web Share API functionality
… with various tweaks, mainly to the Parent above, regarding CSS (usually via Javascript DOM) styling issues, mainly, to improve the user experience for the scenarios where the Web Share API can be used.
When we presented Web Share API Primer Tutorial some time back we remember palpable excitement that a means by which email attachments could be linked to “a” link “mailto:” looking user controlled email sending (as well as several other sharing options, adding to “Mail”, those being “Messages”, “AirDrop”, “Notes”, “Reminders”, “Simulator”, “Notes”, “More…” here on this macOS MacBook Air, that you might not have thought of to use, all presented on a menu created by the Web Share API) could be at hand. Alas, this “Web Share API” methodology is not supported on all browsers and platforms and protocols. Nonetheless, we want to incorporate it where usable because we have the idea, now, to set up web application design scenarios such as …
can help define email and SMS wording via &wording=[title and text words]
call child external Javascript, and if supervised, can resize grandparent iframe and when file(s) selected can move Web Share API button just below File API button into the iframe “view”, ready for a click that activates Web Share API functionality
Now, as good as the cache is, it cannot be used to be the data for an email attachment or SMS image, because a cache only helps out the webpage it is associated with, nothing beyond. We could do lots of alternative approaches such as …
store and recall in Cookies or window.localStorage
store and recall from a web server file
store and recall in a database
store and recall via the PHP codebase itself
store and recall via element global data attributes available via window.parent iframe element interfacing
pre-prepare a PHP mail based attachment set
… to help out with media sharing via email or SMS. But none of those are what we are doing today, because for the case of …
user enters an all uppercase output media file(s) prefix … there are no issues with sharing anyway … so we think we should just do special arrangements for …
user enters an output media file(s) prefix with some lowercase characters …
… and for these, we’ve decided to offer a user controlling way for them to click a button in time enough to delay the deletion of media files off the web server, and during this “stay of execution”, sharing is available as if the prefix was all uppercase. We use email (📧 📧) and SMS (📟 📟) emoji (“a” “mailto:” and “sms:” prefixed link) buttons with event logic …
function emailit(inais) {
event.stopPropagation();
if (gfirstparam) { delit(gfirstparam, gsecondparam); }
var ext='.mp4';
if (defem == '') { defem=' '; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') { ext='.gif'; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') { ext='.pdf ( or perhaps you want original PDF at " . $infile . " )'; }
//var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext, '');
var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defem.trim());
if (em == null) { em=''; }
if (em.indexOf('@') != -1) {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
defem=em.trim();
document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theaemail target=_blank href='mailto:\" + em + \"?subject=Media%20Share'>Email</a>\";
document.getElementById('theaemail').click();
} else if (em.trim() == '' && em != '') {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
}
return false;
}
function smsit(inais) {
event.stopPropagation();
if (gfirstparam) { delit(gfirstparam, gsecondparam); }
var ext='.mp4';
if (defs == '') { defs=' '; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') { ext='.gif'; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') { ext='.pdf ( or perhaps you want original PDF at " . $infile . " )'; }
var em=prompt('Please enter SMS number to send to for an SMS message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
if (em == null) { em=''; }
if (em.trim() != '') {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
if (em.trim() != '') {
defs=em.trim();
document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
document.getElementById('theasms').click();
}
}
return false;
}
function tryagain() {
ajdone=false;
delit(false, gsecondparam);
}
function delit(istouch, ioissrc) {
var doit=false;
var thingos=ioissrc.split('#');
var zhr = new XMLHttpRequest();
var zform=new FormData();
var dgebih='<iframe name=ifdf id=ifdf style=display:none; src=./php_calls_pdfimages.php></iframe><form target=ifdf style=display:none; method=POST action=./php_calls_pdfimages.php><input type=submit id=divformb value=Submit></input></form>';
if (!istouch && gblurb == '') {
gfirstparam=true;
gsecondparam=ioissrc;
gblurb='. Add spaces to say that it is okay, that in two minutes, will tidy up media files, as first requested.';
}
if (thingos[0].length > 0) {
doit=true;
zform.append('delp', ioissrc.split('#')[0]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delp id=delp value=\"' + ioissrc.split('#')[0] + '\"></input><input type=submit');
}
if (thingos.length > 1) {
if (thingos[1].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[1]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[1] + '\"></input><input type=submit');
} else if (thingos[1].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[1]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[1] + '\"></input><input type=submit');
}
}
if (thingos.length > 2) {
if (thingos[2].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[2]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[2] + '\"></input><input type=submit');
} else if (thingos[2].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[2]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[2] + '\"></input><input type=submit');
}
}
if (istouch) {
zform.append('touch', 'y');
}
if (doit && (!ajdone || istouch)) {
if (!istouch) {
document.getElementById('dpf').innerHTML=dgebih;
document.getElementById('divformb').click();
//alert('0:' + dgebih);
} else {
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
}
ajdone=true;
}
“; ?>
… bordered by a dotted border to indicate time is running out for the user to indicate interest in “media sharing” in their session.
Along the way, we had an idea to improve the chances any videos created will reach the cache. We start using the autoplay attribute when a user’s prefix contains lowercase characters in today’s changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above and below holds ).
Why? Well, our MAMP local web server residing ideas with today’s changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ) have us, perhaps, involving browsed for input PDF files that do not sit within the MAMP document root “realm”. When such a situation develops and we want to add a link for the user to view the input PDF in their MAMP web browser session …
the http Protocol is unable to get to these folders and files … but we can resort to …
a file Protocol way to point a URL where such an input PDF might reside
… but this does not mean you can just expect such a file:// file Protocol URL to work, regarding security issues, with all the platforms and versions of modern web browser. Google Chrome, is an example of a web browser that will not allow the combination of …
file:// URL (file Protocol) … of a …
PDF file pointing URL … hosted in a webpage via an …
iframe element
So what can we do? Well, we’re working in PHP, so we can copy the file:// PDF file into the HTTP:// “realm”, temporarily, display the data, and then tidy up, leaving the (web browser) cache to keep the data intact during that web browser session. We already use the cache this way to allow for a tidy up of files should the user specify a non-all-uppercase prefix for their output media filenames.
It would be good for this arrangement to keep a webpage tab title keeping the name of the original PDF file (in its basename form (ie. not the path)), so we start, with today’s work, also temporarily copying the PDF file into the HTTP:// realm in a new random subfolder with its original filename basename, to facilitate this wish of ours, and later, tidy up. Our other wish is to not need any new PHP code files to achieve this. All possible, and take a look at the PHP …
… regarding this modest additional functionality onto yesterday’s Pdfimages PDF Image Extraction PHP Ffmpeg ImageMagick Tutorial, that is more of interest regarding issues where “desktop” meets “online” woooooorrrrrrlllllddds. What seems straightforward is not always a given.
… are brilliant Open Source products worth knowing. We know them here on our local MacBook Air with its MAMP local Apache/PHP/MySql web server, and have a lot of fun working these products amongst their “media darlings” …
Ffmpeg is great at creating Videos or Animated GIFs from Image input
ImageMagick is great at creating PDFs from Image input (and, as we have already alluded to, creating Images of PDF pages)
… that you might think is overkill, here, with this Pdfimages (is great at creating Images extracted from PDF) work, until the day somebody says …
Oh! By the way! We want this in Such and Such format. We’re sure that’s no trouble, so have a great day. See ya!
And so, moving on from yesterday’s Pdfimages PDF Image Extraction PHP Browsing Tutorial we would like you to install these on your local MAMP environment (by visiting links above, or interpreting PHP code below) …
<?php
if (isset($_POST['install'])) {
if ($_POST['install'] == 'pdfimages') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install popper<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install poppler 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt-get update <br>sudo apt-get install poppler-utils<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt-get update');
$x.=shell_exec('sudo apt-get install poppler-utils');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
} else if ($_POST['install'] == 'ffmpeg') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install ffmpeg<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install ffmpeg 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt update -y <br>sudo apt install ffmpeg -y<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt update -y');
$x.=shell_exec('sudo apt install ffmpeg -y');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
} else if ($_POST['install'] == 'imagemagick') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install imagemagick<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install imagemagick 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt update<br>sudo apt install imagemagick<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt update');
$x.=shell_exec('sudo apt install imagemagick');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
}
exit;
}
?>
… and have the chance to have fun using our three new checkboxes for …
Video
Animated GIF
Image PDF
… additional media output options off the Pdfimages start you make, whether that be via filled in textboxes or the browsing mechanisms to define your input PDF containing this Image input data (you’ll be wanting to refer to as “slides” soon enough).
So, why not re-download the changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ). You still need to follow the client_browsing.htm download instructions, as of yesterday’s work, for local File API browsing.
asked a lot of the user as far as interactive entry goes having to specify …
input PDF file path
input PDF file name
when, in this day and age with the HTML5 and the File API we can browse for that PDF file using a look like those dialogue boxes from the early Windows and Mac OS X desktop application days
We don’t reinvent the wheel here, but tweak our oft-changed inhouse client_browsing.htm (which we’d like you to download to your MAMP local Apache/PHP/MySql web server HTMLCSS folder, you create, off its document root) interfacing to the File API, allowing the interface, within the parent window nested in an iframe element, return …
file base name
file size
… not pushing any barrows chasing the non-generic file path data members available on a rare platform (to fill in our input PDF file path), instead, writing some PHP to try to glean that input PDF file path ourselves, knowing the two pieces of information above …
… can present a form a MAMP webpage user uses to find the input PDF and suggest a prefixing part to the filenames, which will end up creating images from that PDF file as per … [userPrefix]-0.jpg [userPrefix]-1.jpg [userPrefix]-2.jpg etcetera etcetera etcetera
So here’s our source code for php_calls_pdfimages.php as it sits for this first incarnation ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ).
… and that what is a common denominator here to be able to convert between Video and PDF and vice versa, is a set of image slides (or frames) of the animation concerned, today’s being, again, that Ant Video we took on our iPhone (that became the “Star Ant Video”), and that today takes as its starting point …
image slides (or frames) from Video via Slide Images and Back Again via ffmpeg Primer Tutorial our MacBook Pro (via an email attachment download) … a listing of which looks like …
$ ls -l image-000*.jpeg
-rw-r--r-- 1 user admin 170993 26 Jul 11:20 image-0001.jpeg
-rw-r--r-- 1 user admin 205565 26 Jul 11:20 image-0002.jpeg
-rw-r--r-- 1 user admin 218950 26 Jul 11:20 image-0003.jpeg
-rw-r--r-- 1 user admin 164271 26 Jul 11:20 image-0004.jpeg
-rw-r--r-- 1 user admin 171662 26 Jul 11:20 image-0005.jpeg
-rw-r--r-- 1 user admin 155528 26 Jul 11:20 image-0006.jpeg
-rw-r--r-- 1 user admin 53193 26 Jul 11:20 image-0007.jpeg
gets converted to an original (input) PDF (antsoriginal.pdf) (with slideshow capabilities via applications like Mac OS X’s Preview or Adobe Acrobat Reader) via Mac OS X Terminal application command line’s ImageMagick executable convert command …
convert image-000*.jpeg -density 4096 antsoriginal.pdf
… and then we act as though this PDF was our original source of data and decide to …
break that PDF into its constituent image slides (or frames) via …
convert -density 900 antsoriginal.pdf image_pdf.jpeg
… and then use ImageMagick convert commands again to …
crop those image slides via Mac OS X Terminal application command line’s ImageMagick executable convert commands (thanks to this great advice) …
$ convert image_pdf-0.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-0.jpg
$ convert image_pdf-1.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-1.jpg
$ convert image_pdf-2.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-2.jpg
$ convert image_pdf-3.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-3.jpg
$ convert image_pdf-4.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-4.jpg
$ convert image_pdf-5.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-5.jpg
$ convert image_pdf-6.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-6.jpg
… into new PDF slide images (or frames) that can be converted to (output) PDF (antscentral.pdf) via ImageMagick executable convert command …
convert image_pdf*.jpg antscentral.pdf
… to see …
we end up with the (relevant) file listing …
$ ls -l image-000*.jpeg image_pdf*.jp*g ants*l.pdf
-rw-r--r--@ 1 user admin 17405330 15 Aug 12:00 antscentral.pdf
-rw-r--r--@ 1 user admin 1350686 15 Aug 11:53 antsoriginal.pdf
-rw-r--r-- 1 user admin 170993 26 Jul 11:20 image-0001.jpeg
-rw-r--r-- 1 user admin 205565 26 Jul 11:20 image-0002.jpeg
-rw-r--r-- 1 user admin 218950 26 Jul 11:20 image-0003.jpeg
-rw-r--r-- 1 user admin 164271 26 Jul 11:20 image-0004.jpeg
-rw-r--r-- 1 user admin 171662 26 Jul 11:20 image-0005.jpeg
-rw-r--r-- 1 user admin 155528 26 Jul 11:20 image-0006.jpeg
-rw-r--r-- 1 user admin 53193 26 Jul 11:20 image-0007.jpeg
-rw-r--r-- 1 user admin 17643304 15 Aug 11:18 image_pdf-0.jpeg
-rw-r--r-- 1 user admin 2906716 15 Aug 11:56 image_pdf-0.jpg
-rw-r--r-- 1 user admin 18521373 15 Aug 11:18 image_pdf-1.jpeg
-rw-r--r-- 1 user admin 3022841 15 Aug 11:58 image_pdf-1.jpg
-rw-r--r-- 1 user admin 17394312 15 Aug 11:18 image_pdf-2.jpeg
-rw-r--r-- 1 user admin 2762837 15 Aug 11:58 image_pdf-2.jpg
-rw-r--r-- 1 user admin 13963420 15 Aug 11:19 image_pdf-3.jpeg
-rw-r--r-- 1 user admin 2215533 15 Aug 11:58 image_pdf-3.jpg
-rw-r--r-- 1 user admin 16076730 15 Aug 11:19 image_pdf-4.jpeg
-rw-r--r-- 1 user admin 2597147 15 Aug 11:59 image_pdf-4.jpg
-rw-r--r-- 1 user admin 16544272 15 Aug 11:19 image_pdf-5.jpeg
-rw-r--r-- 1 user admin 2840288 15 Aug 11:59 image_pdf-5.jpg
-rw-r--r-- 1 user admin 6870989 15 Aug 11:19 image_pdf-6.jpeg
-rw-r--r-- 1 user admin 1030314 15 Aug 11:59 image_pdf-6.jpg
Just as we decided to reinstall ffmpeg due to that disk crash, we decided to reinstall ImageMagick to this MacBook Pro here, and found, thanks to great advice, we found that we needed to …
install ImageMagick via that previous link’s relevant download link … then at Terminal application command line …
sudo -k ln -s /opt/ImageMagick/bin/convert /usr/bin/convert
install GhostScript via that previous link’s relevant download link … then at Terminal application command line …
sudo -k ln -s /opt/Ghostscript/bin/gs /usr/local/bin/gs
the queen ant (often just one per ant colony) is not a leader as such in thinking out strategies … believe it or not …
it is believed ant colony strategies are worked by what we might call “groupthink”
ants march in line often and the scent that the ants leave behind is pheromone, that non-leader ants follow off that left behind by the “leader ant” … ie. “leader” of position, rather than “leader” of hierarchy
So seeing some ants walking in line up a power pole, used an iPhone to capture a very short video (short enough to use the iPhone’s Photo app’s Share via Mail (attachment) method of emailing to the MacBook Pro, and then (Gmail website) downloading) of this, and later, buck the “ant” trend, and “anthropomorphise” a “star ant”, by honing in on an ant in this video and ring it (and its movement) before creating another “Star Ant Video”.
There are video editing approaches you could use, but what got us interested was the thought of …
break the video into its component parts … just like animations like “Bugs Bunny” … a series of (slide, or frame) images
edit those (slide) images to add the (we’ve decided should be) red ringing of our “Star Ant” … who we’ve decided you, the user can call whatever you so desire … aaaaaaarrrrrrr
reconstitute a new video from some new (slide) image components
That’s where one of our favourite Mac Os X friendly media players, which is also a command line “player” (yayyyyyy!) comes to the fore, for us. It’s the wonderful ffmpeg which we’ve had for a long time now on this MacBook Pro until a disk crash mentioned some weeks back. Could get it back off restore, but decided to reconsitute …
… as a fairly straightforward exercise (given you have Xcode installed already) via a How to install FFmpeg on Mac OS X webpage by René Calles, thanks, heaps, we discovered the commands that worked well for us that go …
… could create those original 7 (slide) images, though the use of a value bigger than 1 frames per second for the “-r” switch could be on the cards for your usages.
How to edit those images? We just used the Mac OS X version of PaintBrush and lined a lot of these images side by side across the screen to try to track our “Star Ant” and award it the “Red Ellipse PaintBrush Order of Merit” (for individualism … tee hee).
Reconstituting the new slides into a new video we remember was another talent of ffmpeg and found this useful webpage, thanks, on the topic of taking raw (slide) images to create a video via ffmpeg. Actually, though, we also had our previous very useful Animated GIF and Video via PHP Writing PHP Data URI Tutorial (presented below) to turn to to end up with the Mac OS X (Terminal session command line command …
ffmpeg -r 1 -i image-%04d.jpg ants.mp4
There are no worries with video file “workings” to do with uppercase and lowercase and names, so we …
cp IMG_0738.MOV ants.mov
… just for some consistency purposes (and could use “mv” to rename instead) so that we can show you …
Before …
After … “Star Ant Video”
See a lot of all these goings on at today’s PDF slideshow.
As useful as “FFmpeg” is, it is not necessarily a default application existing on web server operating systems like our rjmprogramming.com.au’s CentOS server. But we do have it on our Mac OS X (MacBook Pro) operating system’s command line, so we write our PHP determining whether to …
create the video data there and then via “FFmpeg” and PHP’s exec method … or …
provide instructions to be able to create the video back at your client computer (that has “FFmpeg” perhaps) … to suit the …
ffmpeg -r 1 -i %03d.jpg video.mp4
… to create a video called video.mp4 with 1 second delays between (input) slides named 001.jpg then 002.jpg then 003.jpg etcetera … thanks useful webpage for the help … that in the command line can sometimes be played via …
open video.mp4
… or used in some HTML as per …
<video controls id=ivideo type='video/mp4'><source src='video.mp4'></source></video>
… that we show you, below, the Mac OS X local MAMP (Apache/PHP/MySql) web server running of today’s PHP to create …
If you are a regular at this blog and “FFmpeg” sounds a bit familiar to you, that’s probably because you’ve read FFmpeg Image Optimization Primer Tutorial on an earlier occasion … by candlelight … with the lights dimmed?!
Animated GIF and Slideshow via PHP Writing PHP Data URI Tutorial
To us, there are great similarities between animated GIFs and slideshows, as two forms of “presentation”, and so to extend yesterday’s Animated GIF via PHP Writing PHP Data URI Tutorial animated GIF creator “PHP Writes PHP” web application that now has the option for data URI “exports” we add the functionality for …
slideshow creation (using our inhouse methods) which defaults to a horizontal (hashtag type of) navigation … as well as adding a …
slideshow creation, with Data URI image data, using functionality as if CSS z-index (ie. slides stacked on top of each other in “overlay” style) was being used, but actually isn’t …
… that little bit different to another “stacked” (or z-index feeling) approach we talked about with Multiple Class Slideshow Details Tutorial, where HTML element “class” properties were changed so that the last class defined reflects the look of the slideshow slide desired at any given time. We just use an array, and a setTimeout timer to achieve the same ends today, with our work (or “presentation”). If this “horizontal versus stack” navigation choice interests you, also take a read of HTML Input Element Types Randomized History Tutorial.
Again, with all this added functionality, because it is “hosted” in an HTML iframe element all the existant web browser (Windows right click or Mac OS X two finger gesture) functionality can come into play, and make life quite interesting for your non-mobile users “collecting” data URIs … there are worse hobbies!
future mobile development web form navigation benefits from their usage
the use of data URIs make your web pages independent of web server location issues, so make your web data more portable, and flexible
… and ideally, animated GIFs are also not just a decorative part of all this web application usage (as they can be a very efficient representation of an animation that could not be a more succinct way to show that animation or presentation), and if they can be made to be like any other GIF or image data file in the ways they can be represented (and used), then that is all for the good.
So we changed the Jeroen van Wissen’s inspired PHP (“PHP writes PHP” methodology) code tutorial_to_animated_gif.php code allow for this extra animated GIF data URI representation in a new additional HTML iframe (containing the animegif.html of code below) that when harnessing existant web browser (Windows right click or Mac OS X two finger gesture) functionality can glean for us, as required, that animated GIF’s data URI representation. But don’t get too excited about this being rocket science, in that with a bit of effort, and PHP, it could have been gleaned from what we already produced, in that (in PHP “land”) …
$lastbitto="\$fp = fopen('animegif.gif', 'w');
\$data = \$gif->GetAnimation(); \$dataUri = 'data:image/gif;base64,' . base64_encode(\$data);
fwrite(\$fp, \$data);
fclose(\$fp); \$fp = fopen('animegif.html', 'w');
fwrite(\$fp, '<!doctype html><html><body><h1>Data URI version below<h1><br><h4> ... via web browser (Windows right click, Mac OS X two finger gesture ...</h4><br><img src=' . \"\\n\" . \$dataUri . \"\\n\" . ' title=DataURI></img></body></html>');
fclose(\$fp);";
You can see this in the context of how this PHP code changed in this way or try it as a live run.
We find another very useful reason for PHP to write PHP. Today we establish a PHP web application to dynamically create Animated GIF images via some still images, like Gifpal would do.
We have some great open source PHP code to thank for the basis of the functionality we found at Jeroen van Wissen’s very useful link, thanks.
Then we added a more user friendly interface to get the information off the user we need. We present this in an HTML form, which navigates to the same PHP to do the actual assembly of the Animated GIF via techniques where PHP writes PHP … and really needs to, to be useful.
And inside the PHP it makes big use of the GD and Image Functions to read and write the image data we assemble via the user information.
This Animated GIF form of animation is the easiest to implement, as it consists of just the one GIF image file, but the user has very little control over the animation settings, such as the delay between stills, one of the settings we ask about in our web application.
Our PHP source code today you could call tutorial_to_animated_gif.php and we redirect you to some live run ideas …
normal run with HTML form which posts back to itself … live run
example GET parameters run (like our tutorial picture)
Hope you find this tutorial useful.
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.
In a similar line of thinking as with yesterday’s Pdftohtml PDF to HTML via PHP Tutorial we discovered the “brew install poppler” also gave us macOS command line access to the Pdfunite way of concatenating PDFs …
pdfunite(1) General Commands Manual pdfunite(1)
NAME
pdfunite – Portable Document Format (PDF) page merger
DESCRIPTION
pdfunite merges several PDF (Portable Document Format) files in order
of their occurrence on command line to one PDF result file.
Neither of the PDF-sourcefile1 to PDF-sourcefilen should be encrypted.
… which we can incorporate into the PHP logic we use to glean from the user the “path” and “name” of an input PDF. For this, the user would best make two browsing choices via two browsing sessions, and then we offer the user a checkbox checking way they can concatenate those two PDFs into a single one. Should they choose to go down this route, where are we placing this “Pdfunite” created amalgamated single PDF? Well, we’re going to use the PHP sys_get_temp_dir() folder here, and its use forms part of the validation when deciding when the Ajax POSTed data arrives …
… because, as we cannot stress enough, PHP is a powerful bee stingbeasting, able to access operating systems via command line commands. So, please, risk assess all exec and shell_exec and passthru type of code, our call assembled by the Javascript Ajax code …
<?php echo ”
function commandit(whatc) {
var zhr = new XMLHttpRequest();
var zform=new FormData();
zform.append('pdfunitec', whatc);
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
installing Pdfimages on macOS via …
brew install poppler
using a macOS command line (via Terminal application) issued command …
pdfimages -j "September 22 record.pdf" ideas -png
… to extract the 242 images (curiously, as jpeg images) contained within our input PDF.
That “brew install poppler” is the hint, it not being “brew install pdfimages” that there is a lot more than “Pdfimages” to that install (as anybody viewing the relevant animated GIF presentation might attest). We took a look at Oracle’s Pdfimages blurb, and saw nearby the intriguing Pdftohtml writeup, and tried “pdftohtml” on the macOS command line, to realize what could be possible here … spolier alert … lots! Thanks, because converting PDF to HTML (or XML) is very useful functionality in our books … and even our pamphlettes this time?!
So, still under macOS, so far, we interfaced the PHP to Pdftohtml (especially with that -c switch …
can help define email and SMS wording via &wording=[title and text words]
call child external Javascript, and if supervised, can resize grandparent iframe and when file(s) selected can move Web Share API button just below File API button into the iframe “view”, ready for a click that activates Web Share API functionality
… with various tweaks, mainly to the Parent above, regarding CSS (usually via Javascript DOM) styling issues, mainly, to improve the user experience for the scenarios where the Web Share API can be used.
When we presented Web Share API Primer Tutorial some time back we remember palpable excitement that a means by which email attachments could be linked to “a” link “mailto:” looking user controlled email sending (as well as several other sharing options, adding to “Mail”, those being “Messages”, “AirDrop”, “Notes”, “Reminders”, “Simulator”, “Notes”, “More…” here on this macOS MacBook Air, that you might not have thought of to use, all presented on a menu created by the Web Share API) could be at hand. Alas, this “Web Share API” methodology is not supported on all browsers and platforms and protocols. Nonetheless, we want to incorporate it where usable because we have the idea, now, to set up web application design scenarios such as …
can help define email and SMS wording via &wording=[title and text words]
call child external Javascript, and if supervised, can resize grandparent iframe and when file(s) selected can move Web Share API button just below File API button into the iframe “view”, ready for a click that activates Web Share API functionality
Now, as good as the cache is, it cannot be used to be the data for an email attachment or SMS image, because a cache only helps out the webpage it is associated with, nothing beyond. We could do lots of alternative approaches such as …
store and recall in Cookies or window.localStorage
store and recall from a web server file
store and recall in a database
store and recall via the PHP codebase itself
store and recall via element global data attributes available via window.parent iframe element interfacing
pre-prepare a PHP mail based attachment set
… to help out with media sharing via email or SMS. But none of those are what we are doing today, because for the case of …
user enters an all uppercase output media file(s) prefix … there are no issues with sharing anyway … so we think we should just do special arrangements for …
user enters an output media file(s) prefix with some lowercase characters …
… and for these, we’ve decided to offer a user controlling way for them to click a button in time enough to delay the deletion of media files off the web server, and during this “stay of execution”, sharing is available as if the prefix was all uppercase. We use email (📧 📧) and SMS (📟 📟) emoji (“a” “mailto:” and “sms:” prefixed link) buttons with event logic …
function emailit(inais) {
event.stopPropagation();
if (gfirstparam) { delit(gfirstparam, gsecondparam); }
var ext='.mp4';
if (defem == '') { defem=' '; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') { ext='.gif'; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') { ext='.pdf ( or perhaps you want original PDF at " . $infile . " )'; }
//var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext, '');
var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defem.trim());
if (em == null) { em=''; }
if (em.indexOf('@') != -1) {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
defem=em.trim();
document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theaemail target=_blank href='mailto:\" + em + \"?subject=Media%20Share'>Email</a>\";
document.getElementById('theaemail').click();
} else if (em.trim() == '' && em != '') {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
}
return false;
}
function smsit(inais) {
event.stopPropagation();
if (gfirstparam) { delit(gfirstparam, gsecondparam); }
var ext='.mp4';
if (defs == '') { defs=' '; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') { ext='.gif'; }
if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') { ext='.pdf ( or perhaps you want original PDF at " . $infile . " )'; }
var em=prompt('Please enter SMS number to send to for an SMS message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
if (em == null) { em=''; }
if (em.trim() != '') {
if (em.trim() != em && gblurb.trim() != '') {
gblurb=' ';
setTimeout(tryagain, 120000);
}
if (em.trim() != '') {
defs=em.trim();
document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
document.getElementById('theasms').click();
}
}
return false;
}
function tryagain() {
ajdone=false;
delit(false, gsecondparam);
}
function delit(istouch, ioissrc) {
var doit=false;
var thingos=ioissrc.split('#');
var zhr = new XMLHttpRequest();
var zform=new FormData();
var dgebih='<iframe name=ifdf id=ifdf style=display:none; src=./php_calls_pdfimages.php></iframe><form target=ifdf style=display:none; method=POST action=./php_calls_pdfimages.php><input type=submit id=divformb value=Submit></input></form>';
if (!istouch && gblurb == '') {
gfirstparam=true;
gsecondparam=ioissrc;
gblurb='. Add spaces to say that it is okay, that in two minutes, will tidy up media files, as first requested.';
}
if (thingos[0].length > 0) {
doit=true;
zform.append('delp', ioissrc.split('#')[0]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delp id=delp value=\"' + ioissrc.split('#')[0] + '\"></input><input type=submit');
}
if (thingos.length > 1) {
if (thingos[1].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[1]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[1] + '\"></input><input type=submit');
} else if (thingos[1].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[1]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[1] + '\"></input><input type=submit');
}
}
if (thingos.length > 2) {
if (thingos[2].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[2]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[2] + '\"></input><input type=submit');
} else if (thingos[2].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[2]);
dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[2] + '\"></input><input type=submit');
}
}
if (istouch) {
zform.append('touch', 'y');
}
if (doit && (!ajdone || istouch)) {
if (!istouch) {
document.getElementById('dpf').innerHTML=dgebih;
document.getElementById('divformb').click();
//alert('0:' + dgebih);
} else {
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
}
ajdone=true;
}
“; ?>
… bordered by a dotted border to indicate time is running out for the user to indicate interest in “media sharing” in their session.
Along the way, we had an idea to improve the chances any videos created will reach the cache. We start using the autoplay attribute when a user’s prefix contains lowercase characters in today’s changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above and below holds ).
Why? Well, our MAMP local web server residing ideas with today’s changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ) have us, perhaps, involving browsed for input PDF files that do not sit within the MAMP document root “realm”. When such a situation develops and we want to add a link for the user to view the input PDF in their MAMP web browser session …
the http Protocol is unable to get to these folders and files … but we can resort to …
a file Protocol way to point a URL where such an input PDF might reside
… but this does not mean you can just expect such a file:// file Protocol URL to work, regarding security issues, with all the platforms and versions of modern web browser. Google Chrome, is an example of a web browser that will not allow the combination of …
file:// URL (file Protocol) … of a …
PDF file pointing URL … hosted in a webpage via an …
iframe element
So what can we do? Well, we’re working in PHP, so we can copy the file:// PDF file into the HTTP:// “realm”, temporarily, display the data, and then tidy up, leaving the (web browser) cache to keep the data intact during that web browser session. We already use the cache this way to allow for a tidy up of files should the user specify a non-all-uppercase prefix for their output media filenames.
It would be good for this arrangement to keep a webpage tab title keeping the name of the original PDF file (in its basename form (ie. not the path)), so we start, with today’s work, also temporarily copying the PDF file into the HTTP:// realm in a new random subfolder with its original filename basename, to facilitate this wish of ours, and later, tidy up. Our other wish is to not need any new PHP code files to achieve this. All possible, and take a look at the PHP …
… regarding this modest additional functionality onto yesterday’s Pdfimages PDF Image Extraction PHP Ffmpeg ImageMagick Tutorial, that is more of interest regarding issues where “desktop” meets “online” woooooorrrrrrlllllddds. What seems straightforward is not always a given.
… are brilliant Open Source products worth knowing. We know them here on our local MacBook Air with its MAMP local Apache/PHP/MySql web server, and have a lot of fun working these products amongst their “media darlings” …
Ffmpeg is great at creating Videos or Animated GIFs from Image input
ImageMagick is great at creating PDFs from Image input (and, as we have already alluded to, creating Images of PDF pages)
… that you might think is overkill, here, with this Pdfimages (is great at creating Images extracted from PDF) work, until the day somebody says …
Oh! By the way! We want this in Such and Such format. We’re sure that’s no trouble, so have a great day. See ya!
And so, moving on from yesterday’s Pdfimages PDF Image Extraction PHP Browsing Tutorial we would like you to install these on your local MAMP environment (by visiting links above, or interpreting PHP code below) …
<?php
if (isset($_POST['install'])) {
if ($_POST['install'] == 'pdfimages') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install popper<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install poppler 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt-get update <br>sudo apt-get install poppler-utils<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt-get update');
$x.=shell_exec('sudo apt-get install poppler-utils');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
} else if ($_POST['install'] == 'ffmpeg') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install ffmpeg<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install ffmpeg 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt update -y <br>sudo apt install ffmpeg -y<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt update -y');
$x.=shell_exec('sudo apt install ffmpeg -y');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
} else if ($_POST['install'] == 'imagemagick') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="<p>Regarding ...<br><br>brew install imagemagick<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('brew install imagemagick 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "<html><body><pre>" . $x . "</pre></body></html>";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="<p>Regarding ...<br><br>sudo apt update<br>sudo apt install imagemagick<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
$x.=shell_exec('sudo apt update');
$x.=shell_exec('sudo apt install imagemagick');
echo "<html><body><pre>" . $x . "</pre></body></html>";
}
}
exit;
}
?>
… and have the chance to have fun using our three new checkboxes for …
Video
Animated GIF
Image PDF
… additional media output options off the Pdfimages start you make, whether that be via filled in textboxes or the browsing mechanisms to define your input PDF containing this Image input data (you’ll be wanting to refer to as “slides” soon enough).
So, why not re-download the changedphp_calls_pdfimages.phpMAMP local Apache/PHP/MySql web server’s document root ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ). You still need to follow the client_browsing.htm download instructions, as of yesterday’s work, for local File API browsing.
asked a lot of the user as far as interactive entry goes having to specify …
input PDF file path
input PDF file name
when, in this day and age with the HTML5 and the File API we can browse for that PDF file using a look like those dialogue boxes from the early Windows and Mac OS X desktop application days
We don’t reinvent the wheel here, but tweak our oft-changed inhouse client_browsing.htm (which we’d like you to download to your MAMP local Apache/PHP/MySql web server HTMLCSS folder, you create, off its document root) interfacing to the File API, allowing the interface, within the parent window nested in an iframe element, return …
file base name
file size
… not pushing any barrows chasing the non-generic file path data members available on a rare platform (to fill in our input PDF file path), instead, writing some PHP to try to glean that input PDF file path ourselves, knowing the two pieces of information above …
… can present a form a MAMP webpage user uses to find the input PDF and suggest a prefixing part to the filenames, which will end up creating images from that PDF file as per … [userPrefix]-0.jpg [userPrefix]-1.jpg [userPrefix]-2.jpg etcetera etcetera etcetera
So here’s our source code for php_calls_pdfimages.php as it sits for this first incarnation ( ie. using a MAMP macOS URL HTTP://localhost:8888/php_calls_pdfimages.php and may take you there with this public domain RJM Programming link if all of above holds ).
… and that what is a common denominator here to be able to convert between Video and PDF and vice versa, is a set of image slides (or frames) of the animation concerned, today’s being, again, that Ant Video we took on our iPhone (that became the “Star Ant Video”), and that today takes as its starting point …
image slides (or frames) from Video via Slide Images and Back Again via ffmpeg Primer Tutorial our MacBook Pro (via an email attachment download) … a listing of which looks like …
$ ls -l image-000*.jpeg
-rw-r--r-- 1 user admin 170993 26 Jul 11:20 image-0001.jpeg
-rw-r--r-- 1 user admin 205565 26 Jul 11:20 image-0002.jpeg
-rw-r--r-- 1 user admin 218950 26 Jul 11:20 image-0003.jpeg
-rw-r--r-- 1 user admin 164271 26 Jul 11:20 image-0004.jpeg
-rw-r--r-- 1 user admin 171662 26 Jul 11:20 image-0005.jpeg
-rw-r--r-- 1 user admin 155528 26 Jul 11:20 image-0006.jpeg
-rw-r--r-- 1 user admin 53193 26 Jul 11:20 image-0007.jpeg
gets converted to an original (input) PDF (antsoriginal.pdf) (with slideshow capabilities via applications like Mac OS X’s Preview or Adobe Acrobat Reader) via Mac OS X Terminal application command line’s ImageMagick executable convert command …
convert image-000*.jpeg -density 4096 antsoriginal.pdf
… and then we act as though this PDF was our original source of data and decide to …
break that PDF into its constituent image slides (or frames) via …
convert -density 900 antsoriginal.pdf image_pdf.jpeg
… and then use ImageMagick convert commands again to …
crop those image slides via Mac OS X Terminal application command line’s ImageMagick executable convert commands (thanks to this great advice) …
$ convert image_pdf-0.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-0.jpg
$ convert image_pdf-1.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-1.jpg
$ convert image_pdf-2.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-2.jpg
$ convert image_pdf-3.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-3.jpg
$ convert image_pdf-4.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-4.jpg
$ convert image_pdf-5.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-5.jpg
$ convert image_pdf-6.jpeg -crop 3000x6000+4000+4000 -gravity center image_pdf-6.jpg
… into new PDF slide images (or frames) that can be converted to (output) PDF (antscentral.pdf) via ImageMagick executable convert command …
convert image_pdf*.jpg antscentral.pdf
… to see …
we end up with the (relevant) file listing …
$ ls -l image-000*.jpeg image_pdf*.jp*g ants*l.pdf
-rw-r--r--@ 1 user admin 17405330 15 Aug 12:00 antscentral.pdf
-rw-r--r--@ 1 user admin 1350686 15 Aug 11:53 antsoriginal.pdf
-rw-r--r-- 1 user admin 170993 26 Jul 11:20 image-0001.jpeg
-rw-r--r-- 1 user admin 205565 26 Jul 11:20 image-0002.jpeg
-rw-r--r-- 1 user admin 218950 26 Jul 11:20 image-0003.jpeg
-rw-r--r-- 1 user admin 164271 26 Jul 11:20 image-0004.jpeg
-rw-r--r-- 1 user admin 171662 26 Jul 11:20 image-0005.jpeg
-rw-r--r-- 1 user admin 155528 26 Jul 11:20 image-0006.jpeg
-rw-r--r-- 1 user admin 53193 26 Jul 11:20 image-0007.jpeg
-rw-r--r-- 1 user admin 17643304 15 Aug 11:18 image_pdf-0.jpeg
-rw-r--r-- 1 user admin 2906716 15 Aug 11:56 image_pdf-0.jpg
-rw-r--r-- 1 user admin 18521373 15 Aug 11:18 image_pdf-1.jpeg
-rw-r--r-- 1 user admin 3022841 15 Aug 11:58 image_pdf-1.jpg
-rw-r--r-- 1 user admin 17394312 15 Aug 11:18 image_pdf-2.jpeg
-rw-r--r-- 1 user admin 2762837 15 Aug 11:58 image_pdf-2.jpg
-rw-r--r-- 1 user admin 13963420 15 Aug 11:19 image_pdf-3.jpeg
-rw-r--r-- 1 user admin 2215533 15 Aug 11:58 image_pdf-3.jpg
-rw-r--r-- 1 user admin 16076730 15 Aug 11:19 image_pdf-4.jpeg
-rw-r--r-- 1 user admin 2597147 15 Aug 11:59 image_pdf-4.jpg
-rw-r--r-- 1 user admin 16544272 15 Aug 11:19 image_pdf-5.jpeg
-rw-r--r-- 1 user admin 2840288 15 Aug 11:59 image_pdf-5.jpg
-rw-r--r-- 1 user admin 6870989 15 Aug 11:19 image_pdf-6.jpeg
-rw-r--r-- 1 user admin 1030314 15 Aug 11:59 image_pdf-6.jpg
Just as we decided to reinstall ffmpeg due to that disk crash, we decided to reinstall ImageMagick to this MacBook Pro here, and found, thanks to great advice, we found that we needed to …
install ImageMagick via that previous link’s relevant download link … then at Terminal application command line …
sudo -k ln -s /opt/ImageMagick/bin/convert /usr/bin/convert
install GhostScript via that previous link’s relevant download link … then at Terminal application command line …
sudo -k ln -s /opt/Ghostscript/bin/gs /usr/local/bin/gs
the queen ant (often just one per ant colony) is not a leader as such in thinking out strategies … believe it or not …
it is believed ant colony strategies are worked by what we might call “groupthink”
ants march in line often and the scent that the ants leave behind is pheromone, that non-leader ants follow off that left behind by the “leader ant” … ie. “leader” of position, rather than “leader” of hierarchy
So seeing some ants walking in line up a power pole, used an iPhone to capture a very short video (short enough to use the iPhone’s Photo app’s Share via Mail (attachment) method of emailing to the MacBook Pro, and then (Gmail website) downloading) of this, and later, buck the “ant” trend, and “anthropomorphise” a “star ant”, by honing in on an ant in this video and ring it (and its movement) before creating another “Star Ant Video”.
There are video editing approaches you could use, but what got us interested was the thought of …
break the video into its component parts … just like animations like “Bugs Bunny” … a series of (slide, or frame) images
edit those (slide) images to add the (we’ve decided should be) red ringing of our “Star Ant” … who we’ve decided you, the user can call whatever you so desire … aaaaaaarrrrrrr
reconstitute a new video from some new (slide) image components
That’s where one of our favourite Mac Os X friendly media players, which is also a command line “player” (yayyyyyy!) comes to the fore, for us. It’s the wonderful ffmpeg which we’ve had for a long time now on this MacBook Pro until a disk crash mentioned some weeks back. Could get it back off restore, but decided to reconsitute …
… as a fairly straightforward exercise (given you have Xcode installed already) via a How to install FFmpeg on Mac OS X webpage by René Calles, thanks, heaps, we discovered the commands that worked well for us that go …
… could create those original 7 (slide) images, though the use of a value bigger than 1 frames per second for the “-r” switch could be on the cards for your usages.
How to edit those images? We just used the Mac OS X version of PaintBrush and lined a lot of these images side by side across the screen to try to track our “Star Ant” and award it the “Red Ellipse PaintBrush Order of Merit” (for individualism … tee hee).
Reconstituting the new slides into a new video we remember was another talent of ffmpeg and found this useful webpage, thanks, on the topic of taking raw (slide) images to create a video via ffmpeg. Actually, though, we also had our previous very useful Animated GIF and Video via PHP Writing PHP Data URI Tutorial (presented below) to turn to to end up with the Mac OS X (Terminal session command line command …
ffmpeg -r 1 -i image-%04d.jpg ants.mp4
There are no worries with video file “workings” to do with uppercase and lowercase and names, so we …
cp IMG_0738.MOV ants.mov
… just for some consistency purposes (and could use “mv” to rename instead) so that we can show you …
Before …
After … “Star Ant Video”
See a lot of all these goings on at today’s PDF slideshow.
As useful as “FFmpeg” is, it is not necessarily a default application existing on web server operating systems like our rjmprogramming.com.au’s CentOS server. But we do have it on our Mac OS X (MacBook Pro) operating system’s command line, so we write our PHP determining whether to …
create the video data there and then via “FFmpeg” and PHP’s exec method … or …
provide instructions to be able to create the video back at your client computer (that has “FFmpeg” perhaps) … to suit the …
ffmpeg -r 1 -i %03d.jpg video.mp4
… to create a video called video.mp4 with 1 second delays between (input) slides named 001.jpg then 002.jpg then 003.jpg etcetera … thanks useful webpage for the help … that in the command line can sometimes be played via …
open video.mp4
… or used in some HTML as per …
<video controls id=ivideo type='video/mp4'><source src='video.mp4'></source></video>
… that we show you, below, the Mac OS X local MAMP (Apache/PHP/MySql) web server running of today’s PHP to create …
If you are a regular at this blog and “FFmpeg” sounds a bit familiar to you, that’s probably because you’ve read FFmpeg Image Optimization Primer Tutorial on an earlier occasion … by candlelight … with the lights dimmed?!
Animated GIF and Slideshow via PHP Writing PHP Data URI Tutorial
To us, there are great similarities between animated GIFs and slideshows, as two forms of “presentation”, and so to extend yesterday’s Animated GIF via PHP Writing PHP Data URI Tutorial animated GIF creator “PHP Writes PHP” web application that now has the option for data URI “exports” we add the functionality for …
slideshow creation (using our inhouse methods) which defaults to a horizontal (hashtag type of) navigation … as well as adding a …
slideshow creation, with Data URI image data, using functionality as if CSS z-index (ie. slides stacked on top of each other in “overlay” style) was being used, but actually isn’t …
… that little bit different to another “stacked” (or z-index feeling) approach we talked about with Multiple Class Slideshow Details Tutorial, where HTML element “class” properties were changed so that the last class defined reflects the look of the slideshow slide desired at any given time. We just use an array, and a setTimeout timer to achieve the same ends today, with our work (or “presentation”). If this “horizontal versus stack” navigation choice interests you, also take a read of HTML Input Element Types Randomized History Tutorial.
Again, with all this added functionality, because it is “hosted” in an HTML iframe element all the existant web browser (Windows right click or Mac OS X two finger gesture) functionality can come into play, and make life quite interesting for your non-mobile users “collecting” data URIs … there are worse hobbies!
future mobile development web form navigation benefits from their usage
the use of data URIs make your web pages independent of web server location issues, so make your web data more portable, and flexible
… and ideally, animated GIFs are also not just a decorative part of all this web application usage (as they can be a very efficient representation of an animation that could not be a more succinct way to show that animation or presentation), and if they can be made to be like any other GIF or image data file in the ways they can be represented (and used), then that is all for the good.
So we changed the Jeroen van Wissen’s inspired PHP (“PHP writes PHP” methodology) code tutorial_to_animated_gif.php code allow for this extra animated GIF data URI representation in a new additional HTML iframe (containing the animegif.html of code below) that when harnessing existant web browser (Windows right click or Mac OS X two finger gesture) functionality can glean for us, as required, that animated GIF’s data URI representation. But don’t get too excited about this being rocket science, in that with a bit of effort, and PHP, it could have been gleaned from what we already produced, in that (in PHP “land”) …
$lastbitto="\$fp = fopen('animegif.gif', 'w');
\$data = \$gif->GetAnimation(); \$dataUri = 'data:image/gif;base64,' . base64_encode(\$data);
fwrite(\$fp, \$data);
fclose(\$fp); \$fp = fopen('animegif.html', 'w');
fwrite(\$fp, '<!doctype html><html><body><h1>Data URI version below<h1><br><h4> ... via web browser (Windows right click, Mac OS X two finger gesture ...</h4><br><img src=' . \"\\n\" . \$dataUri . \"\\n\" . ' title=DataURI></img></body></html>');
fclose(\$fp);";
You can see this in the context of how this PHP code changed in this way or try it as a live run.
We find another very useful reason for PHP to write PHP. Today we establish a PHP web application to dynamically create Animated GIF images via some still images, like Gifpal would do.
We have some great open source PHP code to thank for the basis of the functionality we found at Jeroen van Wissen’s very useful link, thanks.
Then we added a more user friendly interface to get the information off the user we need. We present this in an HTML form, which navigates to the same PHP to do the actual assembly of the Animated GIF via techniques where PHP writes PHP … and really needs to, to be useful.
And inside the PHP it makes big use of the GD and Image Functions to read and write the image data we assemble via the user information.
This Animated GIF form of animation is the easiest to implement, as it consists of just the one GIF image file, but the user has very little control over the animation settings, such as the delay between stills, one of the settings we ask about in our web application.
Our PHP source code today you could call tutorial_to_animated_gif.php and we redirect you to some live run ideas …
normal run with HTML form which posts back to itself … live run
example GET parameters run (like our tutorial picture)
Hope you find this tutorial useful.
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.