' . basename(str_replace('"','',$infile)) . '';
} else if (isset($_POST['convertthis'])) {
$infile='"' . $pathp . str_replace('+',' ',urldecode($_POST['convertthis'])) . '"';
$fextra=' ' . basename(str_replace('"','',$infile)) . '';
}
if (isset($_POST['delv'])) {
if ($_POST['delv'] != '') {
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delv'])) . "?"), ".mp4?") !== false) {
sleep(20);
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
ourunlink(basename(str_replace('+',' ', urldecode($_POST['delv']))));
}
}
}
if (!isset($_POST['delp']) && !isset($_POST['dela'])) {
exit;
}
}
}
if (isset($_POST['dela'])) {
if ($_POST['dela'] != '') {
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['dela'])) . "?"), ".gif?") !== false) {
sleep(20);
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
ourunlink(basename(str_replace('+',' ', urldecode($_POST['dela']))));
}
}
}
if (!isset($_POST['delp'])) {
exit;
}
}
}
if (isset($_POST['delp'])) {
if ($_POST['delp'] != '') {
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delp'])) . "?"), ".pdf?") !== false) {
sleep(20);
if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
ourunlink(basename(str_replace('+',' ', urldecode($_POST['delp']))));
}
}
}
exit;
}
}
$vsw=0;
$vw=720;
$vh=540;
$dovideo=false;
$doag=false;
$dopdf=false;
$sparepdf="";
if (isset($_GET['dovideo']) || isset($_POST['dovideo'])) {
$dovideo=true;
}
if (isset($_GET['doag']) || isset($_POST['doag'])) {
$doag=true;
}
if (isset($_GET['dopdf']) || isset($_POST['dopdf'])) {
$dopdf=true;
}
$vsw=0;
$vw=720;
$vh=540;
if (isset($_GET['sw'])) {
$vsw=intval($_GET['sw']);
$vh=(540 * (720 / ($vsw * 0.48)));
$vw=($vsw * 0.48);
$vh=explode(".", "$vh")[0];
$vh /= 2;
$vh=explode(".", "$vh")[0];
$vh *= 2;
$vh=explode(".", "$vh")[0];
$vw=explode(".", "$vw")[0];
$vw /= 2;
$vw=explode(".", "$vw")[0];
$vw *= 2;
$vh=intval("$vh");
$vw=intval("$vw");
//echo $vh . ',' . $vw . ' via ' . $vsw;
//exit;
} else if (isset($_POST['sw'])) {
$vsw=intval($_POST['sw']);
$vh=(540 * (720 / ($vsw * 0.48)));
$vw=($vsw * 0.48);
$vh=explode(".", "$vh")[0];
$vh /= 2;
$vh=explode(".", "$vh")[0];
$vh *= 2;
$vh=explode(".", "$vh")[0];
$vw=explode(".", "$vw")[0];
$vw /= 2;
$vw=explode(".", "$vw")[0];
$vw *= 2;
$vh=intval("$vh");
$vw=intval("$vw");
//echo $vh . ',' . $vw . ' via ' . $vsw;
//exit;
}
if (isset($_GET['install'])) {
if ($_GET['install'] == 'pdfimages') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="
Regarding ...
brew install popper
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install poppler 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt-get update
sudo apt-get install poppler-utils
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt-get update');
$x.=shell_exec('sudo apt-get install poppler-utils');
echo "
" . $x . "
";
}
} else if ($_GET['install'] == 'ffmpeg') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="Regarding ...
brew install ffmpeg
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install ffmpeg 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt update -y
sudo apt install ffmpeg -y
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt update -y');
$x.=shell_exec('sudo apt install ffmpeg -y');
echo "
" . $x . "
";
}
} else if ($_GET['install'] == 'imagemagick') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="Regarding ...
brew install imagemagick
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install imagemagick 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt update
sudo apt install imagemagick
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt update');
$x.=shell_exec('sudo apt install imagemagick');
echo "
" . $x . "
";
}
}
exit;
}
if (isset($_POST['install'])) {
if ($_POST['install'] == 'pdfimages') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="Regarding ...
brew install popper
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install poppler 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt-get update
sudo apt-get install poppler-utils
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt-get update');
$x.=shell_exec('sudo apt-get install poppler-utils');
echo "
" . $x . "
";
}
} else if ($_POST['install'] == 'ffmpeg') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="Regarding ...
brew install ffmpeg
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install ffmpeg 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt update -y
sudo apt install ffmpeg -y
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt update -y');
$x.=shell_exec('sudo apt install ffmpeg -y');
echo "
" . $x . "
";
}
} else if ($_POST['install'] == 'imagemagick') {
if (PHP_OS == "Darwin") {
putenv('PATH=/usr/local/bin');
$x="Regarding ...
brew install imagemagick
If errors below, you should try command above, yourself, on command line ...
";
$x.=shell_exec('brew install imagemagick 2> huh.jnk');
if (file_exists('huhjunk.jnk')) {
$x.=file_get_contents('huhjnk.jnk');
unlink('huh.jnk');
}
echo "
" . $x . "
";
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$x="Regarding ...
sudo apt update
sudo apt install imagemagick
If errors below, you should try commands above, yourself, on command line ...
";
$x.=shell_exec('sudo apt update');
$x.=shell_exec('sudo apt install imagemagick');
echo "
" . $x . "
";
}
}
exit;
}
$filepath='';
$rest="";
$restfrom="";
$restto="
... or ...
";
function rsearch($folder, $pattern, $size) { // thanks, anyway, to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
$didea='';
if (PHP_OS == "Darwin") {
//file_put_contents("x.ksh", "find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
if ($folder == DIRECTORY_SEPARATOR) {
$didea=shell_exec("find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xx.ksh", $didea);
if ($didea != '') { return $didea; }
$didea=shell_exec("find " . dirname(__FILE__) . DIRECTORY_SEPARATOR . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xxx.ksh", $didea);
if ($didea != '') { return $didea; }
}
return shell_exec("find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
}
//$iti = new RecursiveDirectoryIterator($folder);
//foreach (new RecursiveIteratorIterator($iti) as $file) {
//foreach (glob($folder . $pattern) as $file) {
// if (strpos($file , $pattern) !== false && filesize($file) == $size) {
// return $file;
// }
//}
return '';
}
if (isset($_GET['filename']) && isset($_GET['filesize']) && !isset($_GET['filepath'])) {
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
}
}
if ($filepath == '') {
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
}
echo "";
exit;
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && $_GET['filepath'] == '') {
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
}
}
if ($filepath == '') {
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
}
echo "";
exit;
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && isset($_GET['filepath'])) {
$anyextrac='';
if (substr(str_replace('+',' ',urldecode($_GET['filepath'])), -1, 1) != DIRECTORY_SEPARATOR) {
$anyextrac=DIRECTORY_SEPARATOR;
}
echo "";
exit;
}
$outp='ideas';
if (isset($_GET['outprefix'])) {
$outp=str_replace('+',' ',urldecode($_GET['outprefix']));
if (trim($outp) == "") { $outp='ideas'; }
} else if (isset($_POST['outprefix'])) {
$outp=str_replace('+',' ',urldecode($_POST['outprefix']));
if (trim($outp) == "") { $outp='ideas'; }
}
$origoutp=$outp;
$hashbit="";
$olhashbit="";
if ($outp != strtoupper($outp)) {
if ($doag && $dovideo) {
$hashbit=" + '#" . strtoupper($outp) . ".mp4#" . strtoupper($outp) . ".gif'";
} else if ($dovideo) {
$hashbit=" + '#" . strtoupper($outp) . ".mp4'";
} else if ($doag) {
$hashbit=" + '#" . strtoupper($outp) . ".gif'";
}
}
if (!$dopdf && $hashbit != '' && $outp != strtoupper($outp)) {
$olhashbit='';
} else if ($dopdf && $hashbit != '' && $outp != strtoupper($outp)) {
$olhashbit='';
} else if ($dopdf && $hashbit == '' && $outp != strtoupper($outp)) {
$olhashbit='';
}
$outp=strtoupper($outp);
$proposedtable="
var dmode='ltor';
var lastpath='', lastfilename='';
function woit(ioo) {
var wo=null;
if (ioo.src.indexOf('data:') == 0) {
wo=window.open('', '_blank');
wo.document.write('');
wo.document.title=ioo.title;
} else {
window.open(ioo.src, '_blank');
}
}
function checkf() {
if (document.getElementById('justputpdffilename')) {
if (document.getElementById('justputpdffilename').innerHTML != '') {
document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
document.getElementById('justputpdffilename').innerHTML='';
if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
lastfilename=document.getElementById('justputpdffilename').title;
}
if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
if (document.getElementById('justputpdffilesize').innerHTML != '') {
//alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML);
document.getElementById('justputpdfpath').title=' ';
//var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename));
document.getElementById('path').style.cursor='progress';
document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename);
}
}
}
if (document.getElementById('justputpdfpath').innerHTML != '') {
document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
document.getElementById('justputpdfpath').innerHTML='';
if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
document.getElementById('justputpdfpath').title+='/';
}
} else {
if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
}
}
if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
document.getElementById('path').value=document.getElementById('justputpdfpath').title;
lastpath=document.getElementById('justputpdfpath').title;
}
}
if (document.getElementById('path').value != '') {
document.getElementById('path').style.cursor='pointer';
}
}
}
function iifopen(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto.document) { aconto = aconto.document; }
if (aconto != null) {
//alert(1);
if (aconto.getElementById('distyle')) {
aconto.getElementById('distyle').innerHTML+='';
aconto.getElementById('files').accept='.pdf';
aconto.getElementById('files').multiple=false;
aconto.getElementById('files').style.border='5px solid yellow';
arect=aconto.getElementById('files').getBoundingClientRect();
//alert(2);
//aconto.getElementById('files').click();
}
}
}
}
function toggle() {
document.getElementById('myh4').scrollIntoView(); // location.href='#myh4';
if (dmode == 'ltor') {
dmode='ttob';
document.getElementById('smode').innerHTML='⬇';
document.getElementById('mydflex').style.display='none';
document.getElementById('mytable').style.display='none';
document.getElementById('mytabletwo').style.display='table';
} else if (dmode == 'ttob') {
dmode='fill';
document.getElementById('smode').innerHTML='➡';
document.getElementById('mydflex').style.display='none';
document.getElementById('mytabletwo').style.display='none';
document.getElementById('mytable').style.display='table';
} else {
dmode='ltor';
document.getElementById('smode').innerHTML='↘';
document.getElementById('mytable').style.display='none';
document.getElementById('mytabletwo').style.display='none';
document.getElementById('mydflex').style.display='block';
}
}
function delit(ioissrc) {
var doit=false;
var thingos=ioissrc.split('#');
var zhr = new XMLHttpRequest();
var zform=new FormData();
if (thingos[0].length > 0) {
doit=true;
zform.append('delp', ioissrc.split('#')[0]);
}
if (thingos.length > 1) {
if (thingos[1].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[1]);
} else if (thingos[1].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[1]);
}
}
if (thingos.length > 2) {
if (thingos[2].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[2]);
} else if (thingos[2].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[2]);
}
}
if (doit) {
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
}
caches.open('userSettings').then( (cache) => {
cache.keys().then( (arrayOfRequest) => {
console.log(arrayOfRequest); // [Request, Request]
});
});
setInterval(checkf, 1000);
Extract the Images Within a PDF File" . $fextra . " via Pdfimages then Ffmpeg and/or ImageMagick
RJM Programming ➡ April, 2023
" . $olhashbit . "
";
if (isset($_GET['convertthis'])) {
$infile='"' . $pathp . str_replace('+',' ',urldecode($_GET['convertthis'])) . '"';
//$fextra=' ' . basename(str_replace('"','',$infile)) . '';
$fextra=' ' . basename(str_replace('"','',$infile)) . '';
} else if (isset($_POST['convertthis'])) {
$infile='"' . $pathp . str_replace('+',' ',urldecode($_POST['convertthis'])) . '"';
//$fextra=' ' . basename(str_replace('"','',$infile)) . '';
$fextra=' ' . basename(str_replace('"','',$infile)) . '';
} else if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false) {
echo "
" . str_replace(explode('>', explode('', explode("', '', explode('', explode("
";
echo str_replace($rest, $restto, $proposedtable);
//exit;
} else {
echo "
var lastpath='', lastfilename='';
function checkf() {
if (document.getElementById('justputpdffilename').innerHTML != '') {
document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
document.getElementById('justputpdffilename').innerHTML='';
if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
lastfilename=document.getElementById('justputpdffilename').title;
}
if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
if (document.getElementById('justputpdffilesize').innerHTML != '') {
//alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML);
document.getElementById('justputpdfpath').title=' ';
//var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename));
document.getElementById('path').style.cursor='progress';
document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML + '&filename=' + encodeURIComponent(lastfilename);
}
}
}
if (document.getElementById('justputpdfpath').innerHTML != '') {
document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
document.getElementById('justputpdfpath').innerHTML='';
if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
document.getElementById('justputpdfpath').title+='/';
}
} else {
if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
}
}
if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
document.getElementById('path').value=document.getElementById('justputpdfpath').title;
lastpath=document.getElementById('justputpdfpath').title;
}
}
if (document.getElementById('path').value != '') {
document.getElementById('path').style.cursor='pointer';
}
}
function iifopen(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto.document) { aconto = aconto.document; }
if (aconto != null) {
//alert(1);
if (aconto.getElementById('distyle')) {
aconto.getElementById('distyle').innerHTML+='';
aconto.getElementById('files').accept='.pdf';
aconto.getElementById('files').multiple=false;
aconto.getElementById('files').style.border='5px solid yellow';
arect=aconto.getElementById('files').getBoundingClientRect();
//alert(2);
//aconto.getElementById('files').click();
}
}
}
}
function delit(ioissrc) {
var doit=false;
var thingos=ioissrc.split('#');
var zhr = new XMLHttpRequest();
var zform=new FormData();
if (thingos[0].length > 0) {
doit=true;
zform.append('delp', ioissrc.split('#')[0]);
}
if (thingos.length > 1) {
if (thingos[1].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[1]);
} else if (thingos[1].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[1]);
}
}
if (thingos.length > 2) {
if (thingos[2].indexOf('.mp4') != -1) {
doit=true;
zform.append('delv', thingos[2]);
} else if (thingos[2].indexOf('.gif') != -1) {
doit=true;
zform.append('dela', thingos[2]);
}
}
if (doit) {
zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
zhr.send(zform);
}
}
caches.open('userSettings').then( (cache) => {
cache.keys().then( (arrayOfRequest) => {
console.log(arrayOfRequest); // [Request, Request]
});
});
setInterval(checkf, 1000);
... or ...
Extract the Images Within a PDF File" . $fextra . " via Pdfimages then Ffmpeg and/or ImageMagick
RJM Programming - April, 2023
";
exit;
}
if (PHP_OS == "Darwin") {
$huhw=shell_exec("where pdfimages");
if (strpos($huhw, DIRECTORY_SEPARATOR) !== false) {
$proposedtable=str_replace('>', '>' . $huhw . ' -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
foreach (glob($outp . '-*') as $filename) {
unlink($filename);
}
exec($huhw . ' -j ' . $infile . ' ' . $outp . ' -png 2> pdfimages.bad');
} else {
if (1 == 1) {
putenv('PATH=/usr/local/bin');
$proposedtable=str_replace('>', '>pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
foreach (glob($outp . '-*') as $filename) {
unlink($filename);
}
exec('pdfimages -j ' . $infile . ' ' . $outp . ' -png 2> pdfimages.bad');
} else {
$proposedtable=str_replace('>', '>/usr/local/bin/pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
foreach (glob($outp . '-*') as $filename) {
unlink($filename);
}
exec('/usr/local/bin/pdfimages -j ' . $infile . ' ' . $outp . ' -png 2> pdfimages.bad');
}
}
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$proposedtable=str_replace('>', '>pdfimages -j ' . $infile . ' ' . $outp . ' -png', $proposedtable);
foreach (glob($outp . '-*') as $filename) {
unlink($filename);
}
exec('pdfimages -j ' . $infile . ' ' . $outp . ' -png 2> pdfimages.bad');
}
$icnt=0;
$sofarw=0;
$padbr='';
$rens=",";
if ($dopdf) {
putenv('PATH=/usr/local/bin');
exec("convert " . $outp . "-*.*g -quality 100 " . $outp . ".pdf 2> pdfimage.bad");
$src=$outp . '.pdf';
if ($outp != strtoupper($outp)) {
$sparepdf=' onload=\"delit(this.src' . $hashbit . ');\" '; //' title="data:application/pdf;base64,' . base64_encode(file_get_contents($src)) . '" ';
//unlink($src);
//$src=$spare;
//$proposedtable=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $proposedtable);
//$rest=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $rest);
//$restto=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $restto);
}
if ($fextra != '') {
$proposedtable=str_replace($fextra, '', $proposedtable);
}
$proposedtable=str_replace('Extract the Images Within a PDF <', 'Images Of Image PDF ' . $fextra . '
<', $proposedtable);
}
foreach (glob($outp . '-*') as $filename) {
if (strpos($filename, ".jp") === false) {
$rens.=explode('.', basename($filename))[0] . '.jpg,' . explode('.', basename($filename))[1] . ',';
rename($filename, str_replace('.png', '.jpg', $filename));
}
}
if ($doag) {
if (file_exists($outp . ".gif")) {
unlink($outp . ".gif");
}
putenv('PATH=/usr/local/bin');
exec("ffmpeg -f image2 -framerate 3 -i " . $outp . "-%03d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad");
if (!file_exists($outp . ".gif")) {
file_put_contents($outp . ".gif", ""); //$doag=false;
}
//exit;
}
//exit;
foreach (glob($outp . '-*') as $filename) {
if (strpos($rens, ',' . basename($filename) . ',') !== false) {
$datau='data:image/' . explode(',',explode(',' . basename($filename) . ',', $rens)[1])[0] . ';base64,' . base64_encode(file_get_contents($filename));
} else {
$datau='data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $filename)[-1 + sizeof(explode(".", $filename))])) . ';base64,' . base64_encode(file_get_contents($filename));
}
$proposedtable=str_replace('', ' | ', $proposedtable);
$proposedtable=str_replace('', ' |
', $proposedtable);
list($width, $height, $type, $attr) = getimagesize($filename);
$width=intval("$width");
//file_put_contents("x.x", file_get_contents("x.x") . "sw=" . $vsw . " and original sofarw is " . $sofarw . ' and this width is ' . $width);
$sofarw+=$width;
$sofarw+=10;
//file_put_contents("x.x", file_get_contents("x.x") . " then sofarw becomes " . $sofarw . ' and this width is ' . $width);
if ("$vsw" != "0" && intval("$sofarw") >= intval("$vsw")) { $padbr="
"; $sofarw=$width; $sofarw+=10; } //else { $sofarw+=($width + 10); }
//file_put_contents("x.x", file_get_contents("x.x") . " padbr length is " . strlen($padbr) . "\n");
$proposedtable=str_replace('', $padbr . ' ', $proposedtable);
$padbr='';
if (PHP_OS == "Darwin") {
if ($icnt == 0 && ($dovideo || $doag || $dopdf)) {
if (file_exists($outp . '.mp4')) {
unlink($outp . '.mp4');
}
//if (file_exists($outp . '.gif')) {
// unlink($outp . '.gif');
//}
if ($dovideo) {
$huhvs=['1', '2'];
while (sizeof($huhvs) > 1) {
if (file_exists('video.bad')) {
unlink('video.bad');
}
putenv('PATH=/usr/local/bin');
exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" " . $outp . ".mp4 2> video.bad"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
$huhvs=explode('Could not open file :', file_get_contents('video.bad'));
//file_put_contents('xaaa.xaaa', '' . sizeof($huhvs) . file_get_contents('video.bad'));
if (sizeof($huhvs) > 1) {
//file_put_contents('xa.xa', trim(explode(Chr(10), explode('.j', $huhvs[1])[0])) . '.jpg');
rename(trim(explode(Chr(10), $huhvs[1])[0]) . '', trim(explode('.', $huhvs[1])[0]) . '.jpeg');
unlink('video.bad');
if (file_exists($outp . '.mp4')) {
unlink($outp . '.mp4');
}
//} else {
//file_put_contents('xaa.xaa', '' . sizeof($huhvs) . file_get_contents('video.bad'));
}
}
}
//exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg -filter:v \"setpts=5.0*PTS\" -vf \"scale=1280:-2\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
//exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg -filter:v \"setpts=5.0*PTS\" -vf \"scale=1280:-2,pad=ceil(iw/2)*2:ceil(ih/2)*2\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
//exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg -filter:v \"setpts=5.0*PTS\" -vf \"scale=640:-1\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
if ($doag) {
if (!file_exists($outp . ".gif")) {
putenv('PATH=/usr/local/bin');
exec("ffmpeg -f image2 -framerate 3 -i " . $outp . "-%03d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad");
if (!file_exists($outp . ".gif")) {
$doag=false;
}
}
}
if ($dopdf && 1 == 5) {
putenv('PATH=/usr/local/bin');
exec("convert " . $outp . "-*.jpg -quality 100 " . $outp . ".pdf 2> pdfimage.bad");
$src=$outp . '.pdf';
if ($outp != strtoupper($outp)) {
$sparepdf=' onload=delit(this.src' . $hashbit . '); '; //' title="data:application/pdf;base64,' . base64_encode(file_get_contents($src)) . '" ';
//unlink($src);
//$src=$spare;
//$proposedtable=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $proposedtable);
//$rest=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $rest);
//$restto=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $restto);
}
$proposedtable=str_replace('Extract the Images Within a PDF <', 'Images Of Image PDF
<', $proposedtable);
}
if ($dovideo && $doag) {
$src=$outp . '.mp4';
$srctwo=$outp . '.gif';
if ($outp != strtoupper($outp)) {
//file_put_contents('xxx5.xxx5', $src);
$spare='data:video/mp4;base64,' . base64_encode(file_get_contents($src));
//file_put_contents('xxx6.xxx6', '' . strlen($spare));
unlink($src);
$src=$spare;
//file_put_contents('xxx7.xxx7', '' . strlen($spare));
$spare='data:image/gif;base64,' . base64_encode(file_get_contents($srctwo));
//file_put_contents('xxx8.xxx8', '' . strlen($spare));
unlink($srctwo);
//file_put_contents('xxx9.xxx9', '' . strlen($spare));
$srctwo=$spare;
}
$proposedtable=str_replace('', '
Video ...
Animated GIF ...
', $proposedtable);
$proposedtable=str_replace('
', '
Pdfimages images ...
', $proposedtable);
$proposedtable=str_replace('', ' ', $proposedtable);
//file_put_contents('xxx0.xxx0', '');
} else if ($doag) {
$src=$outp . '.gif';
if ($outp != strtoupper($outp)) {
//file_put_contents('xxx00.xxx00', '');
$spare='data:image/gif;base64,' . base64_encode(file_get_contents($src));
unlink($src);
$src=$spare;
}
//file_put_contents('xxx0002.xxx0002', '');
$proposedtable=str_replace('', '
Animated GIF ...
', $proposedtable);
$proposedtable=str_replace('
', '
Pdfimages images ...
', $proposedtable);
$proposedtable=str_replace('', ' ', $proposedtable);
//file_put_contents('xxx0003.xxx0003', '');
} else if ($dovideo) {
$src=$outp . '.mp4';
if ($outp != strtoupper($outp)) {
$spare='data:video/mp4;base64,' . base64_encode(file_get_contents($src));
unlink($src);
$src=$spare;
}
$proposedtable=str_replace('', '
Video ...
', $proposedtable);
$proposedtable=str_replace('
', '
Pdfimages images ...
', $proposedtable);
$proposedtable=str_replace('', ' ', $proposedtable);
}
}
}
//file_put_contents('xxx000.xxx000', '');
if ($outp != strtoupper($outp) && str_replace(',','',$rens) == '') {
//file_put_contents('xxx0000.xxx0000', $filename);
try {
if (!file_exists($filename)) {
if (file_exists(str_replace('.png','.jpeg',$filename))) {
unlink(str_replace('.png','.jpeg',$filename));
}
} else {
unlink($filename);
}
} catch (Exception $werty) { }
}
$icnt++;
}
if ($outp != strtoupper($outp) && str_replace(',','',$rens) != '') {
//sleep(5);
//file_put_contents('xxx0001.xxx0001', '');
foreach (glob($outp . '-*') as $filename) {
try {
unlink($filename);
} catch (Exception $werty) { }
}
}
//file_put_contents('xxx00014.xxx00014', '');
echo str_replace($rest, $restto, $proposedtable);
//if ($sparepdf != '') {
// sleep(20);
// unlink($outp . ".pdf");
//}
//if (isset($_POST['delp'])) {
// if ($_POST['delp'] != '') {
// if (file_exists(str_replace('+',' ', urldecode($_POST['delp'])))) {
// unlink(str_replace('+',' ', urldecode($_POST['delp'])));
// }
// }
//}
exit;
?>