24 if( file_exists(
$f ) ) {
30 $d = getimagesize(
$f );
35 $o = (
$w >=
$h ) ?
'l' :
'p';
73 checkfolder( dirname(
$f ) );
75 switch( exif_imagetype(
$f ) ) {
77 return imagecreatefromjpeg(
$f );
80 return imagecreatefrompng(
$f );
83 return imagecreatefromwebp(
$f );
97 function imageCut( $fs,
$d = 1024, $fd =
false, $b =
'MIDDLE' ) {
106 if( $dim[
'o'] ==
'l' ) {
111 $x = ( $b ==
'START' ) ? 0 : ( ( $b ==
'MIDDLE' ) ? round( ( $dim[
'w'] -
$d ) / 2 ) : ( $dim[
'w'] -
$d ) );
120 $y = ( $b ==
'START' ) ? 0 : ( ( $b ==
'MIDDLE' ) ? round( ( $dim[
'h'] -
$d ) / 2 ) : ( $dim[
'h'] -
$d ) );
125 $id = imagecrop( $is, array(
'x' =>
$x,
'y' =>
$y,
'width' => $cw,
'height' =>
$ch ) );
129 imagealphablending(
$id,
false );
130 imagesavealpha(
$id,
true );
131 imagepalettecopy( $is,
$id );
150 checkfolder( dirname(
$f ) );
160 imagejpeg(
$id,
$f );
164 imagealphablending(
$id,
false );
165 imagesavealpha(
$id,
true );
170 imagewebp(
$id,
$f );
210 $ext = array(
'jpg',
'jpeg',
'png',
'webp' );
236 }
elseif( file_exists( $fs ) && in_array(
$x, $ext ) ) {
239 $dimensioni = getimagesize( $fs );
241 $altezza = $dimensioni[1];
242 $larghezza = $dimensioni[0];
245 if( empty( $altezza ) || empty( $larghezza ) ) {
248 logWrite(
'file danneggiato: ' . $fs,
'image', LOG_ERR );
256 if( $altezza > $larghezza &&
$o !=
'l' ) {
259 $valore_riferimento = $larghezza;
260 $valore_secondario = $altezza;
263 $alpha_dim = round( (
$d * $valore_riferimento ) / $valore_secondario );
269 $valore_riferimento = $altezza;
270 $valore_secondario = $larghezza;
276 $beta_dim = round( (
$d * $valore_riferimento ) / $valore_secondario );
281 $identificatore_destinazione = imagecreatetruecolor( $alpha_dim , $beta_dim );
290 $identificatore_provenienza = imagecreatefromjpeg( $fs );
293 imagealphablending( $identificatore_destinazione ,
false );
294 imagesavealpha( $identificatore_destinazione ,
true );
295 $identificatore_provenienza = imagecreatefrompng( $fs );
298 $identificatore_provenienza = imagecreatefromwebp( $fs );
302 $exit_message =
'formato non supportato: ' .
$x;
307 if( empty( $identificatore_provenienza ) ) {
310 logWrite(
'impossibile leggere: ' . $fs,
'image', LOG_DEBUG );
318 logWrite(
'lettura ok: ' . $fs,
'image', LOG_DEBUG );
321 imagepalettecopy( $identificatore_provenienza , $identificatore_destinazione );
324 $cont = imagecopyresampled(
325 $identificatore_destinazione,
326 $identificatore_provenienza,
337 logWrite(
'scalamento corretto a ' .
$d .
'px di: ' . $fs,
'image' , LOG_DEBUG );
338 $exit_message =
'file creato con successo';
342 logWrite(
'impossibile scalare a ' .
$d .
'px: ' . $fs,
'image' , LOG_DEBUG );
343 $exit_message =
'impossibile creare il file ' . $fd;
358 $cont = imagejpeg( $identificatore_destinazione , $fd );
362 $cont = imagepng( $identificatore_destinazione , $fd );
366 $cont = imagewebp( $identificatore_destinazione , $fd );
371 logWrite(
'formato ' .
$x .
' non supportato' ,
'image' , LOG_DEBUG );
379 logWrite(
'scrittura corretta: ' . $fd,
'image' , LOG_DEBUG );
380 $exit_message =
'file creato con successo';
387 logWrite(
'impossibile scrivere: ' . $fd,
'image' , LOG_DEBUG );
388 $exit_message =
'impossibile creare il file ' . $fd;
408 if( ! function_exists(
'imagecrop' ) ) {
409 function imagecrop( $src, array $rect ) {
410 $dest = imagecreatetruecolor( $rect[
'width'], $rect[
'height'] );
logWrite( $m, $f='site', $l=LOG_NOTICE, $d=DIRECTORY_LOG, $t=CURRENT_LOG_LEVEL, $s=SITE_STATUS)
scrive un messaggio nei log del sito
if(!empty($_REQUEST['id'])) $d
if(! isset( $_REQUEST['__view__'][ $ct['view']['id']]['__extra__']['assegnato'])|| $_REQUEST['__view__'][ $ct['view']['id']]['__extra__']['assegnato']=='__me__') elseif($_REQUEST[ '__view__'][$ct[ 'view'][ 'id']][ '__extra__'][ 'assegnato']=='__nessuno__')