Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($images) {
- foreach ($images as $value) {
- $f = $_SERVER['DOCUMENT_ROOT'] . '/uploads/images/full/'.$value->img;
- $org_info = getimagesize($f);
- $layer = new Image\Canvas($f);
- $scale = $value->scale * 5;
- $scale_val = array(($org_info[0] * $scale), ($org_info[1] * $scale));
- $layer->fx('resize', $scale_val[0], $scale_val[1]); // Scale
- $scale_min_x = ($scale_val[0] - $org_info[0]) / 2;
- $scale_min_y = ($scale_val[1] - $org_info[1]) / 2;
- $n_x = str_replace('px', '',$value->x) * $per - $scale_min_x; //- $scale * $per;
- $n_y = str_replace('px', '',$value->y) * $per - $scale_min_y; //- $scale * $per;
- if ($value->borderRadius) {
- $rad = $value->borderRadius * $per;
- $layer->fx('corners', $rad, $rad); // Border-Radius
- }
- if ($value->borderD && $value->borderDC) {
- $s = ($value->borderD * $per) * $scale;
- $b = $value->borderD * ($per * 10);
- $layer->draw('border', $b , str_replace('#', '', $value->borderDC)); // Border-Color
- //$s = $b; //$b * $per * -1 / 2 + $b + 5; // $per;
- } else {
- $s = $b = 0;
- }
- if ($value->borderRadius) {
- $layer->fx('corners', $rad, $rad); // Border-Radius
- }
- if ($value->rotation) {
- $layer->fx('rotate', (360 - round((float)$value->rotation * 360)) ); // Rotation
- $img_temp = $_SERVER['DOCUMENT_ROOT'] . '/uploads/images/full/temp-' .$value->img;
- $layer->imageJpeg($img_temp);
- $lb = getimagesize($img_temp);
- $newSize = array(
- "width" => $lb[0],
- "height" => $lb[1]
- );
- $x = $n_x - ( $newSize["width"] - $scale_val[0]) / 2 + $s;
- $y = $n_y - ( $newSize["height"] - $scale_val[1]) / 2 + $s;
- } else {
- $x = $n_x - $s;
- $y = $n_y - $s;
- }
- $image = new Image\Canvas($name);
- $image->draw('layer', $layer, $x, $y, true);
- $image->imageJpeg($name);
- unset($image);
- unset($layer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement