#thone { background:URL(\"' + document.getElementById('result').innerHTML + '\"); background-repeat:no-repeat; } #thtwo { background:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(\"' + document.getElementById('result').innerHTML + '\"); background-repeat:repeat; } #hthree { background:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(\"' + document.getElementById('result').innerHTML + '\"); background-size:cover; background-repeat:no-repeat; } #result { background:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(\"' + document.getElementById('result').innerHTML + '\"); background-size:contain; background-repeat:no-repeat; } #borderimg1 { border-image: url(\"' + document.getElementById('result').innerHTML + '\") 30%; border-image-repeat: round; } #borderimg2 { border-image: url(\"' + document.getElementById('result').innerHTML + '\") 20%; border-image-repeat: stretch; } '; ";
$transparent="transparent";
$ei="Emoji Image";
$cr="Creator";
$imgw="image";
$iimage="image";
$iaudio="ywnft";
$ivideo="ywnft";
$gps="window.open(\"https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.rjmprogramming.com.au%2FPHP%2Femoji_image.php&tab=mobile\",\"_blank\",\"top=50,left=50,height=900,width=1300\");";
$hblurb="Copy (Image) from Google PageSpeed
(thanks, and note to toggle between mobile and desktop tabs perhaps)
and Paste via macOS Alt-PrtScr Below (for Data URI as well)
or to an Image Editor that can Crop out Extraneous White Parts
or Resize Image and Save
(ready for Border Image or Background Image or just Image purposes)";
if (isset($_GET['audio'])) {
$hblurb="Copy Audio
via Finder or Windows Explorer
and come Back Here to Paste that Data";
$ei="Audio";
$cr="Paster";
$imgw="audio";
$iaudio="audio";
$iimage="ywnft";
$ivideo="ywnft";
$gps="";
} else if (isset($_GET['video'])) {
$hblurb="Copy Video
via Finder or Windows Explorer
and come Back Here to Paste that Data";
$ei="Video";
$cr="Paster";
$imgw="video";
$ivideo="video";
$iaudio="ywnft";
$iimage="ywnft";
$gps="";
}
function mycrop($src, array $rect) { // thanks to https://stackoverflow.com/questions/26722811/imagecrop-alternative-for-php-5-5
$dest = imagecreatetruecolor($rect['width'], $rect['height']);
imagecopy(
$dest,
$src,
0,
0,
$rect['x'],
$rect['y'],
$rect['width'],
$rect['height']
);
return $dest;
}
function imageTrimBox($img, $hex=null) { // thanks to https://stackoverflow.com/questions/1669683/crop-whitespace-from-image-in-php
if (!ctype_xdigit($hex)) $hex = imagecolorat($img, 0,0);
$b_top = $b_lft = 0;
$b_rt = $w1 = $w2 = imagesx($img);
$b_btm = $h1 = $h2 = imagesy($img);
do {
//top
for(; $b_top < $h1; ++$b_top) {
for($x = 0; $x < $w1; ++$x) {
if(imagecolorat($img, $x, $b_top) != $hex) {
break 2;
}
}
}
// stop if all pixels are trimmed
if ($b_top == $b_btm) {
$b_top = 0;
$code = 2;
break 1;
}
// bottom
for(; $b_btm >= 0; --$b_btm) {
for($x = 0; $x < $w1; ++$x) {
if(imagecolorat($img, $x, $b_btm-1) != $hex) {
break 2;
}
}
}
// left
for(; $b_lft < $w1; ++$b_lft) {
for($y = $b_top; $y <= $b_btm; ++$y) {
if(imagecolorat($img, $b_lft, $y) != $hex) {
break 2;
}
}
}
// right
for(; $b_rt >= 0; --$b_rt) {
for($y = $b_top; $y <= $b_btm; ++$y) {
if(imagecolorat($img, $b_rt-1, $y) != $hex) {
break 2;
}
}
}
$w2 = $b_rt - $b_lft;
$h2 = $b_btm - $b_top;
$code = ($w2 < $w1 || $h2 < $h1) ? 1 : 0;
} while (0);
// result codes:
// 0 = Trim Zero Pixels
// 1 = Trim Some Pixels
// 2 = Trim All Pixels
return array(
'#' => $code, // result code
'l' => $b_lft, // left
't' => $b_top, // top
'r' => $b_rt, // right
'b' => $b_btm, // bottom
'w' => $w2, // new width
'h' => $h2, // new height
'w1' => $w1, // original width
'h1' => $h1, // original height
);
}
$gei="";
$xgei="";
if (isset($_GET['emoji_textarea_image'])) {
$gei=str_replace("+"," ",urldecode($_GET['emoji_textarea_image']));
$xgei=$gei;
}
if (isset($_POST['emoji_uncropped_image']) && isset($_POST['ewidth']) && isset($_POST['eheight'])) {
// data:image/png;base64,
$datauri=str_replace(" ","+",urldecode($_POST['emoji_uncropped_image']));
if (strpos($datauri, "data:image/") !== false && strpos($datauri, ";base64,") !== false) {
$newdu = $datauri;
$ext = explode("data:image/", explode(";base64,",$datauri)[0])[1];
$rnum = "" . rand(0,198675433);
$im = imagecreatefromstring(base64_decode(explode(";base64,",$datauri)[1]));
if (1 == 1) {
// find the trimmed image border
$box = imageTrimBox($im);
// copy cropped portion
$im_crop = imagecreate($box['w'], $box['h']);
imagecopy($im_crop, $im, 0, 0, $box['l'], $box['t'], $box['w'], $box['h']);
} else {
$im_crop = mycrop($im, ['x' => 0, 'y' => 0, 'width' => str_replace("+"," ",urldecode($_POST['ewidth'])), 'height' => str_replace("+"," ",urldecode($_POST['eheight']))]);
}
$delit="";
//$im_crop = imagecropauto($im, IMG_CROP_WHITE);
if (strtolower($ext) == "png") { // || substr(strtolower($ext),0,2) == "jp" || strtolower($ext) == "gif") {
imagepng($im_crop, "crop_orig" . $rnum . ".png");
$newdu = "data:image/png;base64," . base64_encode(file_get_contents("crop_orig" . $rnum . ".png"));
// $delit="rm -f " . dirname(__FILE__) . "/crop_orig" . $rnum . ".png"; //
unlink("crop_orig" . $rnum . ".png");
} else if (substr(strtolower($ext),0,2) == "jp") {
imagejpeg($im_crop, "crop_orig" . $rnum . ".jpeg");
$newdu = "data:image/jpeg;base64," . base64_encode(file_get_contents("crop_orig" . $rnum . ".jpeg"));
// $delit="rm -f " . dirname(__FILE__) . "/crop_orig" . $rnum . ".jpeg"; //
unlink("crop_orig" . $rnum . ".jpeg");
} else if (strtolower($ext) == "gif") {
imagegif($im_crop, "crop_orig" . $rnum . ".gif");
$newdu = "data:image/" . $ext . ";base64," . base64_encode(file_get_contents("crop_orig" . $rnum . ".gif"));
// $delit="rm -f " . dirname(__FILE__) . "/crop_orig" . $rnum . ".gif"; //
unlink("crop_orig" . $rnum . ".gif");
//} else if (strtolower($ext) == "bmp") {
// imagebmp($im_crop, "crop_orig" . $rnum . ".bmp");
// $newdu = "data:image/" . $ext . ";base64," . base64_encode(file_get_contents("crop_orig" . $rnum . ".bmp"));
// unlink("crop_orig" . $rnum . ".bmp");
}
imagedestroy($im);
imagedestroy($im_crop);
echo "
" . str_replace("\n","
",str_replace(".", ";", str_replace("+"," ",$etext))) . ";
" . str_replace("\n","
",$etext) . "
". str_replace("","","" . str_replace(".", ";", str_replace("+"," ",$etext)) . ";") . "
" . $ei . " " . $cr . " (Paste Below) | Data URI |
---|---|
" . $xgei . "
"; //$eresult=file_get_contents("https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.rjmprogramming.com.au%2FPHP%2Femoji_image.php"); //file_put_contents('emojiimage.txt', $eresult); //exec("sleep 15; rm -f " . dirname(__FILE__) . "/emoji_image.txt"); } else { echo "