[fix] montage: smaller, secu

This commit is contained in:
Alban 2019-11-22 23:41:40 +01:00
parent f7f6fa25ea
commit be8354b535
3 changed files with 6 additions and 5 deletions

View File

@ -9,8 +9,8 @@ panic(){ echo $@; exit 2; }
[[ ! -f $IMG ]] && panic "$IMG does not exist" [[ ! -f $IMG ]] && panic "$IMG does not exist"
SMALL_SIDE=4000 SMALL_SIDE=3000
LARGE_SIDE=5800 LARGE_SIDE=4350
# /tmp/out.pdf PDF 567x822 567x822+0+0 16-bit sRGB 980KB 0.010u 0:00.009 # /tmp/out.pdf PDF 567x822 567x822+0+0 16-bit sRGB 980KB 0.010u 0:00.009
read name type GEOMETRY canvas depth format size other <<< $( identify $IMG ) read name type GEOMETRY canvas depth format size other <<< $( identify $IMG )
@ -29,6 +29,6 @@ DATE=$( date +%s )
OUTPUT_DIR=$( dirname ~+ )/a4 OUTPUT_DIR=$( dirname ~+ )/a4
FILENAME=$( basename $IMG ) FILENAME=$( basename $IMG )
PDF_NAME=${OUTPUT_DIR}/${DATE}_${FILENAME}.pdf PDF_NAME=${OUTPUT_DIR}/${DATE}_${FILENAME}.pdf
OUT=$( montage -tile ${COUNT_HORIZONTAL}x${COUNT_VERTICAL} -density 200x200 -units pixelspercentimeter -border 0 -page ${TOTAL_WIDTH}x${TOTAL_HEIGHT} -compress zip -quality 100 "$IMG" -geometry ${REQ_WIDTH}x${REQ_HEIGHT} -duplicate ${DUP},0 ${PDF_NAME} ) OUT=$( montage -tile ${COUNT_HORIZONTAL}x${COUNT_VERTICAL} -density 150x150 -units pixelspercentimeter -border 0 -page ${TOTAL_WIDTH}x${TOTAL_HEIGHT} -compress zip -quality 100 "$IMG" -geometry ${REQ_WIDTH}x${REQ_HEIGHT} -duplicate ${DUP},0 ${PDF_NAME} )
[ 0 -eq $? ] && echo $PDF_NAME || panic "An error occured... $OUT" [ 0 -eq $? ] && echo $PDF_NAME || panic "An error occured... $OUT"

View File

@ -311,7 +311,8 @@ $( "#montage" ).on("submit",function(e){
div.html( "<a href="+url+" target=_blank>Download "+data["horizontal"]+"x"+data["vertical"]+"</a>")        div.html( "<a href="+url+" target=_blank>Download "+data["horizontal"]+"x"+data["vertical"]+"</a>")       
}, },
error: function( data, msg, xhr){ error: function( data, msg, xhr){
console.log( msg) console.log( data)
div.html( "<span class=error>Oops... An error occured.")
}, },
    url: "montage.php",     url: "montage.php",
    data: data          data: data     

View File

@ -21,7 +21,7 @@ if (strpos($img, 'data:image/png;base64') === 0) {
panic("Not a valid image"); panic("Not a valid image");
} }
$output = $return_code = NULL; $output = $return_code = NULL;
exec( __DIR__."/../page_generator.sh ".escapeshellargs($file)." ".escapeshellargs($horizontal)." ".escapeshellargs($vertical)." ".escapeshellargs($landscape) , $output, $return_code); exec( __DIR__."/../page_generator.sh ".escapeshellarg($file)." ".escapeshellarg($horizontal)." ".escapeshellarg($vertical)." ".escapeshellarg($landscape) , $output, $return_code);
if( 0 === $return_code ){ if( 0 === $return_code ){
$pdf = basename(implode("", $output)); $pdf = basename(implode("", $output));
echo( "https://2020.hackersfest.org/ImageGenerator/a4/".urlencode($pdf) ); echo( "https://2020.hackersfest.org/ImageGenerator/a4/".urlencode($pdf) );