Advertisement
kotvalera83

api.php

Sep 7th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. $org_info = getimagesize($f);
  2. if ($value->scale && $value->scale != 1) {
  3.     $scale = $value->scale;
  4.     $scale_val = array(($org_info[0] * (float)$scale), ($org_info[1] * (float)$scale));
  5.     $layer->fx('resize', $scale_val[0], $scale_val[1]); // Scale   
  6.     $scale_min_x = ($org_info[0] - $scale_val[0]) / 2;
  7.     $scale_min_y = ($org_info[1] - $scale_val[1]) / 2;
  8.     $n_x = str_replace('px', '',$value->x) * 4.36 + $scale_min_x;
  9.     $n_y = str_replace('px', '',$value->y) * 4.65 + $scale_min_y;
  10. }else{
  11.     $n_x = str_replace('px', '',$value->x) * 4.36;
  12.     $n_y = str_replace('px', '',$value->y) * 4.65;
  13.     $scale_val = $org_info;
  14. }  
  15. if ($value->rotation) {
  16.     $layer->fx('rotate', (360 - round((float)$value->rotation * 360)) ); // Rotation
  17.     $img_temp = $_SERVER['DOCUMENT_ROOT'] . '/uploads/images/full/temp-' .$value->img;
  18.     $layer->imageJpeg($img_temp);
  19.     $lb = getimagesize($img_temp);
  20.     $newSize = array(
  21.         "width" => $lb[0],
  22.             "height" => $lb[1]
  23.      );
  24.     $x = $n_x - ( $newSize["width"] - $scale_val[0]) / 2;
  25.     $y = $n_y - ( $newSize["height"] - $scale_val[1]) / 2;
  26. }else{
  27.     $x = $n_x;
  28.     $y = $n_y;
  29. }              
  30.  
  31. $image = new Image\Canvas($name);
  32. $image->draw('layer', $layer, $x, $y, true);
  33. $image->imageJpeg($name);
  34. unset($image);
  35. unset($layer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement