[fix] bugs
This commit is contained in:
parent
b40452b0fb
commit
46ba08519b
6 changed files with 241 additions and 23 deletions
33
public/montage.php
Normal file
33
public/montage.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
$img = $_POST['img'];
|
||||
$horizontal = intval( $_POST['horizontal'] );
|
||||
$vertical = intval( $_POST['vertical'] );
|
||||
$bgImage = basename( $_POST['bgImage'], ".jpg");
|
||||
$landscape = intval( $_POST['landscape'] );
|
||||
function panic( $msg ){
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
die( $msg );
|
||||
}
|
||||
|
||||
if (strpos($img, 'data:image/png;base64') === 0) {
|
||||
|
||||
$img = str_replace('data:image/png;base64,', '', $img);
|
||||
$img = str_replace(' ', '+', $img);
|
||||
$data = base64_decode($img);
|
||||
$file = __DIR__.'/../a4/'.microtime(true).'_'.$bgImage.".png";
|
||||
|
||||
if ( ! file_put_contents($file, $data)) {
|
||||
panic("Failed to save canvas");
|
||||
}
|
||||
|
||||
}else{
|
||||
panic("Not a valid image");
|
||||
}
|
||||
$output = $return_code = NULL;
|
||||
exec( __DIR__."/../page_generator.sh $file $horizontal $vertical $landscape" , $output, $return_code);
|
||||
if( 0 === $return_code ){
|
||||
$pdf = basename(implode("", $output));
|
||||
echo( "https://2020.hackersfest.org//ImageGenerator/a4/".urlencode($pdf) );
|
||||
}else{
|
||||
panic( implode(" / ", $output ) );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue