Skip to content

Instantly share code, notes, and snippets.

@phosphore
Created December 14, 2014 21:19
Show Gist options
  • Save phosphore/03b29f44e2d6f4c42559 to your computer and use it in GitHub Desktop.
Save phosphore/03b29f44e2d6f4c42559 to your computer and use it in GitHub Desktop.
<?php
include 'lib/WideImage.php';
/* Carico le risorse */
$imagesopra = WideImage::load("a.png"); /* LAYER SOPRA immagine iniziale caricata con WideImage */
$image = WideImage::load("a.png"); /* caricata con WideImage, andremo a modificare questa */
/* Trovo x e y */
$sizex = $image->getWidth();
$sizey = $image->getHeight();
if($sizex < $sizey) { /* immagine verticale */
/* resize e taglio */
$image->resize($sizey, null, 'fill')->crop('center', 'center', $sizey, $sizey)->saveToFile("b.png"); /* larghezza, altezza */
/* blur gaussiano */
exec("convert b.png -blur 0x11 b.png");
/* ricarico b */
$imagesotto = WideImage::load("b.png");
/* centriamo il livello imagesopra in imagesotto e fondiamoli */
$imagesotto->merge($imagesopra, 'center', 'center', $sizex)->saveToFile("b.png");
} else { /* immagine orizzontale */
/* resize e taglio */
$image->resize(null, $sizex, 'fill')->crop('center', 'center', $sizex, $sizex)->saveToFile("b.png"); /* larghezza, altezza */
/* blur gaussiano */
exec("convert b.png -blur 0x11 b.png");
/* ricarico b */
$imagesotto = WideImage::load("b.png");
/* centriamo il livello imagesopra in imagesotto e fondiamoli */
$imagesotto->merge($imagesopra, 'center', 'center', $sizey)->saveToFile("b.png");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment