<?php
  // convert_wildcard.php
  // RJM Programming 
  // October, 2022
  // Facilitate the equivalent of ImageMagick command line ...
  // convert ./imspec*.*g* -density 56% ./*.jpeg
error_reporting(E_ERROR | E_PARSE);
  
$lastw=0;
$lasth=0;
$lastio=null;
$imd=true;
  
$inval="";
$tablerows="";
$erroris=" ";
$outeis=".jpeg";
$fspec="";
$ext="";
$width=0;
$height=0;
$iferr="";
$includesare="";
$cr="";
$crd="";
$dcr="";
$div_img="";
$ext="";
$zipfile="";
$ziparr = array();
$ziparrc = array();
$ziparrwh = array();
$quality=-1;
$taberows="";
$chkbox="";
$onl="";
$whenm="";
$myargs="";

$giffile='';
$gifdurl='';

$beginswitch=false;
$nextquality=false;
$argnext=false;
$results="";
$curlstr="";
$iscurl=false;

if (isset($_GET['inval'])) {
  $inval=str_replace('+',' ',urldecode($_GET['inval']));
}
if (isset($_POST['inval'])) {
  $inval=str_replace('+',' ',urldecode($_POST['inval']));
}

$ys="y";
$gabsimg='';
if (isset($_GET['absimg'])) {
  $gabsimg=$_GET['absimg'];
}
if (isset($_POST['absimg'])) {
  $gabsimg=$_POST['absimg'];
  if (strpos(('~' . $gabsimg), '~data') !== false) {
    $dcont=str_replace(' ','+',urldecode($gabsimg));
    if (strpos($dcont, 'image/') !== false && strpos($dcont, ';base64,') !== false) {
      $inext=strtolower(explode(';base64,', explode('image/', $dcont)[1])[0]);
      $imgname='/tmp/mycw_' . server_remote_addr() . '.' . $inext;
      file_put_contents($imgname, base64_decode(explode(';base64,', $dcont)[1]));
      echo '<html><body onload="if (1 == 2) { parent.document.title=' . "''" . ' + parent.document.getElementById(' . "'slideshow'" . ').title.length + ' . "' was vs is " . strlen($dcont) . "'" . '; } parent.document.getElementById(' . "'ispec'" . ').value=' . "'" . $imgname . "'" . ';  parent.document.getElementById(' . "'ispec'" . ').title=' . "''" . ';    "></body></html>';
      exit;
    }
  }
}

if ($gabsimg != '') { //isset($_GET['absimg'])) {
  $imagenametwo='';
  $inname=str_replace('+',' ',urldecode($gabsimg)); //$_GET['absimg']));
  if (strpos($inname, 'mustbedated=') !== false) {
    $ys=explode('#', explode('&', explode('mustbedated=', $inname)[1])[0])[0];
    if (strlen($ys) != 8) { $ys="y";  }
  }
//file_put_contents('x1.zx1', $inname);
  if (strpos($inname, '//') !== false) {
  $inext=strtolower(explode('#',explode('?', explode('.', $inname)[(-1 + sizeof(explode('.', $inname)))])[0])[0]);
//file_put_contents('x2.zx2', $inext);
  $xfis='';
  if (strlen($inext) < 3 || strlen($inext) > 4) {
   $imgname='/tmp/mycw_' . server_remote_addr() . '.png';
   if (file_exists($imgname)) { exec('rm -f ' . $imgname);  }
   if (strpos(str_replace('/wordpress/','/itblog/',strtolower($inname)), 'rjmprogramming.com.au/itblog/') !== false) {
     $nextc=substr(explode('rjmprogramming.com.au/itblog/', str_replace('/wordpress/','/itblog/',strtolower($inname)))[1],0,1);
     if ($nextc >= '0' && $nextc <= '9') {
//file_put_contents('x7.zx7', $imgname);
     if (strpos($inname, 'maybeheader=') === false) {
//file_put_contents('x8.zx8', $imgname);
       if (strpos($inname, '?') === false) {
       //file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1] . '?maybeheader=y'));
      $xfis=exec('curl ' . 'http://' . explode('//', $inname)[1] . '?maybeheader=' . $ys);
//file_put_contents('x8.zx8a', $xfis);
      } else {
       //file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1] . '&maybeheader=y'));
     $xfis=exec('curl ' . 'http://' . explode('?',explode('//', $inname)[1])[0] . '?maybeheader=' . $ys);
//file_put_contents('x8.zx8b', $xfis);
       }
     } else {
        //file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1] . ''));
     $xfis=exec('curl ' . 'http://' . explode('//', $inname)[1] . '');
//file_put_contents('x9.zx9', $xfis);
     }
     //$xfis=file_get_contents($imgname);
     if ($xfis != '') {
     if (2 == 2) {
     echo "<html><body onload=\"top.location.href='/convert_wildcard.php?inval=" . urlencode($xfis) . "';\"></body></html>";
     exit;
     } else {
     $inext=strtolower(explode('#',explode('?', explode('.', $xfis)[(-1 + sizeof(explode('.', $xfis)))])[0])[0]);
     $imgname='/tmp/mycw_' . server_remote_addr() . '.' . $inext;
     if (file_exists($imgname)) { exec('rm -f ' . $imgname);  }
     $zfis=file_get_contents($xfis);
     file_put_contents($imgname, $zfis);
     }
     }
     } else {
     file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1]));
     }
   } else {
     file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1]));
   }
  if (file_exists($imgname)) { 
//file_put_contents('x5.zx5', $imgname);
  if (('' . filesize($imgname)) != '0') { 
//file_put_contents('x6.zx6', '<html><body onload=" parent.document.getElementById(' . "'ispec'" . ').value=' . "'" . $imgname . "'" . '; "></body></html>');
  $extlist=['','gif','jpeg','png','swf','psd','bmp','tiff','tiff','jpc','jp2','jpx','jb2','swc','iff','wbmp','xbm','ico','webp','avif'];
  if ($array = getimagesize($imgname)) { // true and use the $array if required } – 
  $exti=exif_imagetype($imgname);
  if ((strlen('' . $exti) == 1 && ('' . $exti) != '0') || (strlen('' . $exti) > 1 && substr(('' . $exti),0,1) == '1') ) {
    $imgnametwo='/tmp/mycw_' . server_remote_addr() . '.' . $extlist[$exti];
    if (('' . $exti) != '3') {
    if (file_exists($imgnametwo)) { exec('rm -f ' . $imgnametwo);  }
    exec("mv " . $imagename . ' ' . $imagenametwo);
    $imagename=$imagenametwo;
    }
    $inext=$extlist[$exti];
  }
  }
  }
  }
  }

  if (strlen($inext) == 3 || strlen($inext) == 4) {
  $imgname='/tmp/mycw_' . server_remote_addr() . '.' . $inext;
//file_put_contents('x3.x3', $imgname);
  if ($imagenametwo == '') {
  if (file_exists($imgname)) { exec('rm -f ' . $imgname);  }
  file_put_contents($imgname, file_get_contents('http://' . explode('//', $inname)[1]));
  }
//file_put_contents('x4.x4', $imgname);
  if (file_exists($imgname)) { 
//file_put_contents('x5.x5', $imgname);
  if (('' . filesize($imgname)) != '0') { 
//file_put_contents('x6.x6', '<html><body onload=" parent.document.getElementById(' . "'ispec'" . ').value=' . "'" . $imgname . "'" . '; "></body></html>');
  echo '<html><body onload=" parent.document.getElementById(' . "'ispec'" . ').value=' . "'" . $imgname . "'" . ';   "></body></html>';
  exit;
  }
  }
  }
  }
  echo '<html><body onload=" parent.document.getElementById(' . "'ispec'" . ').title=' . "''" . ';   "></body></html>';
  exit;
}

if (!isset($argc) && isset($_GET['command'])) { // curl mode of use eg. curl "http://localhost:8888/convert_wildcard.php?command=x*.jpg+-q+76+-negate+.jpeg"
  $curlstr="convert_wildcard.php " . str_replace('+',' ',urldecode($_GET['command']));
  $argv=explode(" ", $curlstr);
  $argc=sizeof($argv);
  if (strpos(strtolower($_SERVER['SERVER_NAME']), 'rjmprogramming.com.au') !== false && !isset($_GET['amnotcurl'])) { 
    $iscurl=true; 
  }
}

if (isset($argc)) { // command line mode of use eg. php convert_wildcard.php x*.jpg -q 76 -negate .jpeg 
  $results="\n";
  for ($ii=1; $ii<$argc; $ii++) {
   if (trim($argv[$ii]) != '') {
    if ($nextquality) {
      $nextquality=false;
      $_POST['quality']=str_replace('%','',$argv[$ii]);
    } else if (strpos($argv[$ii], '-quality') !== false || strpos($argv[$ii], '-QUALITY') !== false) {
      $beginswitch=true;
      if (strpos($argv[$ii],'=') !== false) {
        $_POST['quality']=str_replace('%','',explode('=', $argv[$ii])[1]);
      } else if (strlen($argv[$ii]) > 8) {
        $_POST['quality']=str_replace('%','',substr($argv[$ii], 8));
      } else {
        $nextquality=true;
      }
    } else if (strpos($argv[$ii], '-q') !== false || strpos($argv[$ii], '-Q') !== false) {
      $beginswitch=true;
      if (strpos($argv[$ii],'=') !== false) {
        $_POST['quality']=str_replace('%','',explode('=', $argv[$ii])[1]);
      } else if (strlen($argv[$ii]) > 2) {
        $_POST['quality']=str_replace('%','',substr($argv[$ii], 2));
      } else {
        $nextquality=true;
      }
    } else if (substr($argv[$ii],0,1) == '-') {
      $beginswitch=true;
      if (strpos($argv[$ii],'=') !== false) {
        $_POST[substr(strtolower(explode('=',$argv[$ii])[0]),1)]='';
        if (sizeof(explode(',',explode('=',$argv[$ii])[1])) == 3) {
          if ($whenm == '') {
            $whenm.='' . substr(strtolower(explode('=',$argv[$ii])[0]),1) . '=' . explode('=',$argv[$ii])[1];
          } else {
            $whenm.=';' . substr(strtolower(explode('=',$argv[$ii])[0]),1) . '=' . explode('=',$argv[$ii])[1];
          }
          $_POST['args']=explode('=',$argv[$ii])[1];
        } else {
          $_POST['arg1']=explode('=',$argv[$ii])[1];
        }
      } else {
        $_POST[substr(strtolower(explode('=',$argv[$ii])[0]),1)]='';
        if ($whenm == '') {
            $whenm.='' . substr(strtolower(explode('=',$argv[$ii])[0]),1) . '='; // . explode('=',$argv[$ii])[1];
        } else {
            $whenm.=';' . substr(strtolower(explode('=',$argv[$ii])[0]),1) . '='; // . explode('=',$argv[$ii])[1];
        }
        $argnext=true;
      }
    } else if (!isset($_POST['ispec'])) {
      $_POST['ispec']=$argv[$ii];
    } else if (!$beginswitch) {
      $_POST['ispec'].="," . $argv[$ii];
    } else if (substr($argv[$ii],0,1) == '.' || strlen($argv[$ii]) == 3) {
      $argnext=false;
      $_POST['outext']=str_replace("..", ".", "." . $argv[$ii]);
    } else if ($argnext) {
      $argnext=false;
      if (sizeof(explode(',',$argv[$ii])) == 3) {
        $whenm.=$argv[$ii];
        $_POST['args']=$argv[$ii];
      } else {
        $whenm.=$argv[$ii];
        $_POST['arg1']=$argv[$ii];
      }
    }
   }
  }
  if ($whenm != '') {
    $_POST['whenmulti']=$whenm;
  }
}

if (function_exists('imagebmp')) {
   $onl=" onload=\"if (document.getElementById('ispec').value != '') { lookforabsolute(document.getElementById('ispec')); } document.getElementById('extsel').innerHTML+='<option value=.bmp>.bmp</option><option value=.BMP>.BMP</option>';\"";
} else if ($inval != '') {
   $onl=" onload=\"if (document.getElementById('ispec').value != '') { lookforabsolute(document.getElementById('ispec')); } \"";
}
if (strpos(strtolower($_SERVER['SERVER_NAME']), 'rjmprogramming.com.au') === false) {
  $chkbox="<br><br>Keep Image Files <input type=checkbox id=delc title='Real web server files left after processing, perhaps lessening need to deploy download click functionalities.'></input>";
}
$cropa="";
if (function_exists('imagecropauto')) {
   $cropa.="<option value=crop>Crop</option>";
}
if (function_exists('imagecropauto')) {
   $cropa.="<option value=transparent>Transparent</option>";
}
if (function_exists('imagecopymerge')) {
   $cropa.="<option value=merge>Merge</option>";
}

$filteropt="<br><br><details id=doif><summary>Optional Image Filtering and/or Transformations ...</summary><br><table><tr><td><select size=20 id=sfilter onchange=zoomsame(this,'');><option class=\"opt000\" value=''>Image Filter ...</option><option class=\"opt001\" value=' '>Image Filter Ask Arguments ...</option><option value=emboss>Emboss</option><option value=negate>Negate</option><option value=edge>Edge</option><option value=negedge>Negedge</option><option value=grayscale>Grayscale</option><option value=gaussianblur>Gaussian Blur</option><option value=selectiveblur>Selective Blur</option><option value=sharpen>Sharpen</option><option value=boxblur>Boxblur</option><option value=colourize>Colourize</option><option value=pixellate>Pixellate</option><option value=smooth>Smooth</option><option value=contrast>Contrast</option><option value=brightness>Brightness</option><option value=sketchy>Sketchy</option><option value=colourizered>Colourize Red</option><option value=colourizegreen>Colourize Green</option><option value=colourizeblue>Colourize Blue</option></select></td><td style=vertical-align:top;><select size=10 id=tsfilter onchange=\"if (this.value.length > 0) { if (this.value.trim().length > 0) { if (document.getElementById('sfilter').innerHTML.indexOf(this.value.substring(0,1).toUpperCase() + this.value.substring(1)) == -1) { document.getElementById('sfilter').innerHTML+='<option value=' + this.value + '>' + this.value.substring(0,1).toUpperCase() + this.value.substring(1) + '</option>'; document.getElementById('sfilter').size=eval(1 + eval('' + document.getElementById('sfilter').size)); } } zoomsame(document.getElementById('sfilter'), this.value); this.value=''; } \"><option value=''>Image Transformations ...</option><option value=' '>Image Transformation Ask Arguments ...</option><option value=flip>Flip</option><option value=flipvertical>Flip Vertical</option><option value=fliphorizontal>Flip Horizontal</option><option value=rotation>Rotation</option><option value=scale>Scale</option>" . $cropa . "</select></td></table><input type=hidden id=rotation value=0></input><input type=hidden id=trot value=0></input></details>";
$inputask="<br><form id=myform onsubmit=\" if (document.getElementById('ispec').title.replace('Just quietly, some absolute image URL(s), comma separated, can work too','').trim() != '') { if (document.getElementById('absurl')) { document.getElementById('absurl').value=document.getElementById('ispec').title; } else {  document.getElementById('presub').innerHTML+='<input type=hidden id=absurl name=absurl value=' + String.fromCharCode(34) + document.getElementById('ispec').title + String.fromCharCode(34) + '></input>';   } } document.getElementById('mysub').style.cursor='progress'; document.getElementById('sfilter').value='';  if (document.getElementById('delc')) { if (!document.getElementById('delc').checked) {  document.getElementById('mysub').name='delfile'; } } return true;\" method=POST action=./convert_wildcard.php><input type=text style='width:80%;' title='Just quietly, some absolute image URL(s), comma separated, can work too' value='" . $inval . "' placeholder='Enter relative image file specification or absolute image URL single file (and no guarantees of success) or image data URI eg. f*.png' id=ispec onblur=lookforabsolute(this); name=ispec></input><br><br><div id=dext><input type=text style='width:80%;' placeholder='Enter output relative image file extension [.jpeg]' value='' name=outext id=outext></input></div><br><br>Quality: <input type=number style='display:inline-block;' name=quality value=75 step=1 min=-1 max=100 name=quality title='Jpeg Quality Percentage'></input>%<input type=hidden id=whenmulti name=whenmulti value=''></input>" . $chkbox . $filteropt . "<br><br><div id=presub></div><input id=mysub type=submit value='Convert Image Format(s)'></input></form>";

 if (isset($_GET['ispec']) && (isset($_GET['outext']) || $outeis != '')) {
    if (isset($_GET['quality'])) {  $quality=explode('.',str_replace('%','',str_replace('+',' ',urldecode($_GET['quality']))))[0];   }
    if (isset($_GET['outext'])) { if (strlen($_GET['outext']) > 0) { $outeis=str_replace('+',' ',urldecode($_GET['outext'])); } }
    ourglob(str_replace('+',' ',urldecode($_GET['ispec'])), $outeis);
 } else if (isset($_POST['ispec']) && (isset($_POST['outext']) || $outeis != '')) {
    if (isset($_POST['quality'])) {  $quality=explode('.',str_replace('%','',str_replace('+',' ',urldecode($_POST['quality']))))[0];   }
    if (isset($_POST['outext'])) {  if (strlen($_POST['outext']) > 0) { $outeis=str_replace('+',' ',urldecode($_POST['outext'])); } }
    ourglob(str_replace('+',' ',urldecode($_POST['ispec'])), $outeis);
 }
 
function newbase64_encode($instg) {
  global $giffile, $gifdurl;
  if ($giffile == '') {
    return base64_encode($instg);
  }
  //file_put_contents('x.xf', $gifdurl);
  if ($gifdurl == '') {
    $gifdurl=base64_encode(file_get_contents(str_replace('https:','http:',preg_replace('{^//}','http://',$giffile))));
  }
  //file_put_contents('x.xg', $gifdurl);
  return $gifdurl;
}

function newfile_get_contents($infl) {
  global $giffile, $gifdurl;
  if (strpos(strtolower($infl), '.gif') === false) {
    $giffile='';
    $gifdurl='';
  }
  if ($giffile == '') {
    return file_get_contents($infl);
  }
  $gifdurl=base64_encode(file_get_contents(str_replace('https:','http:',preg_replace('{^//}','http://',$giffile))));
  return file_get_contents(str_replace('https:','http:',preg_replace('{^//}','http://',$giffile)));
}
 
function server_remote_addr() {
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''));
    // you can add different browsers with the same way ..
    if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
            $rma = '000000'.$rma;
    elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
            $rma = '00000'.$rma;
    elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
            $rma = '0000'.$rma;
    elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
            $rma = '000'.$rma;
    elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
            $rma = '00'.$rma;
    elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
            $rma = '0'.$rma;
    return str_replace(":", "_", $rma);
}
 
 function getpostmaybe($argidea, $defidea) {
   global $myargs;
   $gpidea='';
   if ($myargs != '') {
     $gpidea=$myargs;
   } else if (isset($_GET[$argidea])) {
     $gpidea=str_replace('+',' ',urldecode($_GET[$argidea]));
   } else if (isset($_POST[$argidea])) {
     $gpidea=str_replace('+',' ',urldecode($_POST[$argidea]));
   } else if (isset($_GET['arg'])) {
     $gpidea=str_replace('+',' ',urldecode($_GET['arg']));
   } else if (isset($_POST['arg'])) {
     $gpidea=str_replace('+',' ',urldecode($_POST['arg']));
   } else if (isset($_GET['args'])) {
     $gpidea=str_replace('+',' ',urldecode($_GET['args']));
   } else if (isset($_POST['args'])) {
     $gpidea=str_replace('+',' ',urldecode($_POST['args']));
   }     
   if (trim($gpidea) != '') {
     $clist=explode(',', str_replace(' ','',str_replace('(','',str_replace(')','',str_replace(']','',str_replace('[','',str_replace('array','',$gpidea)))))));
     if (sizeof($clist) == 9) {
      return array([$clist[0], $clist[1], $clist[2]],[$clist[3], $clist[4], $clist[5]],[$clist[6], $clist[7], $clist[8]]);
     } else if (sizeof($clist) == 3 && $argidea == 'arg1') {
      return $clist[0];
     } else if (sizeof($clist) == 3 && $argidea == 'arg2') {
      return $clist[1];
     } else if (sizeof($clist) == 3 && $argidea == 'arg3') {
      return $clist[2];
     } else if (substr(($gpidea . '0'),0,1) < '0' || substr(($gpidea . '0'),0,1) > '9') {
      return '' . $gpidea;
     } else {
      return intval('' . $gpidea);
     } 
   }
   return $defidea;
 }
 

 function ourfile_get_contents($ourfilename) {
   global $giffile, $gifdurl, $zipfile, $ziparrc, $ziparr, $ext;
   return file_get_contents(str_replace('https:','http:',preg_replace('{^//}','http://',$ourfilename)));
   if (substr(($ourfilename . "     "),0,5) != "data:" && substr((strtolower($ourfilename) . "     "),0,4) != "http") {
     $ourfilename=str_replace("/", substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,0,1), $ourfilename);
   } else if (substr(($ourfilename . "     "),0,1) == "/" && substr(($ourfilename . "     "),0,2) != "//") {
     $ourfilename=dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace("/", substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,0,1), substr($ourfilename,1));
     //file_put_contents('qwe.qwezz', $ourfilename);
   }    
   if (trim($zipfile) == "") {
     if (substr(($ourfilename . "     "),0,5) == "data:") {
       $ext="." . 
       explode("/", explode(";base64,", str_replace(" ","+",$ourfilename))[0])[-1 + sizeof(explode("/", explode(";base64,", str_replace(" ","+",$ourfilename))[0]))];   // /jpeg;
     //file_put_contents('qwe.qwezzz', $ourfilename);
       return base64_decode(explode(";base64,", str_replace(" ","+",$ourfilename))[1]);
     }
     return file_get_contents($ourfilename);
   } else if (sizeof($ziparrc) == sizeof($ziparr)) {
     for ($iop=0; $iop<sizeof($ziparr); $iop++) {
       if ($ziparr[$iop] == $ourfilename) {
        //if ($iop > 5) {
        //echo strlen($ziparrc[$iop]) . ' vS ' . $ext . ' ' . $iop . ' ' . sizeof($ziparr) . ' ' . $ourfilename;
        //exit;
        //}
        $zas=$ziparrc[$iop];
        //$ziparrc[$iop]="";
        return $zas;
       }
     }
     return "";
   } else {
     $zip = zip_open($zipfile);
     if ($zip) {
      while ($zip_entry = zip_read($zip)) {
       $thisfilename=zip_entry_name($zip_entry);
       if ($thisfilename == $ourfilename) {
        //echo $thisfilename . ' VS ' . $ourfilename;
        //exit;
        $zhuh=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
        zip_close($zip);
        return $zhuh;
       }
      }
      zip_close($zip);
     }
   }
   return "";
 }
 
 
// converts an html color name to a hex color value
// if the input is not a color name, the original value is returned
// http://wpCodeSnippets.info

function color_name_to_hex($color_name) { // thanks to https://stackoverflow.com/questions/2553566/how-to-convert-a-string-color-to-its-hex-code-or-rgb-value
    global $ris, $gis, $bis;
    // standard 147 HTML color names
    $colors  =  array(
        'aliceblue'=>'F0F8FF',
        'antiquewhite'=>'FAEBD7',
        'aqua'=>'00FFFF',
        'aquamarine'=>'7FFFD4',
        'azure'=>'F0FFFF',
        'beige'=>'F5F5DC',
        'bisque'=>'FFE4C4',
        'black'=>'000000',
        'blanchedalmond '=>'FFEBCD',
        'blue'=>'0000FF',
        'blueviolet'=>'8A2BE2',
        'brown'=>'A52A2A',
        'burlywood'=>'DEB887',
        'cadetblue'=>'5F9EA0',
        'chartreuse'=>'7FFF00',
        'chocolate'=>'D2691E',
        'coral'=>'FF7F50',
        'cornflowerblue'=>'6495ED',
        'cornsilk'=>'FFF8DC',
        'crimson'=>'DC143C',
        'cyan'=>'00FFFF',
        'darkblue'=>'00008B',
        'darkcyan'=>'008B8B',
        'darkgoldenrod'=>'B8860B',
        'darkgray'=>'A9A9A9',
        'darkgreen'=>'006400',
        'darkgrey'=>'A9A9A9',
        'darkkhaki'=>'BDB76B',
        'darkmagenta'=>'8B008B',
        'darkolivegreen'=>'556B2F',
        'darkorange'=>'FF8C00',
        'darkorchid'=>'9932CC',
        'darkred'=>'8B0000',
        'darksalmon'=>'E9967A',
        'darkseagreen'=>'8FBC8F',
        'darkslateblue'=>'483D8B',
        'darkslategray'=>'2F4F4F',
        'darkslategrey'=>'2F4F4F',
        'darkturquoise'=>'00CED1',
        'darkviolet'=>'9400D3',
        'deeppink'=>'FF1493',
        'deepskyblue'=>'00BFFF',
        'dimgray'=>'696969',
        'dimgrey'=>'696969',
        'dodgerblue'=>'1E90FF',
        'firebrick'=>'B22222',
        'floralwhite'=>'FFFAF0',
        'forestgreen'=>'228B22',
        'fuchsia'=>'FF00FF',
        'gainsboro'=>'DCDCDC',
        'ghostwhite'=>'F8F8FF',
        'gold'=>'FFD700',
        'goldenrod'=>'DAA520',
        'gray'=>'808080',
        'green'=>'008000',
        'greenyellow'=>'ADFF2F',
        'grey'=>'808080',
        'honeydew'=>'F0FFF0',
        'hotpink'=>'FF69B4',
        'indianred'=>'CD5C5C',
        'indigo'=>'4B0082',
        'ivory'=>'FFFFF0',
        'khaki'=>'F0E68C',
        'lavender'=>'E6E6FA',
        'lavenderblush'=>'FFF0F5',
        'lawngreen'=>'7CFC00',
        'lemonchiffon'=>'FFFACD',
        'lightblue'=>'ADD8E6',
        'lightcoral'=>'F08080',
        'lightcyan'=>'E0FFFF',
        'lightgoldenrodyellow'=>'FAFAD2',
        'lightgray'=>'D3D3D3',
        'lightgreen'=>'90EE90',
        'lightgrey'=>'D3D3D3',
        'lightpink'=>'FFB6C1',
        'lightsalmon'=>'FFA07A',
        'lightseagreen'=>'20B2AA',
        'lightskyblue'=>'87CEFA',
        'lightslategray'=>'778899',
        'lightslategrey'=>'778899',
        'lightsteelblue'=>'B0C4DE',
        'lightyellow'=>'FFFFE0',
        'lime'=>'00FF00',
        'limegreen'=>'32CD32',
        'linen'=>'FAF0E6',
        'magenta'=>'FF00FF',
        'maroon'=>'800000',
        'mediumaquamarine'=>'66CDAA',
        'mediumblue'=>'0000CD',
        'mediumorchid'=>'BA55D3',
        'mediumpurple'=>'9370D0',
        'mediumseagreen'=>'3CB371',
        'mediumslateblue'=>'7B68EE',
        'mediumspringgreen'=>'00FA9A',
        'mediumturquoise'=>'48D1CC',
        'mediumvioletred'=>'C71585',
        'midnightblue'=>'191970',
        'mintcream'=>'F5FFFA',
        'mistyrose'=>'FFE4E1',
        'moccasin'=>'FFE4B5',
        'navajowhite'=>'FFDEAD',
        'navy'=>'000080',
        'oldlace'=>'FDF5E6',
        'olive'=>'808000',
        'olivedrab'=>'6B8E23',
        'orange'=>'FFA500',
        'orangered'=>'FF4500',
        'orchid'=>'DA70D6',
        'palegoldenrod'=>'EEE8AA',
        'palegreen'=>'98FB98',
        'paleturquoise'=>'AFEEEE',
        'palevioletred'=>'DB7093',
        'papayawhip'=>'FFEFD5',
        'peachpuff'=>'FFDAB9',
        'peru'=>'CD853F',
        'pink'=>'FFC0CB',
        'plum'=>'DDA0DD',
        'powderblue'=>'B0E0E6',
        'purple'=>'800080',
        'red'=>'FF0000',
        'rosybrown'=>'BC8F8F',
        'royalblue'=>'4169E1',
        'saddlebrown'=>'8B4513',
        'salmon'=>'FA8072',
        'sandybrown'=>'F4A460',
        'seagreen'=>'2E8B57',
        'seashell'=>'FFF5EE',
        'sienna'=>'A0522D',
        'silver'=>'C0C0C0',
        'skyblue'=>'87CEEB',
        'slateblue'=>'6A5ACD',
        'slategray'=>'708090',
        'slategrey'=>'708090',
        'snow'=>'FFFAFA',
        'springgreen'=>'00FF7F',
        'steelblue'=>'4682B4',
        'tan'=>'D2B48C',
        'teal'=>'008080',
        'thistle'=>'D8BFD8',
        'tomato'=>'FF6347',
        'turquoise'=>'40E0D0',
        'violet'=>'EE82EE',
        'wheat'=>'F5DEB3',
        'white'=>'FFFFFF',
        'whitesmoke'=>'F5F5F5',
        'yellow'=>'FFFF00',
        'yellowgreen'=>'9ACD32');

    $color_name = strtolower($color_name);
    if (isset($colors[$color_name])) {
        //$ris = hexdec(substr($colors[$color_name],0,2));
        //$gis = hexdec(substr($colors[$color_name],2,2));
        //$bis = hexdec(substr($colors[$color_name],4,2));
        //echo '#' . $colors[$color_name];
        //exit;
        return ('#' . $colors[$color_name]);
    } else {
        //echo '' . $color_name;
        //exit;
        return $color_name;
    }
}

   
 function ourImageFlip($imgsrc, $mode) { // thanks to https://stackoverflow.com/questions/10001728/how-to-flip-image-horizontaly-and-vertically-with-php
    global $giffile, $gifdurl;
    $width                        =    imagesx ( $imgsrc );
    $height                       =    imagesy ( $imgsrc );

    $src_x                        =    0;
    $src_y                        =    0;
    $src_width                    =    $width;
    $src_height                   =    $height;

    switch ($mode) {
        case '1': //vertical
            $src_y                =    $height -1;
            $src_height           =    -$height;
        break;

        case '2': //horizontal
            $src_x                =    $width -1;
            $src_width            =    -$width;
        break;

        case '3': //both
            $src_x                =    $width -1;
            $src_y                =    $height -1;
            $src_width            =    -$width;
            $src_height           =    -$height;
        break;

        default:
            return $imgsrc;
        break;
    }

    $imgdest                    =    imagecreatetruecolor ( $width, $height );

    if ( imagecopyresampled ( $imgdest, $imgsrc, 0, 0, $src_x, $src_y , $width, $height, $src_width, $src_height ) ) {
        return $imgdest;
    }

    return $imgsrc;
 }
  
 function outoftwo($theone, $thetwo) {
   if ($thetwo == "") {
     return $theone;
   } else if ($theone == $thetwo) {
     return $theone;
   } 
   return 'youllneverfindthis';
 } 
 
function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct) { // thanks to https://www.php.net/manual/en/function.imagecopymerge.php
    if (!isset($pct)) {
        return false;
    }
    $pct /= 100;
    // Get image width and height
    $w = imagesx( $src_im );
    $h = imagesy( $src_im );
    // Turn alpha blending off
    imagealphablending( $src_im, false );
    // Find the most opaque pixel in the image (the one with the smallest alpha value)
    $minalpha = 127;
    for ( $x = 0; $x < $w; $x++ )
    for ( $y = 0; $y < $h; $y++ ) {
        $alpha = ( imagecolorat( $src_im, $x, $y ) >> 24 ) & 0xFF;
        if( $alpha < $minalpha ){
            $minalpha = $alpha;
        }
    }
    //loop through image pixels and modify alpha for each
    for ( $x = 0; $x < $w; $x++ ) {
        for ( $y = 0; $y < $h; $y++ ) {
            //get current alpha value (represents the TANSPARENCY!)
            $colorxy = imagecolorat( $src_im, $x, $y );
            $alpha = ( $colorxy >> 24 ) & 0xFF;
            //calculate new alpha
            if( $minalpha !== 127 ){
                $alpha = 127 + 127 * $pct * ( $alpha - 127 ) / ( 127 - $minalpha );
            } else {
                $alpha += 127 * $pct;
            }
            //get the color index with new alpha
            $alphacolorxy = imagecolorallocatealpha( $src_im, ( $colorxy >> 16 ) & 0xFF, ( $colorxy >> 8 ) & 0xFF, $colorxy & 0xFF, $alpha );
            //set pixel with the new color + opacity
            if( !imagesetpixel( $src_im, $x, $y, $alphacolorxy ) ){
                return false;
            }
        }
    }
    //file_put_contents('qwer.qwer', 'w=' . $w);
    // The image copy
    imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
}

  
 function newurldecode($inthing) {
    if (!isset($inthing)) {
      return '';
    } 
    return urldecode($inthing);
 } 
  
 function ourimagecreatefromfile($zfilename) {
    global $giffile, $gifdurl, $imd, $div_img, $ext, $myargs, $lastw, $lasth, $lastio;
    $goes=1;
    $oktoend=true;
    $jm_php=null;
    $myargs="";
    $vs="";
    $wma=[];
    if (strpos(strtolower($zfilename), '.gif') !== false) {
      $giffile=$zfilename;
    } else {
      $giffile='';
      $gifdurl='';
    }
    if (isset($_GET['whenmulti'])) {
      if (strlen($_GET['whenmulti']) > 0) {
      $wma=explode(';', str_replace('+',' ',urldecode($_GET['whenmulti'])));
      $goes=sizeof($wma);
      }
    } else if (isset($_POST['whenmulti'])) {
      if (strlen($_POST['whenmulti']) > 0) {
      $wma=explode(';', str_replace('+',' ',urldecode($_POST['whenmulti'])));
      $goes=sizeof($wma);
      }
    } 
    //file_put_contents("qweaa.qweaa", "goes=" . $goes . " and whenmulti=" . str_replace('+',' ',urldecode($_POST['whenmulti'])));
    for ($ig=0; $ig<$goes; $ig++) {
    if (sizeof($wma) > $ig) {
      $vs=explode('=', $wma[$ig])[0];
      $myargs=explode('=', $wma[$ig])[1];
      if ($myargs == "") { $myargs=" "; }
      //file_put_contents("qwez.qwez" . $ig, "vs=" . $vs . " and myargs=" . $myargs);
    } else {
      $vs="";
      $myargs="";
    }
    if (($ig + 1) >= $goes) {
      $oktoend=true;
    } else {
      $oktoend=false;
    }
    if (isset($_GET['emboss']) || isset($_POST[outoftwo('emboss',$vs)])) {
      $giffile='';
      //file_put_contents("qwe.qwe", str_replace(' ','+',newurldecode($_GET['emboss'])) . str_replace(' ','+',newurldecode($_POST['emboss'])) . $zfilename);
      //file_put_contents("qwe.qwex", $_SERVER['HTTP_REFERER']);
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['emboss'])) . str_replace(' ','+',newurldecode($_POST['emboss'])) . $zfilename));
      }
      $emboss = getpostmaybe('arg1',array([-2, -1, 0], [-1, 1, 1], [0, 1, 2]));
      //file_put_contents("qwe.qwexx", $_SERVER['HTTP_REFERER']);
     //imageconvolution($jm_php, $emboss, 1, 0);    
      imagefilter($jm_php, IMG_FILTER_EMBOSS);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      //file_put_contents("qwe.qwez", $_SERVER['HTTP_REFERER']);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
      //file_put_contents("qwe.qwey", "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>");
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['edge']) || isset($_POST[outoftwo('edge',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['edge'])) . str_replace(' ','+',newurldecode($_POST['edge'])) . $zfilename));
      }
      $edge_detect = getpostmaybe('arg1',array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]));
      imageconvolution($jm_php, $edge_detect, 1, 0);
      imageconvolution($jm_php, $edge_detect, 1, 255);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['negedge']) || isset($_POST[outoftwo('negedge',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['negedge'])) . str_replace(' ','+',newurldecode($_POST['negedge'])) . $zfilename));
      }
      $edge_detect = getpostmaybe('arg1',array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]));
      imageconvolution($jm_php, $edge_detect, 1, 0);
      //imageconvolution($jm_php, $edge_detect, 1, 255);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['sharpen']) || isset($_POST[outoftwo('sharpen',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['sharpen'])) . str_replace(' ','+',newurldecode($_POST['sharpen'])) . $zfilename));
      }
      $sharpen = getpostmaybe('arg1',array([0, -1, 0], [-1, 5, -1], [0, -1, 0]));
      imageconvolution($jm_php, $sharpen, 1, 0);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['boxblur']) || isset($_POST[outoftwo('boxblur',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['boxblur'])) . str_replace(' ','+',newurldecode($_POST['boxblur'])) . $zfilename));
      }
      $box_blur = getpostmaybe('arg1',array([1, 1, 1], [1, 1, 1], [1, 1, 1]));
      imageconvolution($jm_php, $box_blur, 9, 0);    
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['grayscale']) || isset($_POST[outoftwo('grayscale',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['grayscale'])) . str_replace(' ','+',newurldecode($_POST['grayscale'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_GRAYSCALE);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['gaussianianblur']) || isset($_POST[outoftwo('gaussianblur',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['gaussianblur'])) . str_replace(' ','+',newurldecode($_POST['gaussianblur'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_GAUSSIAN_BLUR);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['selectiveblur']) || isset($_POST[outoftwo('selectiveblur',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['selectiveblur'])) . str_replace(' ','+',newurldecode($_POST['selectiveblur'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_SELECTIVE_BLUR);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }      
            
    } else if (isset($_GET['negate']) || isset($_POST[outoftwo('negate',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['negate'])) . str_replace(' ','+',newurldecode($_POST['negate'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_NEGATE);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['colourizered']) || isset($_POST[outoftwo('colourizered',$vs)]) || isset($_GET['colorizered']) || isset($_POST[outoftwo('colorizered',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['colourizered'])) . str_replace(' ','+',newurldecode($_POST['colourizered'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_COLORIZE, getpostmaybe('arg1',rand(0,255)), 0, 0); //, 100);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['colourizegreen']) || isset($_POST[outoftwo('colourizegreen',$vs)]) || isset($_GET['colorizegreen']) || isset($_POST[outoftwo('colorizegreen',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['colourizegreen'])) . str_replace(' ','+',newurldecode($_POST['colourizegreen'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_COLORIZE, 0, getpostmaybe('arg1',rand(0,255)), 0); //, 100);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['colourize']) || isset($_POST[outoftwo('colourize',$vs)]) || isset($_GET['colorize']) || isset($_POST[outoftwo('colorize',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['colourize'])) . str_replace(' ','+',newurldecode($_POST['colourize'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_COLORIZE, getpostmaybe('arg1',rand(0, 255)), getpostmaybe('arg2',rand(0, 255)), getpostmaybe('arg3',rand(0, 255))); //, 100);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['colourizeblue']) || isset($_POST[outoftwo('colourizeblue',$vs)]) || isset($_GET['colorizeblue']) || isset($_POST[outoftwo('colorizeblue',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['colourizeblue'])) . str_replace(' ','+',newurldecode($_POST['colourizeblue'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_COLORIZE, 0, 0, getpostmaybe('arg1',rand(0,255))); //, 100);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['pixellate']) || isset($_POST[outoftwo('pixellate',$vs)]) || isset($_GET['pixelate']) || isset($_POST[outoftwo('pixelate',$vs)]))  {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['pixellate'])) . str_replace(' ','+',newurldecode($_POST['pixellate'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_PIXELATE, getpostmaybe('arg1',rand(1, 9))); // was 3
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['smooth']) || isset($_POST[outoftwo('smooth',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['smooth'])) . str_replace(' ','+',newurldecode($_POST['smooth'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_SMOOTH, getpostmaybe('arg1',rand(5, 35)));  // was -1924.124
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['contrast']) || isset($_POST[outoftwo('contrast',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['contrast'])) . str_replace(' ','+',newurldecode($_POST['contrast'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_CONTRAST, getpostmaybe('arg1',rand(-100, 100))); // was -90
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['brightness']) || isset($_POST[outoftwo('brightness',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['brightness'])) . str_replace(' ','+',newurldecode($_POST['brightness'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_BRIGHTNESS, getpostmaybe('arg1',rand(-255, 255))); // was 98
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['sketchy']) || isset($_POST[outoftwo('sketchy',$vs)]) || isset($_GET['mean_removal']) || isset($_POST[outoftwo('mean_removal',$vs)]) || isset($_GET['mean-removal']) || isset($_POST[outoftwo('mean-removal',$vs)]))  {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['sketchy'])) . str_replace(' ','+',newurldecode($_POST['sketchy'])) . $zfilename));
      }
      imagefilter($jm_php, IMG_FILTER_MEAN_REMOVAL);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['flipvertical']) || isset($_POST[outoftwo('flipvertical',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['flipvertical'])) . str_replace(' ','+',newurldecode($_POST['flipvertical'])) . $zfilename));
      }
      $jm_php=ourImageFlip($jm_php, '1'); //imageflip($jm_php, IMG_FLIP_VERTICAL);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['fliphorizontal']) || isset($_POST[outoftwo('fliphorizontal',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['fliphorizontal'])) . str_replace(' ','+',newurldecode($_POST['fliphorizontal'])) . $zfilename));
      }
      $jm_php=ourImageFlip($jm_php, '2'); //imageflip($jm_php, IMG_FLIP_HORIZONTAL);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['flip']) || isset($_POST[outoftwo('flip',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['flip'])) . str_replace(' ','+',newurldecode($_POST['flip'])) . $zfilename));
      }
      $jm_php=ourImageFlip($jm_php, '3'); //imageflip($jm_php, IMG_FLIP_BOTH);
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }      
      
    } else if (isset($_GET['scale']) || isset($_POST[outoftwo('scale',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['flip'])) . str_replace(' ','+',newurldecode($_POST['flip'])) . $zfilename));
      }
      $wh = imagesx($jm_php);
      $ht = imagesy($jm_php);

      //file_put_contents("qwe.qwe2", "wh=" . $wh . " and ht=" . $ht);
      if (trim($myargs) != '') {
      $iim_php = imagecreatetruecolor(intval($wh * floatval($myargs)),intval($ht * floatval($myargs)));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh * floatval($myargs)),intval($ht * floatval($myargs)),intval($wh),intval($ht)); //, imagecolorallocate($jm_php,255,255,255)); 
      } else if (isset($_GET['arg1'])) {
      $iim_php = imagecreatetruecolor(intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_GET['arg1']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_GET['arg1']))))));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_GET['arg1']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_GET['arg1']))))),intval($wh),intval($ht)); //, imagecolorallocate($jm_php,255,255,255)); 
      } else if (isset($_POST['arg1'])) {
      $iim_php = imagecreatetruecolor(intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1']))))));
      //file_put_contents("qwe.qwe3", '' . intval($wh));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1']))))),intval($wh),intval($ht));  
      //file_put_contents("qwe.qwe4", '' . intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1']))))));
      } else if (isset($_GET['scale'])) {
      if (strlen($_GET['scale']) == 0) {
      $iim_php = imagecreatetruecolor(intval($wh),intval($ht));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh),intval($ht),intval($wh),intval($ht));  
      } else {
      $iim_php = imagecreatetruecolor(intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_GET['scale']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_GET['scale']))))));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_GET['scale']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_GET['scale']))))),intval($wh),intval($ht)); 
      } 
      } else if (isset($_POST['scale'])) {
      //file_put_contents("qwe.qwe3", '' . (trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      if (strlen($_POST['scale']) == 0) {
      $iim_php = imagecreatetruecolor(intval($wh),intval($ht));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh),intval($ht),intval($wh),intval($ht));  
      } else {
      $iim_php = imagecreatetruecolor(intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_POST['scale']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_POST['scale']))))));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh * floatval(trim(str_replace('+',' ',newurldecode($_POST['scale']))))),intval($ht * floatval(trim(str_replace('+',' ',newurldecode($_POST['scale']))))),intval($wh),intval($ht)); 
      }
      //file_put_contents("qwe.qwe4", '' . floatval(trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      } else {
      $iim_php = imagecreatetruecolor(intval($wh),intval($ht));
      imagecopyresampled($iim_php,$jm_php,0,0,0,0,intval($wh),intval($ht),intval($wh),intval($ht)); 
      }
      //file_put_contents("qwe.qwe5", $zfilename);
      imagedestroy($jm_php);
      $jm_php=$iim_php;
      if ($oktoend) {
      return $iim_php; //$new_name = 'anewimage0.jpg'; 
      }
    } else if (isset($_GET['crop']) || isset($_POST[outoftwo('crop',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['edge'])) . str_replace(' ','+',newurldecode($_POST['edge'])) . $zfilename));
      }
      $icc=0;
      $cc = getpostmaybe('arg1',16777215);
      $hcc=str_replace('#','',color_name_to_hex(str_replace(' ','',strtolower("${cc}"))));      
      if ("${hcc}" != str_replace(' ','',strtolower("${cc}"))) { $cc=$hcc; }
      if (strtolower("${cc}") == "white") {
      $cc=16777215;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "transparent") {
      $cc=16777215;
      $iim_php = imagecropauto($jm_php, IMG_CROP_TRANSPARENT);
      } else if (strtolower("${cc}") == "black") {
      $cc=0;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "blue") {
      $cc=255;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "green") {
      $cc=intval(255 * 256);
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "red") {
      $cc=intval(255 * 256 * 256);
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strpos("${cc}", ",") !== false) {
      $acc=explode(",", "${cc}");
      if (sizeof($acc) >= 4) {
      if (floatval(hexdec(explode(')', $acc[3])[0])) == 0) {
      $iim_php = imagecropauto($jm_php, IMG_CROP_TRANSPARENT);
      } else if (sizeof($acc) >= 3) {
      $icc+=intval(hexdec(explode(')', $acc[2])[0]));
      $icc+=intval(intval(hexdec(explode(')', $acc[1])[0])) * 256);
      $icc+=intval(intval(hexdec(explode('(', $acc[0])[-1 + sizeof(explode('(', $acc[0]))])) * 256 * 256);
      $cc="${icc}";
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else {
      $cc=16777215;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      } else {
      $cc=16777215;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      } else if (str_replace("0","",str_replace("1","",str_replace("2","",str_replace("3","",str_replace("4","",str_replace("5","",str_replace("6","",str_replace("7","",str_replace("8","",str_replace("9","",$cc)))))))))) != '') {
      $xcc=hexdec("${cc}");
      $cc=$xcc;
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else {
      $iim_php = imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      imagedestroy($jm_php);
      $jm_php=$iim_php;
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['merge']) || isset($_POST[outoftwo('merge',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $imd=false;
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['edge'])) . str_replace(' ','+',newurldecode($_POST['edge'])) . $zfilename));
      }
      if ($lastio) {
      $cci = getpostmaybe('arg1',50);
      //$iim_php = imagecreatetruecolor(intval(imagesx($jm_php)),intval(imagesy($jm_php)));
      imagecopymerge_alpha($jm_php, $lastio, 0, 0, 0, 0, $lastw, $lasth, intval($cci));
      $iim_php=$jm_php;
      //file_put_contents('qwef.qwef', 'lastw=' . $lastw);
      } else {
      $iim_php=$jm_php;
      }
      if ($oktoend) {
      return $iim_php; //$new_name = 'anewimage0.jpg'; 
      } else {
      $lastio=$iim_php;
      $lastw=imagesx($iim_php);
      $lasth=imagesy($iim_php);
      }
    } else if (isset($_GET['transparent']) || isset($_POST[outoftwo('transparent',$vs)])) {
      $giffile='';
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['edge'])) . str_replace(' ','+',newurldecode($_POST['edge'])) . $zfilename));
      }
      $icc=0;
      $cc = getpostmaybe('arg1',16777215);
      $hcc=str_replace('#','',color_name_to_hex(str_replace(' ','',strtolower("${cc}"))));
      if ("${hcc}" != str_replace(' ','',strtolower("${cc}"))) { $cc=$hcc; }
      if (strtolower("${cc}") == "white") {
      $cc=16777215;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "transparent") {
      $cc=16777215;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_TRANSPARENT);
      } else if (strtolower("${cc}") == "black") {
      $cc=0;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "blue") {
      $cc=255;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "green") {
      $cc=intval(255 * 256);
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strtolower("${cc}") == "red") {
      $cc=intval(255 * 256 * 256);
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else if (strpos("${cc}", ",") !== false) {
      $acc=explode(",", "${cc}");
      if (sizeof($acc) >= 4) {
      if (floatval(hexdec(explode(')', $acc[3])[0])) == 0) {
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_TRANSPARENT);
      } else if (sizeof($acc) >= 3) {
      $icc+=intval(hexdec(explode(')', $acc[2])[0]));
      $icc+=intval(intval(hexdec(explode(')', $acc[1])[0])) * 256);
      $icc+=intval(intval(hexdec(explode('(', $acc[0])[-1 + sizeof(explode('(', $acc[0]))])) * 256 * 256);
      $cc="${icc}";
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else {
      $cc=16777215;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      } else {
      $cc=16777215;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      } else if (str_replace("0","",str_replace("1","",str_replace("2","",str_replace("3","",str_replace("4","",str_replace("5","",str_replace("6","",str_replace("7","",str_replace("8","",str_replace("9","",$cc)))))))))) != '') {
      $xcc=hexdec("${cc}");
      $cc=$xcc;
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      } else {
      $iim_php = imagecolortransparent($jm_php, intval($cc)); // imagecropauto($jm_php, IMG_CROP_THRESHOLD, 3, intval($cc));
      }
      //imagedestroy($jm_php);
      //$jm_php=$iim_php;
      if ($oktoend) {
      return $jm_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($jm_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($jm_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    } else if (isset($_GET['rotation']) || isset($_POST[outoftwo('rotation',$vs)])) {
      $giffile='';
      //file_put_contents("qwe.qwe1", $zfilename);
      if (!$jm_php) {
      $jm_php = imagecreatefromstring(ourfile_get_contents(str_replace(' ','+',newurldecode($_GET['flip'])) . str_replace(' ','+',newurldecode($_POST['flip'])) . $zfilename));
      }
      //file_put_contents("qwe.qwe2", $zfilename);
      if (trim($myargs) != '') {
      $iim_php=imagerotate($jm_php, floatval($myargs), imagecolorallocate($jm_php,255,255,255)); 
      } else if (isset($_GET['arg1'])) {
      $iim_php=imagerotate($jm_php, floatval(trim(str_replace('+',' ',newurldecode($_GET['arg1'])))), imagecolorallocate($jm_php,255,255,255)); 
      } else if (isset($_POST['arg1'])) {
      //file_put_contents("qwe.qwe3", '' . (trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      $iim_php=imagerotate($jm_php, floatval(trim(str_replace('+',' ',newurldecode($_POST['arg1'])))), imagecolorallocate($jm_php,255,255,255)); 
      //file_put_contents("qwe.qwe4", '' . floatval(trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      } else if (isset($_GET['rotation'])) {
      if (strlen($_GET['rotation']) == 0) {
      $iim_php=imagerotate($jm_php, 0.0, imagecolorallocate($jm_php,255,255,255)); 
      } else {
      $iim_php=imagerotate($jm_php, floatval(trim(str_replace('+',' ',newurldecode($_GET['rotation'])))), imagecolorallocate($jm_php,255,255,255));
      } 
      } else if (isset($_POST['rotation'])) {
      //file_put_contents("qwe.qwe3", '' . (trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      if (trim($myargs) != '') {
      $iim_php=imagerotate($jm_php, floatval($myargs), imagecolorallocate($jm_php,255,255,255)); 
      } else if (strlen($_POST['rotation']) == 0) {
      $iim_php=imagerotate($jm_php, 0.0, imagecolorallocate($jm_php,255,255,255)); 
      } else {
      $iim_php=imagerotate($jm_php, floatval(trim(str_replace('+',' ',newurldecode($_POST['rotation'])))), imagecolorallocate($jm_php,255,255,255)); 
      }
      //file_put_contents("qwe.qwe4", '' . floatval(trim(str_replace('+',' ',newurldecode($_POST['rotation'])))));
      } else {
      $iim_php=imagerotate($jm_php, 0.0, imagecolorallocate($jm_php,255,255,255)); 
      }
      //file_put_contents("qwe.qwe5", $zfilename);
      imagedestroy($jm_php);
      $jm_php=$iim_php;
      if ($oktoend) {
      return $iim_php; //$new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      //file_put_contents("qwe.qwe6", $zfilename);
      imagejpeg($iim_php, $new_name);
      //file_put_contents("qwe.qwe7", $zfilename);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      //file_put_contents("qwe.qwe8", $zfilename);
      imagedestroy($jm_php);
      imagedestroy($iim_php);
      //file_put_contents("qwe.qwe9", $zfilename);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/pdfimageplustext.php") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('slideshow')) {   parent.document.getElementById('slideshow').value=parent.undobackup('" . datauriit($qpzm) . "'); parent.forcescale(); }   \"></body></html>";
       exit;
      }      
      return $qpzm;
      }
    }
    }
    if ($giffile != '') {
      return null;
    }
    return imagecreatefromstring(file_get_contents(str_replace('https:','http:',preg_replace('{^//}','http://',$zfilename)))); // 'data:image/' . substr($ext,1) . ";base64," . base64_encode(ourfile_get_contents($zfilename));
 }
 
 function ourglob($ofwhat, $inext) {
   global $giffile, $gifdurl, $imd, $lastio,$lastw,$lasth,$results, $inputask, $erroris, $zipfile, $ziparrwh, $ziparrc, $ziparr, $fspec, $ext, $width, $height, $iferr, $includesare, $cr, $crd, $dcr, $quality, $tablerows;
   $image=null;
   $lastname="";
    //file_put_contents('xpp.xpp', $includesare);
   $concernyourself=0;
   if ($zipfile == "") {
     if ($erroris == "") {
      return glob($ofwhat);
     } else if (strpos(strtolower($ofwhat), 'http') !== false || strpos(strtolower($ofwhat), '//') !== false || strpos(strtolower($ofwhat), ',') !== false) {
      $ourfs=explode(',', $ofwhat);
      for ($ijk=0; $ijk<sizeof($ourfs); $ijk++) {
        if (strpos($inputask, "<scr") === false) {
           $inputask.="<br><sc" . "ript type=text/javascript> function onl() {  document.getElementById('deta').innerHTML='+'; document.getElementById('myh1').innerHTML='<input type=button style=display:inline-block; onclick=\"cura=0; checkca();\" title=All value=Downloadable></input> Image Conversions'; } setTimeout(onl, 3000); </scr" . "ipt>";
        }
         $ourfilename=explode('#', explode('?', $ourfs[$ijk])[0])[0];
         $ext="." . explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))];
        //$new_file=str_replace($ext, strtolower(str_replace('..','.',"." . $inext)), $ourfilename);
        $new_file=basename(str_replace($ext, (str_replace('..','.',"." . $inext)), $ourfilename));
        //echo $ofwhat . "<br>" . $ourfilename . "<br>" . $ext . "<br>" . $inext . "<br>" . $new_file;
        if (file_exists($new_file)) {
          $new_file=basename(str_replace($ext, strtoupper(str_replace('..','.',"." . $inext)), $ourfilename));
        }
        if (file_exists($new_file)) {
          $new_file=basename(str_replace($ext, strtolower(str_replace('..','.',"." . $inext)), $ourfilename));
        }
        if (file_exists($new_file)) {
          $new_file=basename(str_replace($ext, (str_replace('..','.',"." . $inext)), $ourfilename));
          while (file_exists($new_file)) {
            $new_file=basename(str_replace((str_replace('..','.',"." . $inext)), "0" . (str_replace('..','.',"." . $inext)), $new_file));
          }
        }
        array_push($ziparr, $new_file); //$ourfilename);
        //$im_php = imagecreatefromstring(file_get_contents(str_replace('https:','http:',$ourfilename)));
        $im_php = ourimagecreatefromfile($ourfilename);
        if ($giffile != '') {
        list($width, $height) = getimagesize($giffile);
        $new_file=$giffile;
        $lastio=null;
        } else {
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        $lastio=$im_php;
        }
        $lastw=$width;
        $lasth=$height;
        switch (strtolower($inext)) {
    case '.jpg':
    case '.jpeg':
       $image = imagejpeg($im_php, $new_file, $quality);
    break;
    case '.gif':
       if ($giffile == '') {
       $image = imagegif($im_php, $new_file);
       }
    break;
     case '.bmp':
      if (function_exists('imagebmp')) {
       $image = imagebmp($im_php, $new_file, true);
      }
    break;
     case '.png':
       $image = imagepng($im_php, $new_file);
    break;
        }
        if ($imd && $im_php) { imagedestroy($im_php); }
        //array_push($ziparrwh, '' . $width . ',' . $height);
        //array_push($ziparrc, file_get_contents($new_file));
        //if (!file_exists($new_file)) { echo "<br>oops RE " . $new_file . "<br>"; }
        if (isset($_GET['absurl'])) {
        if (strlen($_GET['absurl']) == 0) {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a>#<a target=_blank id=oneabs href='" . str_replace('http://','//',str_replace('https://','//',str_replace('+',' ',urldecode($_GET['absurl'])))) . "'>" . str_replace('+',' ',urldecode($_GET['absurl'])) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        $_GET['absurl']='';
        }
        } else if ($_POST['absurl']) {
        if (strlen($_POST['absurl']) == 0) {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a>#<a target=_blank id=oneabs href='" . str_replace('http://','//',str_replace('https://','//',str_replace('+',' ',urldecode($_POST['absurl'])))) . "'>" . str_replace('+',' ',urldecode($_POST['absurl'])) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        $_POST['absurl']='';
        }
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        }
        if (strlen($results) > 0) {
        $results.="New image " . $new_file . " created ... \n";
        }
        if (strpos(strtolower($_SERVER['SERVER_NAME']), 'rjmprogramming.com.au') === false) {
        //imagedestroy($image);
        if (isset($_GET['delfile']) || isset($_POST['delfile'])) {
        unlink($new_file);
        }
        } else {
        unlink($new_file);
        }
      }
      $zipfile=" ";
      return $ziparr;
     } else {
      foreach (glob($ofwhat) as $ourfilename) { 
        if (strpos($inputask, "<scr") === false) {
           $inputask.="<br><sc" . "ript type=text/javascript> function onl() {  document.getElementById('deta').innerHTML='+'; document.getElementById('myh1').innerHTML='<input type=button style=display:inline-block; onclick=\"cura=0; checkca();\" title=All value=Downloadable></input> Image Conversions'; } setTimeout(onl, 3000); </scr" . "ipt>";
        }
        $ext="." . explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))];
        //$new_file=str_replace($ext, strtolower(str_replace('..','.',"." . $inext)), $ourfilename);
        $new_file=str_replace($ext, (str_replace('..','.',"." . $inext)), $ourfilename);
        //echo $ofwhat . "<br>" . $ourfilename . "<br>" . $ext . "<br>" . $inext . "<br>" . $new_file;
        if (file_exists($new_file)) {
          $new_file=str_replace($ext, strtoupper(str_replace('..','.',"." . $inext)), $ourfilename);
        }
        if (file_exists($new_file)) {
          $new_file=str_replace($ext, strtolower(str_replace('..','.',"." . $inext)), $ourfilename);
        }
        if (file_exists($new_file)) {
          $new_file=str_replace($ext, (str_replace('..','.',"." . $inext)), $ourfilename);
          while (file_exists($new_file)) {
            $new_file=str_replace((str_replace('..','.',"." . $inext)), "0" . (str_replace('..','.',"." . $inext)), $new_file);
          }
        }
        array_push($ziparr, $new_file); //$ourfilename);
        $im_php = ourimagecreatefromfile($ourfilename);
        if ($giffile != '') {
        list($width, $height) = getimagesize($giffile);
        $new_file=$giffile;
        $lastio=null;
        } else {
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        $lastio=$im_php;
        }
        $lastw=$width;
        $lasth=$height;
        switch (strtolower($inext)) {
    case '.jpg':
    case '.jpeg':
       $image = imagejpeg($im_php, $new_file, $quality);
    break;
    case '.gif':
       if ($giffile == '') {
       $image = imagegif($im_php, $new_file);
       }
    break;
     case '.bmp':
      if (function_exists('imagebmp')) {
       $image = imagebmp($im_php, $new_file, true);
      }
    break;
     case '.png':
       $image = imagepng($im_php, $new_file);
    break;
        }
        if ($imd && $im_php) { imagedestroy($im_php); }
        //array_push($ziparrwh, '' . $width . ',' . $height);
        //array_push($ziparrc, file_get_contents($new_file));
        //if (!file_exists($new_file)) { echo "<br>oops RE " . $new_file . "<br>"; }
        if (isset($_GET['absurl'])) {
        if (strlen($_GET['absurl']) == 0) {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a>#<a target=_blank id=oneabs href='" . str_replace('http://','//',str_replace('https://','//',str_replace('+',' ',urldecode($_GET['absurl'])))) . "'>" . str_replace('+',' ',urldecode($_GET['absurl'])) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        $_GET['absurl']='';
        }
        } else if ($_POST['absurl']) {
        if (strlen($_POST['absurl']) == 0) {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a>#<a target=_blank id=oneabs href='" . str_replace('http://','//',str_replace('https://','//',str_replace('+',' ',urldecode($_POST['absurl'])))) . "'>" . str_replace('+',' ',urldecode($_POST['absurl'])) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        $_POST['absurl']='';
        }
        } else {
        $tablerows.="<tr><th><a class=ca title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . ">" . basename($new_file) . "</a></th></tr><tr><td><details open><summary></summary><a title='Click to download " . basename($new_file) . "' target=_blank download=" . basename($new_file) . " href=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "><img style='width:" . $width . "px;height:" . $height . "px;' title='Click to download " . basename($new_file) . "' src=" . 'data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $new_file)[-1 + sizeof(explode(".", $new_file))])) . ';base64,' . newbase64_encode(newfile_get_contents($new_file)) . "></img></a><br>\n</details></td></tr>";
        }
        if (strlen($results) > 0) {
        $results.="New image " . $new_file . " created ... \n";
        }
        if (strpos(strtolower($_SERVER['SERVER_NAME']), 'rjmprogramming.com.au') === false) {
        //imagedestroy($image);
        if (isset($_GET['delfile']) || isset($_POST['delfile'])) {
        unlink($new_file);
        }
        } else {
        unlink($new_file);
        }
      }
      $zipfile=" ";
      return $ziparr;
     }
   } else {
     $zip = zip_open($zipfile);
     if ($zip) {
      while ($zip_entry = zip_read($zip)) {
       $ourfilename=zip_entry_name($zip_entry);
       if (strpos($includesare, $ourfilename) !== false || $includesare == '') {
       $regexpok=0;
       if (strpos($ourfilename, "_MACOSX/") === false) {
       $regexp="/^[\S]" . str_replace('[\s\S]?','[\s\S]*',str_replace('*','[\s\S]?',str_replace('?',',',str_replace('%',',',str_replace('.','[.]',$ofwhat))))) . "$/";
       $regexpok=preg_match($regexp, explode("/",$ourfilename)[-1 + sizeof(explode("/",$ourfilename))]);
       if ($regexpok !== 0) {
        if ($ext == "") $ext="." . explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))];
        if ($iferr != "" && strpos($iferr, "&include=&") !== false) {
          $iferr=str_replace("&include=&", "&include=" . urlencode($ourfilename) . "&", $iferr);
          $lastname=$ourfilename;
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a " . $adatam . "onmouseover=\"butwhatif(this,'" . less($ourfilename) . "');\" onclick=\"butwhatif(this,'" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . basename($ourfilename) . "</a>"; }
          $crd="\n";
        } else if ($iferr != "" && $concernyourself == 1) {
          $iferr=str_replace("&include=" . urlencode($lastname) . "&", "&include=" . urlencode($lastname . "," . $ourfilename) . "&", $iferr);
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a " . $adatam . "onmouseover=\"butwhatif(this,'" . less($ourfilename) . "');\" onclick=\"butwhatif(this,'" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . basename($ourfilename) . "</a>"; }
          $crd="\n";
        } else {
          $cr.=$crd . $ourfilename;
          if ($dcr != " ") { $dcr.=$crd . "<a " . $adatam . "onmouseover=\"butwhatif(this,'" . less($ourfilename) . "');\" onclick=\"butwhatif(this,'" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . basename($ourfilename) . "</a>"; }
          $crd="\n";
        }
        array_push($ziparr, $ourfilename);
        $isc=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
        $im_php = imagecreatefromstring($isc);
        if ($giffile != '') {
        list($width, $height) = getimagesize($giffile);
        $new_file=$giffile;
        $lastio=null;
        } else {
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        imagedestroy($im_php);
        }
        array_push($ziparrwh, '' . $width . ',' . $height);
        array_push($ziparrc, $isc);
       }
       }
       } else { // reject this one
       if (strpos($ourfilename, "_MACOSX/") === false) {
       $regexp="/^[\S]" . str_replace('[\s\S]?','[\s\S]*',str_replace('*','[\s\S]?',str_replace('?',',',str_replace('%',',',str_replace('.','[.]',$ofwhat))))) . "$/";
       $regexpok=preg_match($regexp, explode("/",$ourfilename)[-1 + sizeof(explode("/",$ourfilename))]);
       if ($regexpok !== 0) {
          $cr.=$crd . $ourfilename;
          if ($dcr != " ") { $dcr.=$crd . "<a " . $adatam . "onmouseover=\"butwhatif(this,'" . less($ourfilename) . "');\" onclick=\"butwhatif(this,'" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . basename($ourfilename) . "</a>"; }
          $crd="\n";
       }
       }
       }
      }
      zip_close($zip);
      $includesare="";
     }
     //echo $zhuha;
     //exit;
     return $ziparr;
   }
 }
 
 function openthese($rts) {
   $xsss=explode("ew image ", $rts);
   for ($irts=1; $irts<sizeof($xsss); $irts++) {
    if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     exec('' . explode(' create', $xsss[$irts])[0]);
    } else {
     exec('open ' . explode(' create', $xsss[$irts])[0]);
    }
   }
   return $rts;   
 }

