Created
April 20, 2017 23:56
-
-
Save binzram/db7b43c34c1a1df60ba16de3e36bcb4d to your computer and use it in GitHub Desktop.
creates an reflection thumbnail (2013-11-25) similar to 1st gen Ipod product photos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Reflection\ProcImg; | |
class Reflection{ | |
private $size; | |
private $width; | |
private $height; | |
private $hoehe; | |
private $breite; | |
private $pathimg; | |
private $paththumb; | |
public function __construct($paththumb, $pathrefl){ | |
$halb = 0.50; | |
$start = 80; | |
$stop = 0; | |
$detail = getimagesize($paththumb); | |
$width = $detail[0]; | |
$height = $detail[1]; | |
$type = $detail[2]; | |
$mime = $detail['mime']; | |
$neuehohe = $height*$halb; | |
switch($mime){ | |
case "image/jpeg": | |
$source = imagecreatefromjpeg($paththumb); | |
break; | |
case "image/gif": | |
$source = imagecreatefromgif($paththumb); | |
break; | |
case "image/png": | |
$source = imagecreatefrompng($paththumb); | |
break; | |
} | |
$spieglung = imagecreatetruecolor($width,$neuehohe); | |
$buffer = imagecreatetruecolor($width,$neuehohe); | |
imagesavealpha($spieglung,true); | |
imagesavealpha($buffer,true); | |
imagecopy($spieglung, $source, 0, 0, 0, $height - $neuehohe, $width, $neuehohe); | |
for ($y=0; $y<$neuehohe; $y++){ | |
imagecopy($buffer, $spieglung, 0, $y, 0, $neuehohe - $y - 1, $width, 1); | |
} | |
$spieglung = $buffer; | |
$trans = abs($start-$stop); | |
imagelayereffect($spieglung,IMG_EFFECT_OVERLAY); | |
for ($y=0; $y<=$neuehohe; $y++){ | |
$prozenthohe = $y/$neuehohe; | |
if ($start>$stop){ | |
$alpha = (int)($start- ($prozenthohe*$trans)); | |
} | |
else{ | |
$alpha = (int)($start+ ($prozenthohe*$trans)); | |
} | |
$trans2 = 127-$alpha; | |
imagefilledrectangle($spieglung, 0, $y, $width, $y, imagecolorallocatealpha($spieglung, 127, 127, 127, $trans2)); | |
} | |
imagepng($spieglung, $pathrefl); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment