ACC SHELL
<?php
class JpeG {
###############################################
########## TVORBA NAHLEDU - PRVNI CAST ########
function loadjpeg($path, $max_x, $max_y) {
$info = JpeG::get_file_extension($path);
if($info=="jpg"){
$im = imagecreatefromjpeg($path);
}
elseif($info=="png"){
$im = imagecreatefrompng($path);
}
if (!$im) {
$im = imagecreate(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, "Error loading $path", $tc);
}
if ($max_x != 0 && $max_y != 0) {
$x = imagesx($im);
$y = imagesy($im);
if ($x > $max_x) {
$y = (int)floor($y * ($max_x / $x));
$x = $max_x;
}
if ($y > $max_y) {
$x = (int)floor($x * ($max_y / $y));
$y = $max_y;
}
if (imagesx($im) != $x || imagesy($im) != $y) {
$tmp = imagecreatetruecolor($x, $y);
imagecopyresampled($tmp, $im, 0, 0, 0, 0, $x, $y, imagesx($im), imagesy($im));
imagedestroy($im);
$im = $tmp;
}
}
return $im;
}
###############################################
########## TVORBA NAHLEDU - DRUHA CAST ########
function CreateNewIMG ($original,$nahled,$omezX,$omezY) {
//Use Function loadjpeg(filename and path, max width, max height) keeps ratios correct
//requires GD libraries, included automatically with compiled PHP4.3 not sure about self installer for windows
$jpg = JpeG::loadjpeg("$original",$omezX,$omezY);
//uncomment below to create a file from new image, quality 60%, need write permissions to folder
$info = JpeG::get_file_extension($original);
if($info=="jpg"){
imagejpeg($jpg,"$nahled",100);
}
elseif($info=="png"){
imagepng($jpg,"$nahled" );
}
}
function get_file_extension($file_name)
{
return mb_strtolower(substr(strrchr($file_name,'.'),1), "UTF-8");
}
}
?>
ACC SHELL 2018