if (isset($argc) && !$iscurl && !isset($_GET['amnotcurl'])) {
echo openthese($results);
} else {
$htmlis="<!doctyle html>
<html>
<head>
<title>Image Conversions via PHP GD - RJM Programming - October, 2022</title>
<style>
  body { background-color: #f0e0e0; }
  th { border-top: 1px dotted red; text-align: left; }
  .ca:visited {  color: pink;  }
  #sfilter { background-color: yellow; }
  #tsfilter { background-color: cyan; }
  #mysub { background-color: orange; }
  #mygif { opacity: 0.0; }
  #mysource { opacity: 0.0; }
  #myvideo { opacity: 0.0; }
</style>
<s" . "cript type=text/javascript>
  var fsuff='" . server_remote_addr() . "'; 
  var cura=0;
  var slidetot=0;
  var nextcls=2;
  var duripsofar=' ';
  var aaas=[];
  var sla=[], isla=0, jsla=0, jstep=0, secondgo=false;
  var ignore=false, lastsslo='';
  var aska=false;
  var askastr=';merge;50;transparent;16777215;crop;16777215;rotation;0;scale;1;emboss;array([-2, -1, 0], [-1, 1, 1], [0, 1, 2]);brightness;255;contrast;100;smooth;35;pixellate;9;colourize;255,255,255;colourizegreen;255;colourizeblue;255;colourizered;255;boxblur;array([1, 1, 1], [1, 1, 1], [1, 1, 1]);edge;array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]);negedge;array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]);sharpen;array([0, -1, 0], [-1, 5, -1], [0, -1, 0]);';
  var vwo=null, wvo=null; 
 
  function ondblc(eo) { 
    if (eo.id.indexOf('gif') != -1) {
    vwo=window.open('','_blank','top=100,left=100,height=600,width=600'); 
    if (document.getElementById('div' + eo.id)) {
    vwo.document.write('<html><body>' + document.getElementById('div' + eo.id).outerHTML.replace(/jtog\(\)/g, 'window.opener.jtog()') + '<style> #mygif { opacity: 0.0; }  #myvideo { opacity: 0.0; }  </style></body></html>'); 
    } else {
    vwo.document.write('<html><body>' + eo.outerHTML + '</body></html>'); 
    }
    } else {
    wvo=window.open('','_blank','top=0,left=0,height=' + screen.height + ',width=' + screen.width); 
    if (document.getElementById('div' + eo.id)) {
    wvo.document.write('<html><body>' + document.getElementById('div' + eo.id).outerHTML.replace(/jtog\(\)/g, 'window.opener.jtog()') + '<style> #mygif { opacity: 0.0; }  #myvideo { opacity: 0.0; }  </style></body></html>'); 
    } else {
    wvo.document.write('<html><body>' + eo.outerHTML + '</body></html>'); 
    }
    }
  } 

  function checkca() {
    if (aaas.length == 0) { aaas=document.getElementsByTagName('a'); }
    for (var ias=0; ias<aaas.length; ias++) {
      if (('' + aaas[ias].className) == 'ca' && ias == cura) {
        if (cura > 10) { alert(aaas[ias].title); }
        aaas[ias].click();
        cura++;
        setTimeout(checkca, 5000);
      } else if (ias == cura) {
        cura++;
        setTimeout(checkca, 200);
      }
    }
  }

  function closeall() {
    var aas=document.getElementsByTagName('details');
    for (var ias=0; ias<aas.length; ias++) {
      if (('' + aas[ias].id) != 'doif') {
       if (document.getElementById('deta').innerHTML == '+') {
        aas[ias].removeAttribute('open');
        //aas[ias].style.display='none';
       } else {
        aas[ias].setAttribute('open',true);
       }
      }
    }
    if (document.getElementById('deta').innerHTML == '+') {
      document.getElementById('deta').innerHTML='-';
    } else {
      document.getElementById('deta').innerHTML='+';
    }
  }


function zoomsame(tvo, tvv) {
  var tv=tvo.value;
  var rest='';
  var getcls='';
  if (tvv != '') { tv=tvv;  }
  var pa=null;
  if (tv.trim() == '' && ('' + tv.length) != '0') { aska=true; }
  if (tv.trim() != '') {
    if (document.getElementById('whenmulti').value.indexOf(tv + '=') != -1) {
      rest=tv + '=' + document.getElementById('whenmulti').value.split(tv + '=')[1].split(';')[0];
      if (document.getElementById('whenmulti').value.indexOf(rest + ';') != -1) { rest+=';'; }
      document.getElementById('whenmulti').value=document.getElementById('whenmulti').value.replace(rest, '');
      if (document.getElementById('whenmulti').value != '') {  
        tvo.name=document.getElementById('whenmulti').value.split('=')[0];   
      } else {
        tvo.name='sfilter';
      }
      tvo.innerHTML=tvo.innerHTML.replace(' value=\"' + tv + '\">' + tvo.innerHTML.split(' value=\"' + tv + '\">')[1].split(' ')[0] + ' ', ' value=\"' + tv + '\">');
      getcls=tvo.innerHTML.split(' value=\"' + tv + '\">')[0].split(' class=\"')[eval(-1 + tvo.innerHTML.split(' value=\"' + tv + '\">')[0].split(' class=\"').length)].split('\"')[0];
      if (getcls != '') { tvo.innerHTML=tvo.innerHTML.replace(' class=\"' + getcls + '\"', '');  }
      return '';
    }
    if (tvo.outerHTML.indexOf(' name=') == -1) { tvo.name=tv.trim(); } else if (('' + tvo.name) == 'sfilter') {  tvo.name=tv.trim();    } 
    if (aska && askastr.indexOf(';' + tv.trim().toLowerCase() + ';') != -1) {
     pa=prompt(('Optionally enter argument(s) for ' + tv.trim()).replace(' for crop', ' for crop (via RGB - to 255 colour range integer = R x 256 x 256 + G x 256 + B) or transparent').replace(' for transparent', ' for transparent (via RGB - to 255 colour range integer = R x 256 x 256 + G x 256 + B)'), askastr.split(';' + tv.trim().toLowerCase() + ';')[1].split(';')[0]);
     if (pa != null) {
      if (pa.trim() == '') { pa=null; }
     }
    }
    if (pa != null) {
      if (document.getElementById('whenmulti').value == '') {
       document.getElementById('whenmulti').value=tv + '=' + pa;
      } else {
       document.getElementById('whenmulti').value+=';' + tv + '=' + pa;
       document.getElementById('presub').innerHTML+='<input type=hidden name=' + tv.trim() + ' value=></input>';
      }
      if (('' + pa.split(',').length) == '3') {
        document.getElementById('rotation').name='args';
        document.getElementById('rotation').value=pa;
      } else {
        document.getElementById('rotation').name='arg1';
        document.getElementById('rotation').value=pa;
      }
      tvo.innerHTML=tvo.innerHTML.replace(' value=\"' + tv + '\">', ' class=\"opt' + ('00' + nextcls).slice(-3) + '\" value=\"' + tv + '\">&#10004; ');
      nextcls++;
      sortsel(tvo);
    } else {
      if (document.getElementById('whenmulti').value == '') {
       document.getElementById('whenmulti').value=tv + '=' + '';
      } else {
       document.getElementById('whenmulti').value+=';' + tv + '=' + '';
       document.getElementById('presub').innerHTML+='<input type=hidden name=' + tv.trim() + ' value=></input>';
      }
      tvo.innerHTML=tvo.innerHTML.replace(' value=\"' + tv + '\">', ' class=\"opt' + ('00' + nextcls).slice(-3) + '\" value=\"' + tv + '\">&#10004; ');
      nextcls++;
      document.getElementById('rotation').name='rotation';
      document.getElementById('rotation').value='' + document.getElementById('trot').value;
      sortsel(tvo);
    }
    if (tv.trim().toLowerCase() == 'redo') {
    redo();
    }     //alert(11);
    //}
  }
}

function sortsel(insel) {
  var sv=insel.value;
  var optsa=insel.innerHTML.split('</option>');
  var sopta=optsa.sort();
  var newih='';
  for (var ioj=0; ioj<sopta.length; ioj++) {
    newih+=sopta[ioj] + '</option>';
  }
  insel.innerHTML=newih;
  insel.value=sv;
}

function redo() {
}

function postdext() {
   var valis=document.getElementById('outext').value;
   document.getElementById('dext').innerHTML='<select id=outext name=outext>' + document.getElementById('extsel').innerHTML.replace('none','block') + '</select>';
   if (valis.trim() != '') {
      if (document.getElementById('dext').innerHTML.indexOf('>' + ('.' + valis.toLowerCase()).replace('..','.') + '<') != -1) {
       if (document.getElementById('dext').innerHTML.indexOf('>' + ('.' + valis).replace('..','.') + '<') == -1) {
         document.getElementById('outext').innerHTML+='<option value=\"' + ('.' + valis).replace('..','.') + '\">' + ('.' + valis).replace('..','.') + '</option>';
       }
       document.getElementById('outext').value=('.' + valis).replace('..','.');
      }
   } else {
      document.getElementById('outext').value=valis;
   }
}

function lookforabsolute(ino) {
   var setu='';
   if (eval(('' + ino.value.trim()).length) == 8 && ino.value.indexOf('.') == -1 && (ino.value + ' ').substring(0,1) >= '2' && (ino.value + ' ').substring(0,1) <= '9') {
      setu='https://www.rjmprogramming.com.au/ITblog/500/500/?mustbedated=' + ino.value.trim();
      ino.value=setu;
      setTimeout(function(){
        if (document.getElementById('ispec').value.indexOf('//www.rjmprogramming.com.au/ITblog/500/500/?mustbedated=') != -1) {
          var xxs=document.getElementById('ispec').value.split('//www.rjmprogramming.com.au/ITblog/500/500/?mustbedated=')[1];
          document.getElementById('ispec').value='https://picsum.photos/600/400/?rand=' + xxs;
          lookforabsolute(document.getElementById('ispec'));
        }
      }, 10000);
   } else if (eval(('' + ino.value.trim()).length) == 8 && ino.value.indexOf('.') == -1 && (ino.value + ' ').substring(0,1) >= '0' && (ino.value + ' ').substring(0,1) <= '1') {
      setu='https://picsum.photos/600/400/?rand=' + ino.value.trim();
      ino.value=setu;
   }  
   if (ino.value.indexOf('data:') == 0 && ino.value.indexOf('image/') != -1) {
     //alert(1);
     document.getElementById('absimg').value=ino.value;
     //alert(2);
     document.getElementById('sabsi').click();
     //alert(3);
     if (document.getElementById('outext').outerHTML.indexOf('.' + ino.value.split('image/')[1].split(';')[0]) != -1) {
     document.getElementById('outext').value='.' + ino.value.split('image/')[1].split(';')[0];
     } else if (document.getElementById('outext').outerHTML.indexOf('<input ') != -1 && eval(('' + ino.value.split('image/')[1].split(';')[0]).length) <= 4) {
     document.getElementById('outext').value='.' + ino.value.split('image/')[1].split(';')[0];
     }
   } else if (ino.value.indexOf('//') != -1) {
     if (document.getElementById('outext').outerHTML.indexOf('.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0]) != -1) {
     document.getElementById('outext').value='.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0];
     } else if (document.getElementById('outext').outerHTML.indexOf('<input ') != -1 && eval(('' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0]).length) <= 4) {
     document.getElementById('outext').value='.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0];
     }
     ino.title=ino.value;
     document.getElementById('ifi').src='./convert_wildcard.php?absimg=' + encodeURIComponent('http://' + ino.value.split('//')[1]);
   } else if (document.getElementById('outext').outerHTML.indexOf('.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0]) != -1) {
     document.getElementById('outext').value='.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0];
   } else if (document.getElementById('outext').outerHTML.indexOf('<input ') != -1 && eval(('' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0]).length) <= 4) {
     document.getElementById('outext').value='.' + ino.value.split('.')[eval(-1 + ino.value.split('.').length)].split('?')[0].split('#')[0];
   }
}
        
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+='<style> input[type=file]::file-selector-button { background-color: pink; } </style>';
        aconto.getElementById('files').accept='image/*';
        aconto.getElementById('files').style.border='5px solid yellow';
        aconto.getElementsByTagName('h1')[0].style.visibility='hidden';
        aconto.getElementsByTagName('h3')[0].style.visibility='hidden';
        //arect=aconto.getElementById('files').getBoundingClientRect();
        //alert(2);
        //aconto.getElementById('files').click();
        if (secondgo) {
        aconto.getElementById('files').removeAttribute('multiple');
        }
      }
    }
  } 
} 

function durip(indiv) {
  var tryi=2, pluseq=1;
  if (('' + document.getElementById('slideshow').getAttribute('data-slide1')).replace(/^undefined/g,'').replace(/^null/g,'') != '') {
    tryi=1;
    pluseq=2;
  } else if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
    tryi++;
  }
  if (document.title.indexOf('durip ...') == -1) {
  if (1 == 4) { document.title='durip ... '; }
  }
  if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') != '') {
    while (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') != '') {
      tryi+=pluseq;
      pluseq=1;
    }
    while (duripsofar.indexOf(' ' + tryi + ' ') != -1) {
      tryi+=pluseq;
      pluseq=1;
    }
    //tryi--;
    duripsofar+=' ' + tryi + ' ';
  //document.title+='  tryi=' + tryi;
    //if (lastsslo != indiv) {
    //lastsslo=indiv;
    //sla.push(indiv);
    //}
    document.getElementById('slideshow').setAttribute('data-slide' + tryi, indiv);
    setTimeout(function(){
      if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).trim() != '') {
      if (eval('' + sla.length) == 0) {
      sla.push(document.getElementById('slideshow').getAttribute('data-slide' + tryi));
      } else if (sla[eval(-1 + sla.length)].indexOf(document.getElementById('slideshow').getAttribute('data-slide' + tryi)) == -1) {
      sla.push(document.getElementById('slideshow').getAttribute('data-slide' + tryi));
      }
  if (eval('' + sla.length) >= 2) {
      document.getElementById('vlist').style.display='inline-block';
      document.getElementById('aglist').style.display='inline-block';
      var sofarv=' ';
      for (var ihg=0; ihg<sla.length; ihg++) {
      sofarv+=String.fromCodePoint(128993);
      }
      document.getElementById('vlist').value=document.getElementById('vlist').value.split(' ')[0].trim() + sofarv;
      document.getElementById('aglist').value=document.getElementById('aglist').value.split(' GIF')[0].trim() + ' GIF' + sofarv;
  }
      }
    }, eval(tryi * 50 + 500));
  } else {
    duripsofar+=' ' + Math.min(tryi,3) + ' ';
    document.getElementById('slideshow').setAttribute('data-slide' + Math.min(tryi,3), indiv);
  //document.title+='  Tryi=' + Math.min(tryi,3);
  }
}

function sslook() {
  var sslo='';
  var tryi=2, pluseq=1;
  if (('' + document.getElementById('slideshow').getAttribute('data-slide1')).replace(/^undefined/g,'').replace(/^null/g,'') != '') {
    tryi=1;
    pluseq=2;
  } 
  if (ignore) {
    setTimeout(sslook, 5000);
    return '';
  }
  if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
    tryi+=pluseq;
    pluseq=1;
  }
  if (sslo.trim() == '') {
  if (document.getElementById('slideshow').value.indexOf('data:') == 0) {
    if (document.getElementById('slideshow').value.indexOf('image/') != -1) {
      sslo=document.getElementById('slideshow').value;
  if (document.title.indexOf('durip ...') == -1) {
  if (3 == 6) { document.title='durip ... Sslo.length=' + sslo.length + ' '; }
  }
    }
  } else {
    if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') != '') {
      if (document.title.indexOf('durip ') == 0) { document.title+=' here ';  }
      while (sslo == '') {
        sslo=('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'').trim();
        if (sslo != '') {
          if (lastsslo != sslo) {
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi);
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi, ' ');
      if (document.title.indexOf('durip ') == 0) { document.title+=' no' + tryi + ' ';  }
          } else {
          sslo='';
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi);
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi, ' ');
      if (document.title.indexOf('durip ') == 0) { document.title+=' No' + tryi + ' ';  }
          }
        }
        if (sslo == '') {
          tryi+=pluseq;
          pluseq=1;
          if (('' + document.getElementById('slideshow').getAttribute('data-slide' + tryi)).replace(/^undefined/g,'').replace(/^null/g,'') == '') {
            //tryi++;
          //} else {
            tryi--;
            sslo=' ';
            //alert('here renew');
            //renewlist();
          }
        }
      }
      sslo=sslo.trim();
      if (document.title.indexOf('durip ') == 0) { document.title+=' sslo.length=' + sslo.length + ' ';  }
      if (sslo.trim() != '') {   
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi);
          document.getElementById('slideshow').removeAttribute('data-slide' + tryi, ' ');
      }
    }
  }
  }
  if (lastsslo != sslo && sslo.trim() != '') {
  lastsslo=sslo;
  if (eval('' + sla.length) == 0) {
  sla.push(sslo);
  } else if (sla[eval(-1 + sla.length)].indexOf(sslo) == -1) {
  sla.push(sslo);
  }
      if (document.title.indexOf('durip ') == 0) { document.title+=' found sla.length=' + sla.length + ' ';  document.getElementById('myh1').innerHTML='Image Conversions ' + document.title;  }
  if (!document.getElementById(('slideshow' + slidetot).replace('slideshow0','slideshow'))) {
    document.getElementById('dslides').innerHTML+=\"<input type=hidden name=vandagimg\" + slidetot + \" id=slideshow\" + slidetot + \" style=display:none; title='' value=''></input>\";
  }
  document.getElementById(('slideshow' + slidetot).replace('slideshow0','slideshow')).value='';
  if (eval('' + sla.length) >= 2) {
      document.getElementById('vlist').style.display='inline-block';
      document.getElementById('aglist').style.display='inline-block';
      var sofarv=' ';
      for (var ihg=0; ihg<sla.length; ihg++) {
      sofarv+=String.fromCodePoint(128993);
      }
      document.getElementById('vlist').value=document.getElementById('vlist').value.split(' ')[0].trim() + sofarv;
      document.getElementById('aglist').value=document.getElementById('aglist').value.split(' GIF')[0].trim() + ' GIF' + sofarv;
  }
  if (sslo.trim() != '') {
    document.getElementById(('slideshow' + slidetot).replace('slideshow0','slideshow')).title=sslo;
    if (slidetot == 0) {
      slidetot+=2;
      if (document.getElementById('vlist').value.indexOf('&') != -1) {
      document.getElementById('vlist').value=document.getElementById('vlist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      document.getElementById('vlist').value=document.getElementById('vlist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      document.getElementById('aglist').value=document.getElementById('aglist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      document.getElementById('aglist').value=document.getElementById('aglist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      } else {
      document.getElementById('vlist').value+=' ' + String.fromCodePoint(128308); // + ' ..';
      document.getElementById('aglist').value+=' ' + String.fromCodePoint(128308); //..';
      }
    } else if (eval('' + sla.length) >= 2) {
      slidetot++;
      if (eval(-1 + slidetot) == eval('' + sla.length)) {
      if (document.getElementById('vlist').value.indexOf('&') != -1) {
      document.getElementById('vlist').value=document.getElementById('vlist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      document.getElementById('aglist').value=document.getElementById('aglist').value.replace(String.fromCodePoint(128993), String.fromCodePoint(128308));
      } else {
      document.getElementById('vlist').value+=String.fromCodePoint(128308); //'.';
      document.getElementById('aglist').value+=String.fromCodePoint(128308); //'.';
      }
      document.getElementById('vlist').style.display='inline-block';
      document.getElementById('aglist').style.display='inline-block';
      } else {
      sslo='';
      }
    }
    if (sslo != '') {
    document.getElementById('ispec').value=sslo;
    if (!document.getElementById('slideshow' + slidetot)) {
    document.getElementById('dslides').innerHTML+=\"<input type=hidden name=vandagimg\" + slidetot + \" id=slideshow\" + slidetot + \" style=display:none; title='' value=''></input>\";
    }
    lookforabsolute(document.getElementById('ispec'));
    }
    //alert(sslo);
    sslo='';
    setTimeout(sslook, 5000);
  } else {
    sslo='';
    setTimeout(sslook, 5000);
  }
  } else {
    sslo='';
    setTimeout(sslook, 5000);
  }
}

function renewlist() {
   var iid='slideshow', icnt=1;
   while (document.getElementById(iid)) {
      if (eval('' + sla.length) > eval(-1 + icnt)) {
  if (!document.getElementById(iid)) {
    document.getElementById('dslides').innerHTML+=\"<input type=hidden name=vandagimg\" + icnt + \" id=slideshow\" + icnt + \" style=display:none; title='' value=''></input>\";
  }
      document.getElementById(iid).value=sla[eval(-1 + icnt)];
      document.getElementById(iid).title='';
      }
      icnt++;
      iid='slideshow' + icnt;
   }
   return true;
}

function ttov() {
   var iid='slideshow', icnt=1, dolat=false;
   ignore=true;
   dolat=true;
   document.body.style.cursor='progress';
   while (document.getElementById(iid)) {
      if (eval('' + sla.length) > eval(-1 + icnt)) {
  if (!document.getElementById(iid)) {
    document.getElementById('dslides').innerHTML+=\"<input type=hidden name=vandagimg\" + icnt + \" id=slideshow\" + icnt + \" style=display:none; title='' value=''></input>\";
  }
      document.getElementById(iid).value=sla[eval(-1 + icnt)];
      document.getElementById(iid).title='';
      }
      icnt++;
      iid='slideshow' + icnt;
   }
   icnt=1;
   iid='slideshow';
   while (document.getElementById(iid)) {
      if (document.getElementById(iid).name == 'nowayjose' && document.getElementById(iid).outerHTML.indexOf('data:') != -1) {
        document.getElementById(iid).name=document.getElementById(iid).id.replace('slideshow', 'vandagimg');
      }
      if (document.getElementById(iid).title.indexOf('data:') == 0 && document.getElementById(iid).value.indexOf('data:') != 0) {
        document.getElementById(iid).value=document.getElementById(iid).title;
        document.getElementById(iid).title='';
        if (iid == 'slideshow') {
          dolat=true;
        } else {
          document.getElementById(iid).name=document.getElementById(iid).id.replace('slideshow', 'vandagimg');
        }
      } else if (document.getElementById(iid).title.indexOf('data:') != 0 && document.getElementById(iid).value.indexOf('data:') == 0) {
        icnt=icnt;
      } else if (document.getElementById(iid).title == '' && document.getElementById(iid).value.indexOf('data:') != 0) {
        document.getElementById(iid).name='nowayjose';
      }
      icnt++;
      iid='slideshow' + icnt;
   }
   if (dolat) {
      setTimeout(function(){
   var iid='slideshow', icnt=1;
   document.body.style.cursor='progress';
   while (document.getElementById(iid)) {
      if (document.getElementById(iid).name == 'nowayjose' && document.getElementById(iid).outerHTML.indexOf('data:') != -1) {
        document.getElementById(iid).name=document.getElementById(iid).id.replace('slideshow', 'vandagimg');
      }
      if (document.getElementById(iid).value.indexOf('data:') == 0 && document.getElementById(iid).title.indexOf('data:') != 0) {
        document.getElementById(iid).title=document.getElementById(iid).value;
        document.getElementById(iid).value='';
      } else if (document.getElementById(iid).title.indexOf('data:') == 0 && document.getElementById(iid).value.indexOf('data:') != 0) {
        icnt=icnt;
      } else if (document.getElementById(iid).title == '' && document.getElementById(iid).name == 'nowayjose') {
        document.getElementById(iid).name='vandagimg' + icnt;
      }
      icnt++;
      iid='slideshow' + icnt;
   }
   ignore=false;
   document.body.style.cursor='pointer';
      }, 3000); //30000);   
   }
   document.body.style.cursor='pointer';
   lastsslo='';
   secondgo=true;
   document.getElementById('cbi').src='/HTMLCSS/client_browsing.htm?d=567' + Math.floor(Math.random() * 1987865);
   return true;
}

function jtog() {
   jstep=eval(1 - eval('' + jstep)); 
}

function myvideolook() {
  var myvideooh='';
  if (document.getElementById('myvideo')) {
    myvideooh=document.getElementById('myvideo').outerHTML;
    if (!document.getElementById('divmyvideo')) {
      var dets=document.getElementsByTagName('details');
      if (document.getElementsByTagName('details')[0].outerHTML.indexOf('<video ') != -1) {
        document.getElementsByTagName('details')[0].innerHTML=document.getElementsByTagName('details')[0].innerHTML.replace('<video ' + document.getElementsByTagName('details')[0].outerHTML.split('<video ')[1].split('</video>')[0] + '</video>', '&nbsp;&nbsp;<div id=divmyvideo style=display:inline-block;>' + myvideooh.replace('<video ', '<video onmousedown=jtog(); ontoiuchdown=jtog(); ') + '</div>');
      } else {
        dets[eval(-1 + dets.length)].innerHTML=dets[eval(-1 + dets.length)].innerHTML.replace('<video ' + dets[eval(-1 + dets.length)].outerHTML.split('<video ')[1].split('</video>')[0] + '</video>', '&nbsp;&nbsp;<div id=divmyvideo style=display:inline-block;>' + myvideooh.replace('<video ', '<video onmousedown=jtog(); ontoiuchdown=jtog(); ') + '</div>');
      }
    }
    //document.getElementById('myvideo').onmousedown=function(){  jstep=eval(1 - eval('' + jstep));   };
    //document.getElementById('myvideo').ontouchdown=function(){  jstep=eval(1 - eval('' + jstep));   };
    document.getElementById('divmyvideo').style.backgroundImage='URL(' + sla[0] + ')';
    document.getElementById('divmyvideo').style.backgroundSize='cover';
    document.getElementById('divmyvideo').style.backgroundRepeat='no-repeat';
    document.getElementById('divmyvideo').style.zIndex='-9';
    setInterval(myvideoslait, 1000);
    return '';
  } 
  setTimeout(myvideolook, 500);
}

function myvideoslait() {
  var bloop=' looping ';
  jsla+=jstep;
  if (jsla >= eval('' + sla.length)) {
    jsla=0;
  }
  if (jsla == 0) {
    bloop+=' (at start) ';
    document.getElementById('divmyvideo').style.border='5px dotted yellow';
  } else if (jsla == 1) {
    document.getElementById('divmyvideo').style.border='0px dotted yellow';
  }
  if (jstep == 0) {
  if (('' + document.getElementById('myvideo').title).indexOf('Slide ' + eval(1 + jsla) + ' of ' + sla.length) == -1 || ('' + document.getElementById('myvideo').title).indexOf(' playing ') != -1) {
  document.getElementById('myvideo').title='Video ... Slide ' + eval(1 + jsla) + ' of ' + sla.length + ' ... 1 second delay' + bloop + '... paused (click/tap to play) ... ' + ('' + new Date()); 
  }
  } else {
  document.getElementById('myvideo').title='Video ... Slide ' + eval(1 + jsla) + ' of ' + sla.length + ' ... 1 second delay' + bloop + '... playing ...'; 
  }
  document.getElementById('divmyvideo').style.backgroundImage='URL(' + sla[jsla] + ')';
  if (wvo) {
    wvo.document.getElementById('divmyvideo').style.backgroundImage='URL(' + sla[jsla] + ')';
    wvo.document.getElementById('myvideo').title=document.getElementById('myvideo').title;
  if (jsla == 0) {
    wvo.document.getElementById('divmygif').style.border='1px dotted yellow';
  } else if (jsla == 1) {
    wvo.document.getElementById('divmygif').style.border='0px dotted yellow';
  }
  }
}

function mygifslait() {
  var bloop=' looping ';
  isla++;
  if (isla >= eval('' + sla.length)) {
    isla=0;
  }
  if (isla == 0) {
    bloop+=' (at start) ';
    document.getElementById('divmygif').style.border='5px dotted yellow';
  } else if (isla == 1) {
    document.getElementById('divmygif').style.border='0px dotted yellow';
  }
  document.getElementById('mygif').title='Animated GIF ... Slide ' + eval(1 + isla) + ' of ' + sla.length + ' ... 5 second delay' + bloop + '...'; 
  document.getElementById('divmygif').style.backgroundImage='URL(' + sla[isla] + ')';
  if (vwo) {
    vwo.document.getElementById('divmygif').style.backgroundImage='URL(' + sla[isla] + ')';
    vwo.document.getElementById('mygif').title=document.getElementById('mygif').title;
  if (isla == 0) {
    vwo.document.getElementById('divmygif').style.border='1px dotted yellow';
  } else if (isla == 1) {
    vwo.document.getElementById('divmygif').style.border='0px dotted yellow';
  }
  }
}

function mygiflook() {
  var mygifoh='';
  if (document.getElementById('mygif')) {
    mygifoh=document.getElementById('mygif').outerHTML;
    if (!document.getElementById('divmygif')) {
      var dets=document.getElementsByTagName('details');
      if (document.getElementsByTagName('details')[0].outerHTML.indexOf('<img ') != -1) {
        document.getElementsByTagName('details')[0].innerHTML=document.getElementsByTagName('details')[0].innerHTML.replace('<img ' + document.getElementsByTagName('details')[0].outerHTML.split('<img ')[1].split('<scrip')[0].split('</details>')[0], '&nbsp;&nbsp;<div id=divmygif style=display:inline-block;>' + mygifoh + '</div>');
      } else {
        dets[eval(-1 + dets.length)].innerHTML=dets[eval(-1 + dets.length)].innerHTML.replace('<img ' + dets[eval(-1 + dets.length)].outerHTML.split('<img ')[1].split('<scrip')[0].split('</details>')[0], '&nbsp;&nbsp;<div id=divmygif style=display:inline-block;>' + mygifoh + '</div>');
      }
    }
    document.getElementById('divmygif').style.backgroundImage='URL(' + sla[0] + ')';
    document.getElementById('divmygif').style.backgroundSize='cover';
    document.getElementById('divmygif').style.backgroundRepeat='no-repeat';
    document.getElementById('divmygif').style.zIndex='-9';
    setInterval(mygifslait, 5000);
    return '';
  } 
  setTimeout(mygiflook, 500);
}

setTimeout(postdext, 15000);
setTimeout(sslook, 5000);
setTimeout(mygiflook, 500);
setTimeout(myvideolook, 500);
  
</sc" . "ript>
</head>
<body" . $onl . ">
<h1 id=myh1>Image Conversions</h1>
<h3>RJM Programming <a onclick=closeall(); id=deta style='cursor:pointer;text-decoration:none;'>-</a> October, 2022 ... &nbsp;&nbsp;<iframe onload='iifopen(this);' id='cbi' frameborder='0' style='width:173px;height:228px;margin-top:-184px;' scrolling='no' src='/HTMLCSS/client_browsing.htm?d=323324051632686'></iframe></h3>
<table>" . $tablerows . "
</table>" . $inputask . "
<select id=extsel style=display:none; id=xxxoutext><option value=''>Enter output relative image file extension [.jpeg]</option><option value=.jpeg>.jpeg</option><option value=.jpg>.jpg</option><option value=.png>.png</option><option value=.gif>.gif</option><option value=.JPEG>.JPEG</option><option value=.JPG>.JPG</option><option value=.PNG>.PNG</option><option value=.GIF>.GIF</option></select>
<iframe style=display:none; id=ifi name=ifi src=./convert_wildcard.php></iframe>
<form method=POST action='/convert_wildcard.php' target=ifi style=display:none;>
<input type=hidden name=absimg id=absimg value=''></input><input id=sabsi type=submit value=Submit style=display:none;></input></form>
<div id=result style=display:none;></div>
<form id=cowform target=mycowifr onsubmit='return ttov();' method=POST action=/cowsay.php>
<div id=dslides style=display:none;>
<input type=hidden id=slideshow name=vandagimg1 style=display:none; title='' value=''></input>
</div>
<input style=display:none;background-color:lightblue; type=submit value=Video id=vlist name=vlist></input>&nbsp;&nbsp;<input style=display:none;background-color:lightgreen; type=submit value='Animated GIF' id=aglist name=aglist></input>
</form>
<div id=slideshowdiv>
<div id=divcowpf></div>
</div>
<iframe name='mycowifr' id='mycowifr' style='display:none;' src='/About_Us.html'></iframe>
</body>
</html>";
 if (!$iscurl) {
   echo $htmlis;
 } else {
   $phtmlis="temphtml.html";
   while (file_exists($phtmlis)) {
     $phtmlis=str_replace(".htm", "0.htm", $phtmlis);
   }
   file_put_contents($phtmlis, $htmlis);
   //exec("cd " . dirname(__FILE__) . " ; open " . $phtmlis); // . " ; rm -f " . $phtmlis);
   echo "Please issue command ...\nopen http://www.rjmprogramming.com.au/" . $phtmlis . " \n ... to see results.  Omit the open word for Windows.  You have up to the next minute to do this. ";
 }
}
?>
