<?php

namespace app\controllers;

use Yii;
use app\models\Design;
use app\models\DesignSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use app\models\AppSetup;
use app\models\AlphabetsK3;
use app\models\MultipleCase;
use app\components\Shopify;
use yii\web\UploadedFile;
use app\models\SvgSizes;
use app\models\MultipleCaseType;
use app\models\AlphabetsCaseType;
use app\models\SetsCase;
use app\models\SetsCaseTypes;

/**
 * DesignController implements the CRUD actions for Design model.
 */
class DesignController extends Controller {

    /**
     * @inheritdoc
     */
    public $enableCsrfValidation = false;

    public function behaviors() {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                    'deleteSVG' => ['POST'],
                ],
            ],
            'corsFilter' => [
                'class' => \yii\filters\Cors::className(),
                'cors' => [
// restrict access to domains:
                    'Origin' => static::allowedDomains(),
                    'Access-Control-Request-Method' => ['POST'],
                    'Access-Control-Allow-Credentials' => true,
                    'Access-Control-Max-Age' => 3600, // Cache (seconds)
                ],
            ],
        ];
    }

    public static function allowedDomains() {
        return [
// '*' star allows all domains ,
            'https://www.everythingetched.com'
        ];
    }

    /**
     * Lists all Design models.
     * @return mixed
     */
    public function actionIndex() {

        $session = Yii::$app->session;
        $shop = $session->get('shop');

       // echo'<pre>';print_r($shop);die('sa');    
        $app_installed = AppSetup::find()->Where(['shopify_shop' => $shop])->one();
        if (!empty($app_installed)) {

            $shop_id = $app_installed->id;
            $searchModel = new DesignSearch();
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $shop_id);

            return $this->render('index', [
                        'searchModel' => $searchModel,
                        'dataProvider' => $dataProvider,
            ]);
        } else {     
            die("Invalid request");
        }
    }

    /**
     * Displays a single Design model.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionView($id) {
        return $this->render('view', [
                    'model' => $this->findModel($id),
        ]);
    }

    /**
     * Creates a new Design model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate() {

        $model = new Design();
        $session = Yii::$app->session;
        $shop = $session->get('shop');

        $app_installed = AppSetup::find()->Where(['shopify_shop' => $shop])->one();
        if (!empty($app_installed)) {

            $app_secret = Yii::$app->params['app_secret'];
            $app_key = Yii::$app->params['app_key'];
            $shop_id = $app_installed->id;
            $shopify_token = $app_installed->shopify_token;

            $designs = Design::find()->select('product_id')->where(['shop_id' => $shop_id])->all();

            $saved_designs = [];
            if ($designs) {
                foreach ($designs as $key => $value) {
                    if ($value) {
                        array_push($saved_designs, $value->product_id);
                    }
                }
            }
            $product_list = [];

            
            $sc = new Shopify($shop, $shopify_token, $app_key, $app_secret);
            $limit = 250;
            $count = $sc->call('GET', '/admin/api/' . Yii::$app->params['API_VERSION'] . '/products/count.json');
            $ceiled = ceil($count / 250);

            $page_link = "";
            for ($x = 1; $x <= $ceiled; $x++) {

                $product_api = "/admin/api/" . Yii::$app->params['API_VERSION'] . "/products.json?fields=id,title&limit=$limit";
                if($ceiled >= $x && $page_link !== "") {
                    $product_api = "/admin/api/" . Yii::$app->params['API_VERSION'] . "/products.json?fields=id,title&limit=$limit&page_info=".$page_link;
                }

                $resp = $sc->callWithHeader('GET', $product_api);
                $pd = json_decode($resp, true);
                if($ceiled > $x) {
                    $link = substr($pd['header'], (strpos($pd['header'], 'Link: <') + 7), (strpos($pd['header'], '>; rel="next"') - strpos($pd['header'], 'Link:') - 7));
                    $data = explode('&page_info=', $link);
                    $page_link = $data[count($data) - 1];
                }

                $products_details = $pd['products'];
                foreach ($products_details as $key => $value) {

                    if (!in_array($value['id'], $saved_designs)) {
                        $id = (string) $value['id']; // change id to string 
                        $product_list[$id] = $value['title'];
                    }
                }
            }

            if ($model->load(Yii::$app->request->post())) {
                if ($modelimage = UploadedFile::getInstance($model, 'design_svg')) {
                    $stripped = str_replace(' ', '', $modelimage);
                    $file_name = time() . '_' . $stripped;
                    $modelimage->saveAs('uploads/designs/' . $file_name);
                    $model->design_svg = $file_name;
                }

                $product = $sc->call('GET', "/admin/api/" . Yii::$app->params['API_VERSION'] . "/products/" . $model->product_id . ".json");
                $model->shop_id = $shop_id;
                $model->product_title = $product['title'];
                $model->product_image = $product['image']['src'];
                if ($model->save(false)) {
                    Yii::$app->session->setFlash('success', 'Design has been saved Successfully!');
                    return $this->redirect(['index']);
                }
            }

            return $this->render('create', [
                        'model' => $model,
                        'product_list' => $product_list
            ]);
        }
    }

    /**
     * Updates an existing Design model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionUpdate($id) {

        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post())) {
            if ($modelimage = UploadedFile::getInstance($model, 'design_svg')) {
                $stripped = str_replace(' ', '', $modelimage);
                $file_name = time() . '_' . $stripped;
                $modelimage->saveAs('uploads/designs/' . $file_name);
                $model->design_svg = $file_name;
            }
            if ($model->save(false)) {
                Yii::$app->session->setFlash('success', 'Design has been updated Successfully!');
                return $this->redirect(['index']);
            }
        }
        return $this->render('update', [
                    'model' => $model
        ]);
    }

    /**
     * Deletes an existing Design model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionDelete($id) {
        $this->findModel($id)->delete();

        return $this->redirect(['index']);
    }

    /**
     * Finds the Design model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $id
     * @return Design the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id) {
        if (($model = Design::findOne($id)) !== null) {
            return $model;
        }

        throw new NotFoundHttpException('The requested page does not exist.');
    }

    public function actionDeletesvg() {

        if (Yii::$app->request->isPost) {

            $id = Yii::$app->request->post('id');
            $svg_img = Yii::$app->request->post('design_svg');
            $model = $this->findModel($id);
            $model->$svg_img = "";
            if ($model->save(false))
                return $model;
            else
                return $model->$svg_img;
        }
        else {
            return 'eror';
        }
    }

    public function actionGetsvg() {

        $id = Yii::$app->request->get('p_id');
        $model = Design::find()->Where(['product_id' => $id])->one();

        if (!empty($model)) {
            $design_type = $model->design_type;

            $svg_image = $model['design_svg'];
            $skus = $designs = [];
            $base_url = Yii::$app->params['base_url'];
            $buttons = '';
            $svgSet = false;
            if ($design_type == 'alphabet') {

                $parent_id = $model->alphabet_parent_id;

                $childs = AlphabetsCaseType::find()->where(['parent_id' => $parent_id])->all();
                // $result = "<option value=''>-- Please select --</option>";
                $result = "";
                foreach ($childs as $child) {
                    $result .= '<option value="' . $child->id . '">' . $child->type . '</option>';
                }

                $alphabets_cases = AlphabetsCaseType::find()->where(['parent_id' => $parent_id])->all();
                $sub_title_id = $alphabets_cases[0]['id'];
                $alphabets = AlphabetsK3::find()->where(['title' => $parent_id, 'sub_title' => $sub_title_id])->all();
                $svg_image = $alphabets[0]['image'];
                $result2 = "";
                $svg_file = file_get_contents($base_url . '/web/uploads/' . $svg_image);
            } else if ($design_type == 'multiple') {

                $parent_id = $model->is_parent;
                $records_data = MultipleCase::find()->where(['case_type' => $parent_id])->all();
                $svg_image = $records_data[0]['svg_image'];
                $childs = MultipleCaseType::find()->where(['parent_id' => $parent_id])->all();
                //  $records = MultipleCase::find()->select('case_type')->distinct()->all();
                // $result = "<option value=''>-- Please select Title --</option>";
                $result = "";
                foreach ($childs as $child) {
                    $result .= '<option value="' . $child->id . '">' . $child->type . '</option>';
                }
                $record_s = MultipleCase::find()->where(['case_type' => $parent_id])->select('case_number')->distinct()->orderBy(['case_number' => SORT_ASC])->all();
                // $result2 = "<option value=''>-- Please select a number --</option>";
                $result2 = "";
                if (!empty($record_s)) {
                    foreach ($record_s as $record) {
                        $number = $record->case_number;
                        $result2 .= '<option value="' . $number . '">' . $number . '</option>';
                    }
                }
                $svg_file = file_get_contents($base_url . '/web/uploads/' . $svg_image);
            } else if ($design_type == 'sets') {

                $parent_id = $model->sets_parent_id;
                $records_data = SetsCase::find()->where(['sc_type' => $parent_id])->all();
                $childs = SetsCaseTypes::find()->where(['parent_id' => $parent_id])->all();
                if(!empty($records_data) ) {
                    $svg_file_new = '';
                    if($childs[0]->sub_type === 'single') {
                        $svgSet = true;
                        $svg_image = $records_data[0]['svg_image'];

                        $svg = file_get_contents($base_url . '/web/uploads/' . $svg_image);
                        $find_string = '<svg';
                        $position = strpos($svg, $find_string);
                        $svg_file_new = substr($svg, $position);
                    }
                    foreach ($records_data as $data) {

                        $skus[$data['sku']] = ['svg' => $svg_file_new];
                        $svg_file_new = '';
                    }
                }

                $result = "";
                $index = 1;
                foreach ($childs as $child) {
                    $index++;
                    $margin = $index%2 == 0 ? 'margin-right: 5px;' : 'margin-left: 5px;';
                    $margin = $index > 3 ? "$margin margin-top: 10px;" : $margin;
                    $active = $index == 2 ? 'active' : '';
                    $val = $child->id;
                    $ref_id = $child->sub_type === 'single' ? '' : $child->reference_id;
                    $result .= '<option value="' . $val . '" type="'.$child->sub_type.'" ref-id="'.$ref_id.'">' . $child->name . '</option>';
                    $svg = '';

                    $numbers = '';
                    $options = '';
                    switch ($child->sub_type) {
                        case "alphabetic":
                            $alphas = AlphabetsCaseType::find()->where(['parent_id' => $ref_id])->all();
                            foreach ($alphas as $alpha) {
                                $options .= '<option value="' . $alpha->id . '">' . $alpha->type . '</option>';
                            }
                            if(!$svgSet) {
                                $svgSet = true;
                                $sub_title_id = $alphas[0]['id'];
                                $alphabets = AlphabetsK3::find()->where(['title' => $ref_id, 'sub_title' => $sub_title_id])->all();
                                $svg_image = $alphabets[0]['image'];
                            }
                        break;

                        case "multiple":
                            if(!$svgSet) {
                                $svgSet = true;
                                $records_data = MultipleCase::find()->where(['case_type' => $ref_id])->all();
                                $svg_image = $records_data[0]['svg_image'];
                            }
                            $multis = MultipleCaseType::find()->where(['parent_id' => $ref_id])->all();
                            foreach ($multis as $multi) {
                                $options .= '<option value="' . $multi->id . '">' . $multi->type . '</option>';
                            }
                            $record_s = MultipleCase::find()->where(['case_type' => $ref_id])->select('case_number')->distinct()->orderBy(['case_number' => SORT_ASC])->all();
                            if (!empty($record_s)) {
                                foreach ($record_s as $record) {
                                    $number = $record->case_number;
                                    $numbers .= '<option value="' . $number . '">' . $number . '</option>';
                                }
                            }
                        break;
                    }

                    if($child->sub_type === 'single')
                        $svg = $skus[$val]['svg'];

                    $subtype = $child->sub_type;

                    $designs[] = ['id' => $val, 'type' => $subtype, 'designs' => $options, 'numbers' => $numbers];
                    $skus[$val] = ['type' => $child->sub_type, 'sku' => $child->type, 'name' => $child->name, 'svg' => $svg, 'preview' => $svg];
                    $buttons .= '<button style="'.$margin.'" data-ref="'.$ref_id.'" data-type="'.$child->sub_type.'" class="btn btn-default btn-sets '.$active.'" type="button" value="' . $val . '">' . $child->name . '</button>';
                }
                $result2 = 0;
                $svg_file = file_get_contents($base_url . '/web/uploads/' . $svg_image);
            } else {
                $result = 0;
                $result2 = 0;
                $svg_file = file_get_contents($base_url . '/web/uploads/designs/' . $svg_image);
            }

            $find_string = '<svg';
            $position = strpos($svg_file, $find_string);
            $svg_file_new = substr($svg_file, $position);
            $alphabet = $design_type == 'alphabet';
            $multiple = $design_type == 'multiple';
            $sets = $design_type == 'sets';

            $path = '/var/www/html/basic/web/svg_created_images/';
            $file = glob($path . '*');
            $countFile = 0;
            if ($file != false) {
                $countFile = count($file);
            }
            return json_encode(['svg' => $svg_file_new, 'mutliple' => $multiple, 'alphabet' => $alphabet, 'skus' => $skus, 'buttons' => $buttons, 'sets' => $sets, 'designs' => $designs, 'result' => $result, 'result2' => $result2, 'number' => $countFile]);
        } else {
            return json_encode(['svg' => 'no']);
        }
    }

    public function actionCreatesetssvg() { 

        $curent_time = time();
        $base_url = Yii::$app->params['base_url'];
        $ref = Yii::$app->request->post('use_ref');
        $ref_no = Yii::$app->request->post('ref_no');
        $data = Yii::$app->request->post('content');
        $result = [];
        $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
        $i = 0;

        $path = '/var/www/html/basic/web/svg_created_images/';
        $file_data = glob($path . '*');
        $ref_no = 32200;
        if ($file_data != false) {
            $count = count($file_data) + 1;//is_float((count($file_data) / 2)) ? (count($file_data) / 2) + .5 : (count($file_data) / 2) + 1;
            $ref_no += $count;
        } else {
            $ref_no += 1;
        }
        $notSaved = true;

        foreach($data as $set) {

            $filepath = getcwd() . "/testsvg.txt";
            $file = fopen($filepath, "a");
            fwrite($file, "\n [" . date("Y-m-d H:i:s A") . "] Create Sets SVG: " . time(). " -- ref no: " . $ref_no);
//            fwrite($file, " -- ref:" . $ref);
//            if ($ref === "false") {
//                $filename = ' svg_created_images/' . $ref_no.'_'.$alpha[$i] . '.jpg';
//                fwrite($file, " -- here-in-condition: " . $ref.$filename);
//            }
//            fwrite($file, " -- final no to save: " . json_encode($ref_no));

            $sku = $set['sku'];
            if ($sku !== 'null') {
                $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
                if (!empty($svg_sizes)) {
                    $width = $svg_sizes->width;
                    $height = $svg_sizes->height;
                } else {
                    $width = 1400;
                    $height = 1400;
                }
            } else {
                $width = 1400;
                $height = 1400;
            }

            $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $set['svg'];
            $imagick = new \Imagick();
            $imagick->readImageBlob($content);
            $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
            $imagick->setImageResolution(420, 420);
            /* bmp settings */

            $imagick->setImageFormat("jpg");
            header("Content-Type: image/jpeg");
            $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

            fwrite($file, "\n sets previous current time: " . $curent_time. " == current time: " . time());
            if ($curent_time !== time() && $notSaved) {
                $path = '/var/www/html/basic/web/svg_created_images/';
                $file_data = glob($path . '*');
                $ref_no = 32200;
                $count = count($file_data);
                if ($file_data != false) {
                    $count = count($file_data) + 1;//is_float((count($file_data) / 2)) ? (count($file_data) / 2) + .5 : (count($file_data) / 2) + 1;
                    $ref_no += $count;
                } else {
                    $ref_no += 1;
                    $count = ' -- sets else count: '.$ref_no;
                }
                
                fwrite($file, " -- sets times not equal $ref_no, $count, ".count($file_data));
                $filename = 'svg_created_images/' . $ref_no . '.jpg';
                $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';
                if (file_exists($filename) || file_exists($filenameSet)) {
                    $ref_no += 1;
                    $filename = 'svg_created_images/' . $ref_no . '.jpg';
                    $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';
                    if (file_exists($filename) || file_exists($filenameSet)) {
                        $ref_no += 1;
                    }
                    $filename = 'svg_created_images/' . $ref_no . '.jpg';
                    $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';
                    if (file_exists($filename) || file_exists($filenameSet)) {
                        $ref_no += 1;
                    }
                    $filename = 'svg_created_images/' . $ref_no . '.jpg';
                    $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';
                    if (file_exists($filename) || file_exists($filenameSet)) {
                        $ref_no += 1;
                    }
                    fwrite($file, " -- sets File Exists Final ref no. $ref_no ");
                }
                $refno = $ref_no.'_'.$alpha[$i];
                $saved = file_put_contents("svg_created_images/$refno.jpg", $imagick);
                $notSaved = false;
            } else {
                fwrite($file, " -- sets times equal: $ref_no");
                $refno = $ref_no.'_'.$alpha[$i];
                $saved = file_put_contents("svg_created_images/$refno.jpg", $imagick);
                $notSaved = false;
            }
            $i++;
            if ($saved) {
                fwrite($file, " -- sets Saved: " . json_encode($refno));
                $im = new \Imagick();
                $im->readImage("$base_url" . "/web/svg_created_images/$refno.jpg");                                   # <--------
                $im->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
                $numberColors = 256 * 256 * 256;
                $colorSpace = \Imagick::COLORSPACE_RGB;
                $treeDepth = 1;
                $dither = true;
                $im->quantizeImage($numberColors, $colorSpace, $treeDepth, $dither, true);
                //$im->resampleImage(300, 300, \imagick::FILTER_UNDEFINED, 1);
                $im->setImageFormat("bmp");
                header("Content-Type: image/bmp");
                file_put_contents("svg_created_images/$refno.bmp", $im);

                $img_name = $refno . '.bmp';
                $response = $this->Fileupload($img_name);
                $result[] = $response;
            }
        }
        return json_encode($result);
    }

    public function actionCreatenewsvg() { 
        $curent_time = time();
        $base_url = Yii::$app->params['base_url'];
        $ref = Yii::$app->request->post('use_ref');
        $ref_no = Yii::$app->request->post('ref_no');
        $filepath = getcwd() . "/testsvg.txt";
        $file = fopen($filepath, "a");
        fwrite($file, "\n [" . date("Y-m-d H:i:s A") . "] Create SVG: " . time(). " ref no: $ref_no -- ref: " . $ref);
//        if ($ref !== "false") {
//            fwrite($file, " -- here-in-condition -" . $ref);
//            $filename = 'svg_created_images/' . $ref_no . '.jpg';
//            if (file_exists($filename)) {
                fwrite($file, " -- exists");
                $path = '/var/www/html/basic/web/svg_created_images/';
                $file_data = glob($path . '*');
                $ref_no = 32200;
                if ($file_data != false) {
                    $count = count($file_data) + 1;//is_float((count($file_data) / 2)) ? (count($file_data) / 2) + .5 : (count($file_data) / 2) + 1;
                    $ref_no += $count;
                } else {
                    $ref_no += 1;
                }
//            } else {
//                fwrite($file, " -- else not exists");
//                $ref_no = Yii::$app->request->post('ref_no');
//            }
//        }
        fwrite($file, " -- final no to save: " . json_encode($ref_no));
//        if ($ref == "false") {
//            $path = '/var/www/html/basic/web/svg_created_images/';
//            $file = glob($path . '*');
//            $ref_no = 32200;
//            if ($file != false) {
//                $count = (count($file) / 2) + 1;
//                $ref_no += $count;
//            } else {
//                $ref_no += 1;
//            }
//        }

        $sku = Yii::$app->request->post('sku');
        if ($sku !== 'null') {
            $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
            if (!empty($svg_sizes)) {
                $width = $svg_sizes->width;
                $height = $svg_sizes->height;
            } else {
                $width = 1400;
                $height = 1400;
            }
        } else {
            $width = 1400;
            $height = 1400;
        }

        $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . Yii::$app->request->post('content');
        $imagick = new \Imagick();
        $imagick->readImageBlob($content);
        $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
        $imagick->setImageResolution(420, 420);
        /* bmp settings */

        $imagick->setImageFormat("jpg");
        header("Content-Type: image/jpeg");
        $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

        fwrite($file, "\n previous current time: " . $curent_time. " == current time: " . time());
        if ($curent_time === time()) {
            fwrite($file, " -- times equal $ref_no");
            $saved = file_put_contents("svg_created_images/$ref_no.jpg", $imagick);
        } else {
            fwrite($file, " -- times not equal $ref_no");
            $path = '/var/www/html/basic/web/svg_created_images/';
            $file_data = glob($path . '*');
            $ref_no = 32200;
            if ($file_data != false) {
                $count = count($file_data) + 1;//is_float((count($file_data) / 2)) ? (count($file_data) / 2) + .5 : (count($file_data) / 2) + 1;
                $ref_no += $count;
                fwrite($file, "\n count IN IF--". $count);
                fwrite($file, "\n ref_no IN IF--". $ref_no);
            } else {
                $ref_no += 1;
                fwrite($file, "\n ref_no IN ELSE--". $ref_no);
            }
            $filename = 'svg_created_images/' . $ref_no . '.jpg';
            $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';

            fwrite($file, "\n filename--". $filename."fileset---".$filenameSet);

            if (file_exists($filename) || file_exists($filenameSet)) {
                $ref_no += 1;
                $filename = 'svg_created_images/' . $ref_no . '.jpg';
                $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';

                fwrite($file, "\n filename1--". $filename."fileset1---".$filenameSet);

                if (file_exists($filename) || file_exists($filenameSet)) {
                    $ref_no += 1;
                }
                $filename = 'svg_created_images/' . $ref_no . '.jpg';
                $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';

                fwrite($file, "\n filename2--". $filename."fileset2---".$filenameSet);
                if (file_exists($filename) || file_exists($filenameSet)) {
                    $ref_no += 1;
                }
                $filename = 'svg_created_images/' . $ref_no . '.jpg';
                $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';

                fwrite($file, "\n filename3--". $filename."fileset3---".$filenameSet);

                if (file_exists($filename) || file_exists($filenameSet)) {
                    $ref_no += 1;
                }
                $filename = 'svg_created_images/' . $ref_no . '.jpg';
                $filenameSet = 'svg_created_images/' . $ref_no . '_A.jpg';

                fwrite($file, "\n filename4--". $filename."fileset4---".$filenameSet);

                if (file_exists($filename) || file_exists($filenameSet)) {
                    $ref_no += 1;
                }
                fwrite($file, " -- File Exists Final ref no. $ref_no ");
            }
            fwrite($file, " -- New $ref_no");
            $saved = file_put_contents("svg_created_images/$ref_no.jpg", $imagick);
        }
        if ($saved) {
            fwrite($file, " -- saved: " . json_encode($ref_no));
            $im = new \Imagick();
            $im->readImage("$base_url" . "/web/svg_created_images/$ref_no.jpg");                                   # <--------
            $im->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
            $numberColors = 256 * 256 * 256;
            $colorSpace = \Imagick::COLORSPACE_RGB;
            $treeDepth = 1;
            $dither = true;
            $im->quantizeImage($numberColors, $colorSpace, $treeDepth, $dither, true);
            //$im->resampleImage(300, 300, \imagick::FILTER_UNDEFINED, 1);
            $im->setImageFormat("bmp");
            header("Content-Type: image/bmp");
            file_put_contents("svg_created_images/$ref_no.bmp", $im);

            $img_name = $ref_no . '.bmp';
            $response = $this->Fileupload($img_name);
            return json_encode($response);
        }
    }

    protected function Fileupload($img_name) {
        $base_url = Yii::$app->params['base_url'];
        $img = $base_url . '/web/svg_created_images/' . $img_name;
        $path = $img;
        $fp = fopen($path, 'rb');
        //  $size = filesize($path);
        $token = Yii::$app->params['dropbox_token'];
        $cheaders = array("Authorization: Bearer $token",
            'Content-Type: application/octet-stream',
            'Dropbox-API-Arg: {"path":"/Production Files/' . $img_name . '", "mode":"add","autorename": true,"mute": false,"strict_conflict": false}');

        $file_pointer = "/var/www/html/basic/web/svg_created_images/$img_name";
        if (!unlink($file_pointer)) {
//            echo ("$file_pointer cannot be deleted due to an error");  
        }

        $ch = curl_init('https://content.dropboxapi.com/2/files/upload');
        curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
        curl_setopt($ch, CURLOPT_PUT, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        curl_setopt($ch, CURLOPT_INFILE, $fp);
//        curl_setopt($ch, CURLOPT_INFILESIZE, $size);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        fclose($fp);
        // fwrite($file, "ref no:- ". $ref_no .'Closeed');
        return $response;
    }

    public function actionSave() {

        $access_token = Yii::$app->request->get('access_token');
        echo $access_token;
    }

    public function actionChangeSvgImage() {

        $title = $_POST['title'];
        $number = $_POST['number'];
        $where = array(
            'case_number' => $number,
            'case_sub_type' => $title
        );
        $base_url = Yii::$app->params['base_url'];
        $model = MultipleCase::find()->Where($where)->one();
        if (!empty($model)) {
            $svg_file = file_get_contents($base_url . '/web/uploads/' . $model->svg_image);
            if (!empty($svg_file)) {
                $find_string = '<svg';
                $position = strpos($svg_file, $find_string);
                $svg_file_new = substr($svg_file, $position);
                return json_encode($svg_file_new);
            } else {
                $no_svg = '<div class="no_svg" style="min-height: 150px; text-align: center; font-size: 24px;padding-top: 50px;">No svg image..</div>';
                return json_encode($no_svg);
            }
        }
    }

    public function actionChangeAlphaSvg() {

        $base_url = Yii::$app->params['base_url'];
        $alpha_id = $_POST['value'];
        $Alphabets = AlphabetsK3::find()->where(['sub_title' => $alpha_id])->one();
        if (!empty($Alphabets)) {
            $svg_file = file_get_contents($base_url . '/web/uploads/' . $Alphabets->image);
            if (!empty($svg_file)) {
                $find_string = '<svg';
                $position = strpos($svg_file, $find_string);
                $svg_file_new = substr($svg_file, $position);
                return json_encode($svg_file_new);
            }
        } else {
            return json_encode("");
        }
    }

    public function actionChangeSetSvg() {

        $base_url = Yii::$app->params['base_url'];
        $sku = $_POST['value'];
        $sets = SetsCase::find()->where(['sku' => $sku])->one();
        if (!empty($sets)) {
            $svg_file = file_get_contents($base_url . '/web/uploads/' . $sets->svg_image);
            if (!empty($svg_file)) {
                $find_string = '<svg';
                $position = strpos($svg_file, $find_string);
                $svg_file_new = substr($svg_file, $position);
                return json_encode($svg_file_new);
            }
        } else {
            return json_encode("");
        }
    }

    public function actionGetChild() {
        $parent_id = $_POST['parent_id'];
        $child_arr = MultipleCaseType::find()->where(['parent_id' => $parent_id])->all();
        if (!empty($child_arr)) {
            $child_new_arr = array();
            foreach ($child_arr as $child) {
                $child_new_arr[$child->id] = $child->type;
            }
            return json_encode(['status' => 'success', 'child_arr' => $child_new_arr]);
        }
    }

    public function actionCreatesetsref() {

        $data = Yii::$app->request->post('content');
        $path = '/var/www/html/basic/web/svg_created_images/';
        $file = glob($path . '*');
        $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
        $i = 0;
        $ref_no = 32200;  
        if ($file != false) {
            $count = count($file) + 1;//is_float((count($file) / 2)) ? (count($file) / 2) + .5 : (count($file) / 2) + 1;
            $ref_no += $count;
        } else {
            $ref_no += 1;
        }
        $response = [];
        foreach($data as $set) {

            $sku = $set['sku'];
            $name = $set['name'];
            if ($sku !== 'null') {
                $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
                if (!empty($svg_sizes)) {
                    $width = $svg_sizes->width;
                    $height = $svg_sizes->height;
                } else {
                    $width = 1400;
                    $height = 1400;
                }
            } else {
                $width = 1400;
                $height = 1400;
            }

            $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $set['svg'];
            $imagick = new \Imagick();
            $imagick->readImageBlob($content);
            $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
            $imagick->setImageResolution(420, 420);
            /* bmp settings */

            $imagick->setImageFormat("jpg");
            header("Content-Type: image/jpeg");
            $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

            $imgBuff = $imagick->getimageblob();
            $imagick->clear();
            $image = base64_encode($imgBuff);

            
            $response[] = ['ref_no' => $ref_no."_".$alpha[$i], 'sku' => $sku, 'name' => $name, 'preview' => 'data:image/png;base64, '.$image];
            $i++;
        }

        return json_encode(['ref_no' => $ref_no, 'response' => $response]);
//        return json_encode($ref_no]);
    }

    public function actionCreateref() {
        $sku = Yii::$app->request->post('sku');
        if ($sku !== 'null') {
            $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
            if (!empty($svg_sizes)) {
                $width = $svg_sizes->width;
                $height = $svg_sizes->height;
            } else {
                $width = 1400;
                $height = 1400;
            }
        } else {
            $width = 1400;
            $height = 1400;
        }

        $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . Yii::$app->request->post('content');
        $imagick = new \Imagick();
        $imagick->readImageBlob($content);
        $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
        $imagick->setImageResolution(420, 420);
        /* bmp settings */

        $imagick->setImageFormat("jpg");
        header("Content-Type: image/jpeg");
        $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

        $imgBuff = $imagick->getimageblob();
        $imagick->clear();
        $image = base64_encode($imgBuff);

        $path = '/var/www/html/basic/web/svg_created_images/';
        $file = glob($path . '*');
        $ref_no = 32200;  
        if ($file != false) {
            $count = count($file) + 1;//is_float((count($file) / 2)) ? (count($file) / 2) + .5 : (count($file) / 2) + 1;
            $ref_no += $count;
        } else {
            $ref_no += 1;
        }

        return json_encode(['ref_no' => $ref_no, 'preview' => 'data:image/png;base64, '.$image]);
//        return json_encode($ref_no]);
    }

    public function actionCheckFonts() {
        $imagick = new \Imagick();
        $fonts = $imagick->queryfonts();
        echo'<pre>';
        print_r($fonts);
        die;
    }

    public function actionCheckColor() {
        $svg = '<svg version="1.1" viewBox="0 0 5000 5000" xmlns="http://www.w3.org/2000/svg">
	<title>DADEST_3</title>
	<path d="m1188.03 50.001c-88.9585.02788-177.922.45077-266.881.45957-5.732.00064-11.4639.7435-16.6739 1.10353-4.8418 19.7998-4.1212 205.443 1.3391 221.297h94.2567v487.834h-95.2931c-5.0259 20.0809-4.4416 206.156.6455 221.74h22.1254c146.894 0 293.79.1812 440.682-.1729 25.381-.0613 50.8283-1.5546 76.1201-3.8551 48.2348-4.3862 94.0236-18.8108 137.802-39.7825 66.0509-31.6397 121.851-77.4023 168.524-134.897 26.7385-32.9371 49.5618-68.692 65.495-108.725 28.4395-71.4539 39.5965-145.236 32.4529-222.633-6.6196-71.7176-28.1593-137.448-65.5746-197.685-27.7496-44.6752-63.0417-82.5439-102.84-115.913-82.9527-69.552-178.266-106.451-284.624-107.739-69.1805-.83721-138.368-1.05445-207.558-1.03284zm1131.64.22453c-111.106-.08619-235.19 1.07016-242.557 3.0994-4.4598 18.9551-3.5749 204.087 1.207 217.501 22.7296 4.06992 46.3847-1.68457 71.5773 3.75572-75.0676 163.229-149.231 324.492-224.008 487.091h-88.1496v217.589c17.3323 4.6203 403.558 4.2491 419.338-.6497.0977-71.3214.0667-143.247.0314-217.895h-74.3545c13.1133-35.634 25.0562-68.0881 37.1684-101h249.236c9.673 32.7778 19.2398 65.1956 29.0987 98.6038-26.0449 5.43765-50.5137-1.24838-73.5195 4.36145-3.9057 26.7884-2.5856 204.83 1.6604 218.682h415.142v-220.45h-79.4537c-89.865-237.651-179.045-473.494-267.744-708.062-9.6926-1.74321-88.2578-2.56223-174.674-2.6293zm882.802.05733c-81.1472.01346-162.296.20384-243.444.20349-5.0719 0-10.1445 1.07335-14.6856 1.586-3.8753 20.7827-3.1676 203.927 1.2053 220.15h93.4292c4.5852 21.4603 3.7809 473.197-1.1322 489.109h-93.3279c-3.9699 21.0951-3.3474 204.651.9069 221.103h20.0087c150.447-6e-4 300.895.1541 451.342-.1701 22.4199-.0482 44.8956-1.6607 67.2402-3.7471 50.0436-4.6719 97.5127-19.5194 142.673-41.917 57.7514-28.6428 107.792-67.9053 150.879-117.163 26.0192-29.7443 49.1492-61.4743 66.5793-97.0769 38.0505-77.7232 52.6969-160.025 45.1945-247.238-6.116-71.1046-26.1519-136.932-63.526-196.45-52.5541-83.6901-123.07-146.697-211.486-187.326-53.5401-24.6028-109.962-39.6961-168.421-40.2068-81.1411-.709-162.288-.87239-243.435-.85894zm213.442 211.008c52.1638-.12067 97.1023 19.4056 135.646 54.7807 31.7588 29.1469 57.0851 63.4608 73.9155 104.217 10.3531 25.0698 15.0342 51.0898 17.5208 78.1624 3.7946 41.3214-2.0877 80.9359-19.111 117.816-32.2455 69.8562-79.6055 124.219-153.776 147.721-12.3144 3.90234-25.4364 6.66-38.2534 6.98024-38.454.96138-76.9433.48402-115.418.45858-2.825-.00189-5.6488-.88082-9.4945-1.5219v-507.717c6.8523-.33069 12.6268-.83468 18.4036-.85033 30.1889-.07957 60.3774.02233 90.5663-.04681zm-2086.51.00478c15.3904.00383 30.7812.01854 46.1716.0019 52.1518-.05674 97.0589 19.5284 135.598 54.9125 32.2278 29.5891 57.7867 64.5183 74.5907 105.938 9.9504 24.5245 14.2522 50.0691 16.7091 76.5165 3.9005 42.003-2.2931 82.2853-19.8554 119.505-32.4832 68.8438-79.6104 122.857-153.264 145.859-12.8801 4.02229-26.6172 6.6475-40.0312 7.00227-37.2689.98751-74.5752.47652-111.867.43283-3.4057-.00386-6.81-.90876-11.1311-1.52583v-507.402c5.6192-.4096 11.2625-1.15651 16.9094-1.17803 15.3901-.05805 30.7803-.06497 46.1707-.06114zm715.101 19.4866c-3.9907 32.5327 7.4375 47.4626 41.3158 53.5368 4.2549-9.34911 8.2723-18.1774 13.0353-28.6443-22.3664-1.71078-43.938 1.03965-54.3511-24.8924zm-1173.42.10225c-2.47702 25.9274 5.19472 43.0764 22.1254 49.0978 24.5458 8.73139 49.6425 4.87104 75.6196 3.43092v-28.6663c-19.5779 0-37.1367-.12019-54.6927.03439-17.8095.15654-33.9509-3.05616-43.052-23.8969zm2040.63.13182c-2.6623 25.4611 5.032 42.8449 21.8927 48.9107 24.5433 8.83057 49.6616 4.85597 75.3199 3.56847v-28.7475c-18.9915 0-36.5383-.1198-54.0823.03346-17.8706.15526-34.1051-2.97651-43.1305-23.7651zm-1557.86 12.2704c-16.0439-.02034-32.1322.74653-48.1755 1.44077-1.5926.06912-3.1284 1.53918-4.5576 2.28728-3.533 19.2349-2.8202 425.198 3.2259 438.056v-19.4398c0-123.184-.0142-246.368.0387-369.552.0032-7.03824.5582-14.0757.8986-22.1112 27.1748 0 52.0217-.29986 76.8587.07645 30.8793.46829 59.7027 8.75165 85.319 26.9561 40.498 28.7803 70.7155 66.5033 90.0564 113.315 3.6862 8.92312 6.4529 18.2526 9.6443 27.3956 1.4436-.35678 2.8865-.71227 4.3302-1.06912-3.3861-14.0373-5.8418-28.4021-10.3312-42.0507-14.0778-42.8039-39.6899-77.6968-71.7222-107.8-21.3878-20.0998-45.9107-35.5078-74.1113-41.6982-20.2914-4.45388-40.8463-5.7808-61.4741-5.80702zm1995.51.9306c-2.6958-.07371-5.44 1.7396-7.8351 2.56337-3.8299 23.5847-2.6757 426.2 3.3671 437.964v-408.857c4.354-.90076 6.5945-1.75901 8.8389-1.76753 25.4713-.09651 50.9886-1.00798 76.3961.30955 13.9883.72525 28.37 3.55761 41.5771 8.37036 51.7862 18.8703 86.7291 58.1829 113.795 105.577 9.5165 16.6651 15.658 35.394 23.3406 53.1804 1.0825-.40116 2.1653-.80278 3.2471-1.20387-3.6667-14.6224-6.4244-29.5682-11.1699-43.8058-13.8445-41.5334-38.8988-75.3838-69.8973-104.744-23.1286-21.9071-49.6262-39.591-80.6978-43.6224-33.2952-4.31905-67.275-3.04177-100.963-3.96401zm-1006.16 1.44748c21.4781 62.6304 43.1867 125.933 65.5883 191.255-6.4166 1.58297-11.905 4.06249-17.4145 4.11407-35.5213.33259-71.0476.15591-106.572.0391-1.6555-.00585-3.3085-1.04319-7.2671-2.37698 22.2586-65.4317 44.0119-129.378 65.666-193.031zm-.664 103.376c-5.5895 19.2376-14.3647 36.2294-18.0471 54.9947 18.1568 5.89482 15.713-10.8539 22.8955-17.7402 1.5907 3.70275 2.6645 7.07451 4.407 10.0232 1.9128 3.23572 4.4427 6.08147 7.9902 10.8134.2289-15.1265-4.8459-31.5721-17.2456-58.0912zm-459.67 57.3794c-1.2426.17083-2.4847.34244-3.7272.51397 1.2421 4.32659 2.4851 8.65369 3.7272 12.9803zm0 13.4942v.4548c.0299.05661.0652.11263.0961.1691.003-.08567.0061-.17135.0092-.25702-.0351-.12221-.0701-.24454-.1053-.36688zm.0961.6239c-1.2841 35.2606-1.2606 70.6383-4.2001 105.75-3.8918 46.4903-16.496 91.0264-33.926 134.058-2.0079 4.95692-4.0627 9.89429-6.1948 15.0822 15.6017 2.66372 17.9233 2.24057 21.9203-11.0943 7.1524-23.8645 13.8169-47.9489 19.281-72.2791 12.2704-54.6328 13.4167-109.889 6.2447-165.379-.2784-2.15181-2.0106-4.10224-3.1251-6.13859zm2040.45-14.1182c-1.2426.16961-2.4846.33961-3.7272.50922 1.2422 4.32852 2.485 8.65651 3.7272 12.985zm0 13.4942v.4548c.0315.05963.0691.11822.1016.17772.0015-.08857.0023-.17707.0037-.26564-.0351-.12227-.0702-.24454-.1053-.36688zm.1016.63252c-.7168 44.538.8667 89.1334-7.4859 133.308-11.0139 58.2422-29.1924 113.497-60.0666 163.839-27.41 44.6928-59.4078 85.1481-98.7654 119.501-35.4885 30.9757-73.0993 58.5017-114.966 79.0109-70.0335 34.3079-144.663 50.2849-221.746 50.851-151.601 1.1133-303.216.282-454.824.3831-20.6837.0137-40.1731-2.5407-53.8311-22.8316-3.3112 26.5015 6.6445 43.1 28.7745 48.3928 7.9418 1.8999 16.4258 1.8789 24.6632 1.8841 151.017.1018 302.033-.2106 453.048.2675 39.2239.1246 77.8342-3.2572 116.241-11.5222 111.202-23.9291 203.661-81.6428 278.488-168.704 54.7523-63.7046 91.5237-137.744 107.654-222.313 10.5203-55.1546 13.1436-110.269 5.9381-165.916-.2786-2.15516-2.0067-4.11047-3.1232-6.15005zm-1682.2 224.288c-3.5098 10.4722-6.8046 20.3021-10.7921 32.1994 5.9639 0 9.5522 1.16534 11.4228-.19586 9.5494-6.95153 20.2639-5.53604 30.7924-5.54711 48.4795-.05152 96.9593-.16491 145.437.07834 11.865.05872 23.7233 1.37754 36.2799 2.16018-2.552-8.826-5.2272-18.078-8.2968-28.695zm636.802 81.1719c-1.2476.09261-2.4944.18545-3.742.27799v19.8918c-6e-4 55.1154.0013 110.23-.0018 165.345 0 4.8989.1452 9.8068-.0768 14.6953-1.0017 22.0858-10.1306 33.8838-30.8653 38.5491-7.9916 1.7982-16.3611 2.5049-24.5607 2.5146-122.53.1533-245.062.0028-367.593.1998-22.0965.0351-43.429-1.0742-58.9002-22.5842-2.4656 28.7197 8.9529 45.029 33.1538 49.2345 5.2082.9053 10.6146.7956 15.9305.7968 130.227.0392 260.454-.3012 390.678.2676 31.7688.1389 50.173-16.3034 50.0652-51.8056-.1905-63.0759.1115-126.153-.2346-189.228-.0517-9.39208-2.5082-18.7702-3.8529-28.1551zm-583.984 4.31088c-1.051.10563-2.1022.21021-3.1538.31524 0 6.62211 6e-4 13.2439 0 19.866 0 53.9075.1441 107.817-.1423 161.723-.0478 9.0738-1.525 18.2188-3.1075 27.1863-2.361 13.3812-10.264 22.011-23.2613 24.5083-9.2366 1.7748-18.6858 3.3105-28.0422 3.3268-124.346.2159-248.693.0505-373.04.2332-21.7246.0319-42.5578-1.4124-57.3267-22.8728-2.8306 28.9004 9.5844 46.2368 34.4385 49.7562 6.4091.9072 13.001.578 19.5091.5799 120.793.0281 241.587.0217 362.382.0192 11.2503 0 22.5115.2997 33.7486-.1118 25.4435-.9308 39.8741-15.3491 39.9813-41.317.2919-71.0577.0529-142.118-.1016-213.178-.0076-3.34593-1.2282-6.68974-1.8839-10.0338zm-490.735 7.78947c-27.0922 37.2782-54.2068 70.8539-87.0231 99.3821-35.537 30.8955-73.1347 58.4425-115.033 78.8822-70.6291 34.4561-145.827 50.2427-223.533 50.7364-149.81.9529-299.63.2036-449.446.3621-21.6886.0228-42.5247-1.3727-57.286-22.8258-2.81369 27.7875 7.80587 44.2626 30.9458 49.0004 7.4538 1.5262 15.3128 1.2636 22.986 1.2669 152.185.0646 304.368-.1719 456.552.2064 36.8333.0912 73.0427-3.2808 109.16-11.0026 124.674-26.6547 224.63-93.4049 303.168-196.339 11.469-15.0319 12.2756-30.0534 9.5092-49.6692z"></path>
	<path d="m4192.89 1582.79h-3437.07v-460.984h3437.07z"></path>
	<path d="m1255.13 1196.65c-14.2388 0-28.4776 1.913-42.7164 5.7351-14.2388 3.8247-26.9949 9.6256-38.2664 17.4082-11.2743 7.7827-20.396 17.752-27.3653 29.9021-6.972 12.1528-10.4569 26.4195-10.4569 42.804 0 44.7861 24.9179 73.0497 74.7535 84.7899l84.543 20.0714c13.0513 3.2769 19.578 9.2851 19.578 18.0227 0 4.6439-2.2248 8.3304-6.6744 11.0595-4.4496 2.7317-11.569 4.0965-21.3582 4.0965-18.6884 0-33.0019-2.7985-42.9386-8.3973-9.9393-5.5965-14.9069-12.3552-14.9069-20.2759v-8.1921c-7.7145-.5452-15.5733-.9547-23.5827-1.2289-8.0093-.2713-15.8709-.4098-23.5826-.4098-7.7145 0-15.5014.1385-23.3605.4098-7.862.2742-15.6488.6837-23.3605 1.2289v108.138c6.8218.5453 13.7188.955 20.6908 1.2289 6.9692.2714 14.0156.4098 21.135.4098 6.8218 0 13.7945-.1384 20.9139-.4098 7.1194-.2739 14.2388-.6836 21.3583-1.2289v-9.0118c9.194 4.3701 19.9478 7.9878 32.2594 10.8551 12.3087 2.8673 27.9572 4.3009 46.9432 4.3009 12.1614 0 25.4355-1.2287 39.8245-3.6865 14.3862-2.4577 27.8098-7.0994 40.2687-13.9271 12.459-6.8254 22.8409-16.3152 31.1478-28.4679 8.304-12.1502 12.4593-28.0589 12.4593-47.7203 0-8.7375-.9657-17.9539-2.893-27.649-1.93-9.6923-5.9346-18.9775-12.0139-27.8533-6.0822-8.8734-14.7589-16.9296-26.0303-24.167-11.2743-7.2347-26.2525-12.9031-44.9409-16.9992l-82.7627-18.4326c-5.3395-1.3646-8.8273-3.0718-10.4569-5.1199-1.6325-2.048-2.4466-4.1633-2.4466-6.3495 0-3.8223 2.0743-7.5088 6.2291-11.0596 4.1521-3.5483 12.4586-5.3243 24.9175-5.3243 13.349 0 23.8785 2.5264 31.5931 7.5774 7.7117 5.0537 11.5687 10.7194 11.5687 16.9994v4.9153c7.7117.5479 15.4986.9574 23.3605 1.2287 7.8591.2741 15.646.4091 23.3606.4091 7.7117 0 15.5732-.135 23.5826-.4091 8.0093-.2713 15.8691-.6808 23.5836-1.2287v-97.488c-6.8246-.5453-13.6467-.9549-20.4686-1.2289-6.8246-.2714-13.6468-.4099-20.4686-.4099-6.8246 0-13.571.1385-20.2455.4099-6.6744.274-13.4236.6836-20.2454 1.2289v9.0118c-7.417-4.3675-17.1314-8.054-29.1454-11.0596-12.014-3.0029-26.4752-4.5063-43.3839-4.5063zm1707.36 0c-14.2388 0-28.4776 1.913-42.7164 5.7351-14.2387 3.8247-26.995 9.6256-38.2664 17.4082-11.2742 7.7827-20.3959 17.752-27.3652 29.9021-6.9721 12.1528-10.457 26.4195-10.457 42.804 0 44.7861 24.9181 73.0497 74.7542 84.7899l84.543 20.0714c13.0513 3.2769 19.578 9.2851 19.578 18.0227 0 4.6439-2.2247 8.3304-6.6743 11.0595-4.4497 2.7317-11.569 4.0965-21.3583 4.0965-18.6884 0-33.002-2.7985-42.9386-8.3973-9.9393-5.5965-14.9059-12.3552-14.9059-20.2759v-8.1921c-7.7145-.5452-15.5742-.9547-23.5837-1.2289-8.0093-.2713-15.8708-.4098-23.5826-.4098-7.7146 0-15.5013.1385-23.3605.4098-7.862.2742-15.6489.6837-23.3607 1.2289v108.138c6.822.5453 13.7189.955 20.6909 1.2289 6.9691.2714 14.0165.4098 21.136.4098 6.8219 0 13.7935-.1384 20.9129-.4098 7.1193-.2739 14.2387-.6836 21.3582-1.2289v-9.0118c9.194 4.3701 19.9479 7.9878 32.2596 10.8551 12.3086 2.8673 27.9581 4.3009 46.9441 4.3009 12.1613 0 25.4345-1.2287 39.8235-3.6865 14.3862-2.4577 27.8108-7.0994 40.2699-13.9271 12.4588-6.8254 22.8397-16.3152 31.1465-28.4679 8.3041-12.1502 12.4594-28.0589 12.4594-47.7203 0-8.7375-.9647-17.9539-2.8919-27.649-1.9301-9.6923-5.9347-18.9775-12.014-27.8533-6.0822-8.8734-14.759-16.9296-26.0303-24.167-11.2743-7.2347-26.2536-12.9031-44.942-16.9992l-82.7627-18.4326c-5.3395-1.3646-8.8261-3.0718-10.4559-5.1199-1.6325-2.048-2.4477-4.1633-2.4477-6.3495 0-3.8223 2.0744-7.5088 6.2291-11.0596 4.1521-3.5483 12.4597-5.3243 24.9187-5.3243 13.3488 0 23.8775 2.5264 31.5919 7.5774 7.7119 5.0537 11.5687 10.7194 11.5687 16.9994v4.9153c7.7118.5479 15.4987.9574 23.3607 1.2287 7.859.2741 15.6459.4091 23.3605.4091 7.7117 0 15.5742-.135 23.5836-.4091 8.0093-.2713 15.8682-.6808 23.5827-1.2287v-97.488c-6.8246-.5453-13.6468-.9549-20.4687-1.2289-6.8245-.2714-13.6457-.4099-20.4674-.4099-6.8246 0-13.572.1385-20.2467.4099-6.6742.274-13.4235.6836-20.2453 1.2289v9.0118c-7.417-4.3675-17.1314-8.054-29.1455-11.0596-12.0139-3.0029-26.4751-4.5063-43.3838-4.5063zm-2128.31 6.5541c-.59513 6.2823-1.0401 12.4265-1.33488 18.4325-.29758 6.0086-.44531 12.1527-.44531 18.4326 0 6.2825.14773 12.4266.44531 18.4325.29478 6.0087.73975 12.1528 1.33488 18.4328h20.4676v151.147h-20.4676c-.59513 6.2825-1.0401 12.4267-1.33488 18.4327-.29758 6.0086-.44531 12.1527-.44531 18.4327 0 6.2824.14773 12.4266.44531 18.4325.29478 6.0085.73975 12.1529 1.33488 18.4327h282.551v-95.0309c-8.8993-.5452-17.7267-.955-26.4757-1.2288-8.7519-.2716-17.5754-.4091-26.4746-.4091-14.834 0-29.3682.4095-43.607 1.2288v18.8416h-57.4002v-36.4552h105.902c.5923-6.2799 1.0373-12.6288 1.3349-19.047.2948-6.4156.4453-12.9031.4453-19.4569 0-6.28-.1505-12.6978-.4453-19.2517-.2976-6.5538-.7426-13.1075-1.3349-19.6614h-105.902v-33.9977h55.1757v17.2038c8.0093.548 16.0187.9576 24.028 1.229 8.0093.2739 16.0187.4089 24.0279.4089 8.0093 0 16.0187-.135 24.028-.4089 8.0094-.2714 16.0187-.681 24.028-1.229v-91.3441zm593.595 0v109.777c7.7116.5479 15.1284.9573 22.2479 1.2288 7.1192.274 14.2387.4089 21.358.4089 7.1194 0 14.2388-.1349 21.3583-.4089 7.1193-.2715 14.5343-.6809 22.2488-1.2288v-36.0464h22.6931v151.147h-25.8081c-.5952 6.2824-1.0402 12.4267-1.335 18.4327-.2975 6.0086-.4453 12.1527-.4453 18.4326 0 6.2824.1478 12.4267.4453 18.4326.2948 6.0085.7398 12.1528 1.335 18.4327h159.741c.5923-6.2799 1.0373-12.4242 1.3347-18.4327.295-6.0059.4454-12.1502.4454-18.4326 0-6.2799-.1504-12.424-.4454-18.4326-.2974-6.006-.7424-12.1503-1.3347-18.4327h-25.8072v-151.147h22.693v36.0464c7.7118.5479 15.1284.9573 22.2479 1.2288 7.1193.274 14.2387.4089 21.3581.4089 7.1196 0 14.2389-.1349 21.3583-.4089 7.1194-.2715 14.5332-.6809 22.2478-1.2288v-109.777zm389.351 0l-82.7628 224.878h-24.028c-.5949 6.2824-1.0399 12.4266-1.3348 18.4327-.2976 6.0086-.4453 12.1527-.4453 18.4326 0 6.2824.1477 12.4266.4453 18.4326.2949 6.0084.7399 12.1528 1.3348 18.4326h151.732c.5923-5.4606 1.0372-10.9904 1.3349-16.5893.2948-5.5964.4453-11.1261.4453-16.5894 0-5.4606-.1505-10.8545-.4453-16.1794-.2977-5.325-.7426-10.7172-1.3349-16.1804h-18.243l5.3395-22.1191h65.8537l5.3395 22.1191h-18.2431c-.595 5.4632-1.04 10.8554-1.3348 16.1804-.2976 5.3249-.4453 10.7188-.4453 16.1794 0 5.4633.1477 10.993.4453 16.5894.2948 5.5989.7398 11.1287 1.3348 16.5893h154.847c.5924-6.2798 1.0374-12.4242 1.335-18.4326.2948-6.006.4452-12.1502.4452-18.4326 0-6.2799-.1504-12.424-.4452-18.4326-.2976-6.0061-.7426-12.1503-1.335-18.4327h-22.2477l-79.2035-224.878zm262.092 0c-.595 6.2823-1.04 12.4265-1.3348 18.4325-.2977 6.0086-.4453 12.1527-.4453 18.4326 0 6.2825.1476 12.4266.4453 18.4325.2948 6.0087.7398 12.1528 1.3348 18.4328h20.4675v151.147h-20.4675c-.595 6.2825-1.04 12.4267-1.3348 18.4327-.2977 6.0086-.4453 12.1527-.4453 18.4327 0 6.2824.1476 12.4266.4453 18.4325.2948 6.0085.7398 12.1529 1.3348 18.4327h174.425c21.0607 0 39.1563-2.4578 54.2851-7.3731 15.1286-4.9153 27.513-11.674 37.1547-20.2758 9.6391-8.602 16.7585-18.6374 21.3582-30.1065 4.5969-11.4693 6.8966-23.7577 6.8966-36.8653 0-9.5567-1.1124-17.9539-3.3372-25.1913-2.2249-7.2348-5.2665-13.5175-9.121-18.8424-3.8574-5.3251-8.3828-9.9659-13.572-13.9264-5.1922-3.9578-10.6065-7.4396-16.2409-10.4451 8.6016-6.006 15.2761-13.7223 20.0233-23.1435 4.7445-9.4211 7.1199-20.2758 7.1199-32.5642 0-10.1021-2.2251-20.0016-6.6746-29.6967-4.4497-9.6925-11.124-18.2281-20.0232-25.6012-8.8993-7.3729-20.1739-13.3125-33.8175-17.8182-13.6466-4.5058-29.5174-6.7585-47.6107-6.7585zm307.032 0c-.5952 6.2823-1.0401 12.4265-1.3349 18.4325-.2976 6.0086-.4442 12.1527-.4442 18.4326 0 6.2825.1466 12.4266.4442 18.4325.2948 6.0087.7397 12.1528 1.3349 18.4328h20.4686v151.147h-20.4686c-.5952 6.2825-1.0401 12.4267-1.3349 18.4327-.2976 6.0086-.4442 12.1527-.4442 18.4327 0 6.2824.1466 12.4266.4442 18.4325.2948 6.0085.7397 12.1529 1.3349 18.4327h266.533v-122.474c-7.7145-.5453-15.2041-.955-22.471-1.2289-7.2695-.2714-14.7591-.4099-22.471-.4099-7.7144 0-15.2788.1385-22.693.4099-7.417.2739-14.8335.6836-22.2478 1.2289v47.5149h-54.285v-149.919h25.3629c.5921-6.28 1.0373-12.424 1.3348-18.4327.2948-6.0059.4442-12.15.4442-18.4325 0-6.2799-.1494-12.4241-.4442-18.4327-.2975-6.0059-.7427-12.1502-1.3348-18.4325zm287.009 0c-.595 6.2823-1.0399 12.4265-1.3347 18.4325-.2976 6.0086-.4454 12.1527-.4454 18.4326 0 6.2825.1478 12.4266.4454 18.4325.2948 6.0087.7397 12.1528 1.3347 18.4328h20.4677v151.147h-20.4677c-.595 6.2825-1.0399 12.4267-1.3347 18.4327-.2976 6.0086-.4454 12.1527-.4454 18.4327 0 6.2824.1478 12.4266.4454 18.4325.2948 6.0085.7397 12.1529 1.3347 18.4327h149.063c.5923-6.2798 1.0373-12.4242 1.3348-18.4327.2948-6.0059.4454-12.1501.4454-18.4325 0-6.28-.1506-12.4241-.4454-18.4327-.2975-6.006-.7425-12.1502-1.3348-18.4327h-20.4686v-151.147h20.4686c.5923-6.28 1.0373-12.4241 1.3348-18.4328.2948-6.0059.4454-12.15.4454-18.4325 0-6.2799-.1506-12.424-.4454-18.4326-.2975-6.006-.7425-12.1502-1.3348-18.4325zm469.003 0c-.5951 6.2823-1.0401 12.4265-1.335 18.4325-.2975 6.0086-.4451 12.1527-.4451 18.4326 0 6.2825.1476 12.4266.4451 18.4325.2949 6.0087.7399 12.1528 1.335 18.4328h20.4686v151.147h-20.4686c-.5951 6.2825-1.0401 12.4267-1.335 18.4327-.2975 6.0086-.4451 12.1527-.4451 18.4327 0 6.2824.1476 12.4266.4451 18.4325.2949 6.0085.7399 12.1529 1.335 18.4327h144.613c.5923-6.2798 1.0373-12.4242 1.3349-18.4327.2949-6.0059.4442-12.1501.4442-18.4325 0-6.28-.1493-12.4241-.4442-18.4327-.2976-6.006-.7426-12.1502-1.3349-18.4327h-22.2487v-43.0093h80.9837v43.0093h-22.2488c-.5952 6.2825-1.0401 12.4267-1.3348 18.4327-.2978 6.0086-.4444 12.1527-.4444 18.4327 0 6.2824.1466 12.4266.4444 18.4325.2947 6.0085.7396 12.1529 1.3348 18.4327h144.168c.5922-6.2798 1.0373-12.4242 1.3349-18.4327.2949-6.0059.4453-12.1501.4453-18.4325 0-6.28-.1504-12.4241-.4453-18.4327-.2976-6.006-.7427-12.1502-1.3349-18.4327h-20.4676v-151.147h20.4676c.5922-6.28 1.0373-12.4241 1.3349-18.4328.2949-6.0059.4453-12.15.4453-18.4325 0-6.2799-.1504-12.424-.4453-18.4326-.2976-6.006-.7427-12.1502-1.3349-18.4325h-144.168c-.5952 6.2823-1.0401 12.4265-1.3348 18.4325-.2978 6.0086-.4444 12.1527-.4444 18.4326 0 6.2825.1466 12.4266.4444 18.4325.2947 6.0087.7396 12.1528 1.3348 18.4328h22.2488v32.3597h-80.9837v-32.3597h22.2487c.5923-6.28 1.0373-12.4241 1.3349-18.4328.2949-6.0059.4442-12.15.4442-18.4325 0-6.2799-.1493-12.424-.4442-18.4326-.2976-6.006-.7426-12.1502-1.3349-18.4325zm347.526 0c-.5951 6.2823-1.04 12.4265-1.3348 18.4325-.2976 6.0086-.4453 12.1527-.4453 18.4326 0 6.2825.1477 12.4266.4453 18.4325.2948 6.0087.7397 12.1528 1.3348 18.4328h20.4677v151.147h-20.4677c-.5951 6.2825-1.04 12.4267-1.3348 18.4327-.2976 6.0086-.4453 12.1527-.4453 18.4327 0 6.2824.1477 12.4266.4453 18.4325.2948 6.0085.7397 12.1529 1.3348 18.4327h282.551v-95.0309c-8.8993-.5452-17.7265-.955-26.4756-1.2288-8.7519-.2716-17.5754-.4091-26.4746-.4091-14.834 0-29.3682.4095-43.607 1.2288v18.8416h-57.4003v-36.4552h105.902c.5923-6.2799 1.0373-12.6288 1.3348-19.047.2948-6.4156.4454-12.9031.4454-19.4569 0-6.28-.1506-12.6978-.4454-19.2517-.2975-6.5538-.7425-13.1075-1.3348-19.6614h-105.902v-33.9977h55.1758v17.2038c8.0092.548 16.0187.9576 24.0279 1.229 8.0094.2739 16.0186.4089 24.028.4089 8.0093 0 16.0186-.135 24.028-.4089 8.0094-.2714 16.0187-.681 24.0281-1.229v-91.3441zm303.027 0c-.595 6.2823-1.04 12.4265-1.3348 18.4325-.2976 6.0086-.4444 12.1527-.4444 18.4326 0 6.2825.1468 12.4266.4444 18.4325.2948 6.0087.7398 12.1528 1.3348 18.4328h20.4686v151.147h-20.4686c-.595 6.2825-1.04 12.4267-1.3348 18.4327-.2976 6.0086-.4444 12.1527-.4444 18.4327 0 6.2824.1468 12.4266.4444 18.4325.2948 6.0085.7398 12.1529 1.3348 18.4327h165.082c31.1475 0 56.9553-5.1202 77.4233-15.3605 20.4683-10.2404 36.7093-23.0743 48.7234-38.5039 12.0139-15.4272 20.3924-31.9493 25.1396-49.5627 4.7444-17.6134 7.1198-33.7932 7.1198-48.5393 0-20.2067-3.412-39.2537-10.2338-57.141-6.8247-17.8848-16.984-33.4501-30.4803-46.6959-13.499-13.2433-30.1851-23.6884-50.0582-31.3354-19.876-7.6446-42.7168-11.4695-68.5245-11.4695zm-1593.01 72.5017h36.042c7.7119 0 13.1992 2.0481 16.464 6.1442 3.2621 4.0962 4.8942 8.3309 4.8942 12.6983 0 5.1894-1.7797 9.6253-5.3395 13.3119-3.5598 3.6865-8.8993 5.5298-16.0187 5.5298h-36.042zm-316.378 2.4576l19.5781 70.8628h-40.4909zm2037.98 2.0479h17.7988c8.0093 0 15.8682.9578 23.5828 2.8676 7.7117 1.9124 14.5338 5.4629 20.4685 10.6497 5.932 5.1893 10.7508 12.3576 14.4607 21.5047 3.707 9.1496 5.5627 21.0956 5.5627 35.8418 0 25.67-5.6379 44.3761-16.9092 56.1167-11.2743 11.7432-26.6975 17.6137-46.2759 17.6137h-18.6884zm-1721.6 103.223h43.1619c8.8992 0 15.5736 2.1865 20.0232 6.5539 4.4496 4.3703 6.6745 9.5591 6.6745 15.5652 0 6.2824-2.2249 11.6073-6.6745 15.9749-4.4496 4.3701-11.124 6.554-20.0232 6.554h-43.1619z" fill="#fff"></path>
	
	<text class="design-field" id="Date" x="2499.6067" y="2347.9165" font-family="ChunkFive" font-size="853.333px" text-anchor="middle">
		03.13.06
	</text>
	
	<text class="design-field" id="Name" x="2512.5537" y="2735.9941" fill="#000000" font-family="Blair ITC" font-size="280px" font-weight="300" text-anchor="middle">
		JOHNATHAN
	</text>
	
	<text class="design-field" id="Date-2" x="2504.2" y="3480.4436" font-family="ChunkFive" font-size="853.333px" text-anchor="middle">
		02.07.12
	</text>
	
	<text class="design-field" id="Name-2" x="2499.8809" y="3980.2388" fill="#000000" font-family="Blair ITC" font-size="280px" font-weight="300" text-anchor="middle">
		CCCCCCCCCCC
	</text>
	
	<text class="design-field" id="Date-3" x="2499.8267" y="4626.6528" font-family="ChunkFive" font-size="853.333px" text-anchor="middle">
		08.26.18
	</text>
	
	<text class="design-field" id="Name-3" x="2494.3135" y="5051.8872" font-family="Blair ITC" font-size="280px" font-weight="300" text-anchor="middle">
		GGGGGGGGGG
	</text>
	<defs>
		<style type="text/css">
			@import url(//db.onlinewebfonts.com/c/a9f291b96478e28bbf8b5c4075602456?family=ChunkFive);
			@import url(//db.onlinewebfonts.com/c/15990133848a9b6a5b4362092fbc127f?family=Blair+ITC);
		</style>
	</defs>
</svg>';
        $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $svg;       

        $content2 = '<div class="design_source">' . $content . '</div>';
      //  echo '<object  class="svg_image_table" type="image/svg+xml" data="' . Yii::$app->request->BaseUrl . '/uploads/test/1590650056_GPAEST_5.svg' . '"></object>';   
//die;
//        $imagick = new \Imagick();
//        $imagick->readImageBlob($content);
//        // $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
//        // $imagick->setImageResolution(420, 420);
//        /* bmp settings */
//
//        $imagick->setImageFormat("jpg");
//        header("Content-Type: image/jpeg");
//        // $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);
//        // $im->writeImage('output.bmp');
//        file_put_contents("bmp_images/" . time() . "testing_curve.bmp", $imagick);
        return $this->render('test');
    }

    public function actionCheckFile() {
        //  if ($ref !== "false") {
//        $filepath = getcwd() . "/testsvg.txt";
//        $file = fopen($filepath, "a");
//        fwrite($file, "hello");

        $filename = 'svg_created_images/13275.jpg';
        if (file_exists($filename)) {
            echo 'file exists';
        } else {
            echo 'file not exists';
        }
        //}
    }
    
       public function actionCheckColor2() {
        $base_url = Yii::$app->params['base_url'];
        $ref = 'false';
        $ref_no = '121212';
        $svg = '<svg version="1.1" viewBox="0 0 5000 5000" xmlns="http://www.w3.org/2000/svg">
	<title>DADEST_1</title>
	<path d="m549.522 462.953c-143.086.04335-286.18.70083-429.266.71452-9.21972.00099-18.4392 1.15594-26.8193 1.71569-7.78788 30.7834-6.6288 319.409 2.15386 344.059h151.608v758.453h-153.275c-8.08398 31.2205-7.14402 320.519 1.03831 344.748h35.5877c236.273 0 472.548.2817 708.819-.2689 40.8244-.0953 81.7552-2.417 122.436-5.9936 77.5837-6.8195 151.233-29.2458 221.648-61.8514 106.24-49.1914 195.992-120.34 271.064-209.729 43.0078-51.2084 79.718-106.798 105.346-169.038 45.7436-111.092 63.6892-225.804 52.1991-346.136-10.6475-111.502-45.2932-213.695-105.474-307.348-44.6342-69.4581-101.4-128.334-165.413-180.214-133.426-108.135-286.733-165.504-457.805-167.505-111.274-1.30165-222.559-1.6394-333.848-1.60579zm1820.2.34909c-178.71-.13401-378.294 1.66382-390.143 4.81875-7.1734 29.4702-5.7501 317.301 1.9414 338.156 36.5595 6.32765 74.6077-2.61906 115.129 5.83916-120.743 253.778-240.032 504.499-360.308 757.298h-141.785v338.294c27.8783 7.1834 649.106 6.6063 674.488-1.0101.1571-110.886.1073-222.711.0505-338.769h-119.596c21.0921-55.4014 40.3018-105.859 59.7837-157.028h400.885c15.5585 50.9609 30.9464 101.362 46.804 153.303-41.8922 8.4541-81.2492-1.9409-118.253 6.7809-6.2821 41.6489-4.1589 318.456 2.6707 339.993h667.739v-342.741h-127.798c-144.544-369.485-287.987-736.159-430.654-1100.85-15.5901-2.71024-141.959-3.9836-280.955-4.08787zm1419.95.08913c-130.522.02092-261.047.31692-391.569.31638-8.158 0-16.317 1.66877-23.6212 2.46581-6.2333 32.3116-5.0949 317.053 1.9386 342.276h150.277c7.3751 33.3651 6.0814 735.697-1.8211 760.435h-150.114c-6.3854 32.7973-5.3841 318.179 1.4587 343.757h32.1831c241.988-9e-4 483.977.2396 725.965-.2644 36.0615-.075 72.2126-2.5819 108.153-5.8258 80.493-7.2636 156.845-30.3475 229.483-65.1698 92.8907-44.532 173.379-105.575 242.682-182.157 41.8507-46.2445 79.0545-95.5763 107.09-150.929 61.2027-120.839 84.7607-248.796 72.6935-384.39-9.8373-110.549-42.0643-212.893-102.179-305.428-84.531-130.116-197.952-228.075-340.167-291.242-86.1169-38.2508-176.87-61.7169-270.898-62.5109-130.512-1.10231-261.033-1.35633-391.555-1.33542zm343.312 328.062c83.9032-.1876 156.185 30.1706 218.181 85.1695 51.0827 45.3157 91.819 98.6649 118.89 162.03 16.6526 38.9769 24.1819 79.4312 28.1814 121.522 6.1035 64.2439-3.358 125.834-30.7393 183.173-51.8654 108.608-128.042 193.128-247.342 229.667-19.8074 6.0671-40.9135 10.3545-61.529 10.8524-61.8518 1.4947-123.76.7526-185.645.713-4.5439-.003-9.0859-1.3694-15.2715-2.3662v-789.366c11.0217-.51412 20.3096-1.29769 29.6014-1.32202 48.5575-.12372 97.1145.0347 145.672-.07279zm-3356.06.00743c24.7548.00596 49.5102.02883 74.2651.00297 83.884-.08822 156.115 30.3615 218.103 85.3745 51.837 46.0032 92.9475 100.309 119.976 164.705 16.0047 38.1291 22.924 77.8442 26.8758 118.963 6.2738 65.3036-3.6883 127.932-31.9366 185.799-52.2478 107.034-128.05 191.01-246.519 226.772-20.717 6.2536-42.8126 10.3351-64.3885 10.8867-59.9454 1.5353-119.951.7409-179.933.6729-5.47787-.006-10.9535-1.4129-17.9038-2.3722v-788.877c9.0382-.63682 18.1152-1.79806 27.198-1.83153 24.7544-.09024 49.5088-.10102 74.2636-.09506zm1150.21 30.2966c-6.4189 50.5797 11.963 73.7918 66.4548 83.2356 6.8438-14.5354 13.3056-28.261 20.9667-44.5344-35.9754-2.65982-70.6724 1.61637-87.4215-38.7011zm-1887.39.15896c-3.98419 40.3103 8.35547 66.9725 35.5877 76.3342 39.4809 13.575 79.8479 7.57318 121.631 5.33417v-44.5685c-31.4902 0-59.7329-.18686-87.971.05347-28.6458.24337-54.6085-4.75152-69.2473-37.1534zm3282.27.20496c-4.2824 39.5853 8.0937 66.6125 35.2133 76.0432 39.4769 13.7292 79.8787 7.54976 121.149 5.54803v-44.6948c-30.5471 0-58.7703-.18626-86.9892.05202-28.7441.24139-54.8565-4.6277-69.3735-36.9484zm-2505.76 19.0773c-25.8059-.03164-51.6833 1.16065-77.4884 2.24001-2.56149.10746-5.0317 2.39302-7.3305 3.55611-5.68275 29.9052-4.53618 661.071 5.18852 681.062v-30.2238c0-191.519-.02274-383.037.06244-574.556.0051-10.9426.89766-21.884 1.44525-34.3771 43.7095 0 83.6748-.46621 123.624.11887 49.668.72806 96.0293 13.6065 137.232 41.9096 65.1393 44.7458 113.743 103.395 144.852 176.175 5.9291 13.8731 10.3792 28.378 15.5123 42.5929 2.3221-.5547 4.6429-1.1074 6.9651-1.6622-5.4465-21.8243-9.3963-44.1578-16.6174-65.3778-22.6436-66.5488-63.8395-120.798-115.362-167.6-34.4016-31.2499-73.8456-55.2053-119.205-64.8297-32.6378-6.9246-65.6995-8.98762-98.8785-9.02839zm3209.7 1.44684c-4.3361-.11461-8.75 2.70462-12.6023 3.98536-6.1604 36.668-4.3038 662.629 5.4158 680.918v-635.665c7.003-1.40045 10.6069-2.73481 14.2169-2.74805 40.9695-.15005 82.0129-1.56715 122.88.48127 22.4996 1.12757 45.6318 5.53114 66.875 13.0137 83.2958 29.3384 139.5 90.4591 183.035 164.145 15.307 25.9099 25.1853 55.0284 37.5425 82.6815 1.7411-.6237 3.4826-1.2481 5.2227-1.8717-5.8977-22.7339-10.3334-45.9708-17.9662-68.1064-22.2684-64.5735-62.5673-117.202-112.427-162.85-37.2013-34.0598-79.8217-61.5535-129.799-67.8213-53.5538-6.71499-108.209-4.72916-162.394-6.163zm-1618.37 2.25043c34.5466 97.3737 69.4639 195.792 105.496 297.351-10.3209 2.4611-19.1488 6.3161-28.0106 6.3963-57.1344.5171-114.277.2424-171.417.0608-2.6629-.0091-5.3216-1.6219-11.6888-3.6956 35.8019-101.729 70.7913-201.148 105.621-300.113zm-1.068 160.722c-8.9905 29.9094-23.1051 56.3271-29.0281 85.5023 29.2045 9.1649 25.2736-16.8749 36.8265-27.5813 2.5585 5.7568 4.2857 10.999 7.0885 15.5835 3.0766 5.0307 7.1458 9.4551 12.8519 16.812.3681-23.5177-7.7945-49.0863-27.7388-90.3165zm-739.36 89.2099c-1.9987.2656-3.9965.5324-5.9951.7991 1.9979 6.7267 3.9971 13.4542 5.9951 20.1809zm0 20.98v.7071c.0481.088.1048.1751.1545.2629.005-.1332.0098-.2664.0149-.3996-.0565-.19-.1129-.3802-.1694-.5704zm.1545.97c-2.0655 54.821-2.0275 109.824-6.7557 164.414-6.2597 72.2802-26.533 141.522-54.5684 208.425-3.2297 7.7067-6.5347 15.383-9.9642 23.4488 25.0947 4.1414 28.8289 3.4835 35.2579-17.2487 11.5044-37.103 22.2239-74.5479 31.0127-112.375 19.7364-84.9396 21.5801-170.848 10.0443-257.12-.4478-3.3455-3.2339-6.3779-5.0266-9.5439zm3281.98-21.95c-1.9986.2637-3.9964.528-5.9951.7917 1.998 6.7297 3.9971 13.4586 5.9951 20.1883zm0 20.98v.7071c.0506.0927.1111.1838.1634.2763.0024-.1377.0037-.2753.006-.413-.0565-.1901-.1129-.3802-.1694-.5704zm.1634.9834c-1.153 69.2448 1.394 138.579-12.0408 207.259-17.7154 90.5513-46.9547 176.458-96.6146 254.726-44.0878 69.4855-95.5549 132.383-158.86 185.793-57.0817 48.159-117.577 90.9546-184.917 122.841-112.646 53.3398-232.684 78.1798-356.669 79.06-243.844 1.7309-487.71.4384-731.565.5956-33.2689.0213-64.6168-3.9501-86.5851-35.4971-5.3258 41.2028 10.6875 67.009 46.2826 75.238 12.774 2.9539 26.4202 2.9212 39.6697 2.9293 242.904.1582 485.808-.3274 728.708.4159 63.0899.1937 125.193-5.0641 186.968-17.9141 178.863-37.2034 327.58-126.933 447.937-262.291 88.0669-99.0439 147.212-214.156 173.157-345.638 16.9214-85.7509 21.1408-171.439 9.5512-257.956-.4482-3.3507-3.2278-6.3907-5.0237-9.5617zm-2705.75 348.708c-5.6453 16.2815-10.9448 31.5644-17.3586 50.0616 9.5928 0 15.3644 1.8118 18.3731-.3045 15.3598-10.8078 32.5937-8.6071 49.5283-8.6243 77.9772-.0801 155.955-.2564 233.93.1218 19.0843.0913 38.1579 2.1417 58.3547 3.3585-4.1049-13.7221-8.4077-28.1065-13.3451-44.6131zm1024.27 126.201c-2.0068.1439-4.0121.2883-6.0188.4322v30.9264c-.0011 85.6901.0021 171.379-.003 257.068 0 7.6165.2336 15.247-.1234 22.8473-1.6113 34.3376-16.2947 52.6803-49.6456 59.9337-12.8541 2.7957-26.3162 3.8944-39.5048 3.9096-197.085.2383-394.172.0043-591.258.3105-35.5413.0547-69.8538-1.6701-94.7385-35.1123-3.9659 44.6515 14.4003 70.0081 53.3265 76.5466 8.3771 1.4075 17.0731 1.2369 25.6236 1.2388 209.464.0609 418.93-.4682 628.389.416 51.0988.216 80.7011-25.3474 80.5277-80.544-.3063-98.0664.1794-196.135-.3773-294.199-.0832-14.6022-4.0343-29.1827-6.1973-43.7738zm-939.313 6.7022c-1.6904.1643-3.3813.3269-5.0728.4901 0 10.2957.0011 20.5908 0 30.8864 0 83.812.2318 167.627-.2287 251.436-.077 14.1074-2.4531 28.3255-4.9984 42.2676-3.7976 20.8042-16.5092 34.2212-37.4148 38.104-14.8567 2.7592-30.0553 5.1469-45.1048 5.1722-200.006.3357-400.012.0786-600.019.3625-34.943.0497-68.4524-2.1957-92.2075-35.561-4.553 44.9325 15.416 71.8859 55.3928 77.3577 10.3087 1.4105 20.9115.8986 31.3795.9016 194.291.0437 388.583.0338 582.876.0298 18.0957 0 36.2088.466 54.2832-.1738 40.9249-1.4471 64.1359-23.8638 64.3083-64.237.4695-110.476.0851-220.956-.1634-331.436-.0122-5.202-1.9756-10.4008-3.0302-15.5998zm-789.326 12.1106c-43.5766 57.9578-87.1894 110.159-139.973 154.513-57.1597 48.0343-117.634 90.8626-185.025 122.641-113.604 53.57-234.556 78.1141-359.544 78.8817-240.963 1.4815-481.942.3165-722.914.5629-34.8852.0355-68.3992-2.1341-92.1421-35.4881-4.52569 43.2024 12.5554 68.8167 49.7749 76.1828 11.9891 2.3728 24.6301 1.9645 36.9721 1.9696 244.783.1004 489.563-.2673 734.344.3209 59.2447.1419 117.486-5.1008 175.58-17.1061 200.532-41.4411 361.307-145.22 487.632-305.255 18.4475-23.3707 19.745-46.7252 15.2953-77.2226z"></path>
	<path d="m4959.57 2846.04h-4919.22v-716.708h4919.22z"></path>
	<path d="m754.971 2245.69c-20.3789 0-40.7578 2.9741-61.1367 8.9166-20.3789 5.9464-38.6358 14.9652-54.7678 27.0652-16.136 12.0999-29.1912 27.5996-39.1658 46.4899-9.97849 18.8943-14.9662 41.0753-14.9662 66.5489 0 69.6306 35.6631 113.573 106.989 131.826l121 31.2057c18.6794 5.0948 28.0205 14.436 28.0205 28.0206 0 7.22-3.18418 12.9516-9.55254 17.1946-6.36845 4.2471-16.5579 6.3689-30.5684 6.3689-26.7473 0-47.2332-4.3509-61.4547-13.0556-14.2254-8.701-21.3352-19.2089-21.3352-31.5237v-12.7365c-11.0412-.8477-22.2889-1.4844-33.7521-1.9105-11.4631-.4219-22.7148-.6372-33.752-.6372-11.0412 0-22.186.2153-33.4341.6372-11.2523.4261-22.397 1.0628-33.4342 1.9105v168.126c9.7636.8478 19.6347 1.4847 29.6132 1.9106 9.97454.4219 20.0595.6371 30.2489.6371 9.7636 0 19.7431-.2152 29.9326-.6371 10.1894-.4259 20.3789-1.0628 30.5684-1.9106v-14.0109c13.1588 6.7943 28.5499 12.4188 46.1705 16.8767 17.6166 4.4579 40.013 6.6868 67.1862 6.6868 17.4057 0 36.404-1.9104 56.9978-5.7315 20.5899-3.8211 39.8021-11.0377 57.6336-21.653 17.8317-10.6117 32.6904-25.3658 44.5794-44.2601 11.885-18.8903 17.8321-43.6242 17.8321-74.1925 0-13.5845-1.38215-27.9135-4.14049-42.9869-2.76226-15.069-8.49383-29.505-17.1947-43.3046-8.70479-13.7957-21.1232-26.321-37.2552-37.5732-16.136-11.2481-37.5731-20.0609-64.3204-26.4293l-118.452-28.658c-7.64207-2.1215-12.6338-4.7757-14.9662-7.9599-2.33643-3.1842-3.50168-6.473-3.50168-9.872 0-5.9426 2.96882-11.6741 8.91526-17.1946 5.94264-5.5168 17.8311-8.278 35.6626-8.278 19.1053 0 34.1756 3.9279 45.2168 11.7809 11.0372 7.8571 16.5573 16.6658 16.5573 26.4295v7.642c11.0373.8519 22.1821 1.4886 33.4342 1.9105 11.2482.426 22.393.6359 33.4342.6359 11.0372 0 22.2889-.2099 33.752-.6359 11.4632-.4219 22.7123-1.0586 33.7536-1.9105v-151.568c-9.76762-.8479-19.5316-1.4847-29.2952-1.9107-9.76752-.4219-19.5316-.6372-29.2952-.6372-9.76752 0-19.4232.2153-28.9758.6372-9.55264.426-19.2122 1.0628-28.9758 1.9107v14.011c-10.6153-6.7905-24.5189-12.522-41.7136-17.1948-17.1947-4.6689-37.892-7.0061-62.0921-7.0061zm2443.62 0c-20.3789 0-40.7578 2.9741-61.1368 8.9166-20.3788 5.9464-38.6358 14.9652-54.7677 27.0652-16.136 12.0999-29.1912 27.5996-39.1657 46.4899-9.9787 18.8943-14.9664 41.0753-14.9664 66.5489 0 69.6306 35.6633 113.573 106.99 131.826l121 31.2057c18.6794 5.0948 28.0204 14.436 28.0204 28.0206 0 7.22-3.184 12.9516-9.5524 17.1946-6.3684 4.2471-16.5578 6.3689-30.5684 6.3689-26.7473 0-47.2333-4.3509-61.4548-13.0556-14.2253-8.701-21.3337-19.2089-21.3337-31.5237v-12.7365c-11.0412-.8477-22.2902-1.4844-33.7535-1.9105-11.4632-.4219-22.7148-.6372-33.752-.6372-11.0413 0-22.186.2153-33.4341.6372-11.2524.4261-22.3972 1.0628-33.4344 1.9105v168.126c9.7637.8478 19.6347 1.4847 29.6133 1.9106 9.9744.4219 20.0607.6371 30.2503.6371 9.7637 0 19.7416-.2152 29.9311-.6371 10.1894-.4259 20.3788-1.0628 30.5683-1.9106v-14.0109c13.1588 6.7943 28.55 12.4188 46.1707 16.8767 17.6165 4.4579 40.0144 6.6868 67.1876 6.6868 17.4056 0 36.4024-1.9104 56.9964-5.7315 20.5899-3.8211 39.8035-11.0377 57.6352-21.653 17.8314-10.6117 32.6888-25.3658 44.5776-44.2601 11.8851-18.8903 17.8322-43.6242 17.8322-74.1925 0-13.5845-1.3807-27.9135-4.1389-42.9869-2.7624-15.069-8.494-29.505-17.1948-43.3046-8.7049-13.7957-21.1234-26.321-37.2552-37.5732-16.136-11.2481-37.5747-20.0609-64.322-26.4293l-118.452-28.658c-7.642-2.1215-12.6322-4.7757-14.9647-7.9599-2.3365-3.1842-3.5032-6.473-3.5032-9.872 0-5.9426 2.9689-11.6741 8.9152-17.1946 5.9426-5.5168 17.8326-8.278 35.6642-8.278 19.1052 0 34.174 3.9279 45.2152 11.7809 11.0374 7.8571 16.5573 16.6658 16.5573 26.4295v7.642c11.0374.8519 22.1821 1.4886 33.4344 1.9105 11.2481.426 22.3928.6359 33.4341.6359 11.0373 0 22.2903-.2099 33.7534-.6359 11.4632-.4219 22.711-1.0586 33.7522-1.9105v-151.568c-9.7675-.8479-19.5316-1.4847-29.2952-1.9107-9.7675-.4219-19.5302-.6372-29.2935-.6372-9.7676 0-19.4247.2153-28.9775.6372-9.5524.426-19.2121 1.0628-28.9757 1.9107v14.011c-10.6153-6.7905-24.5189-12.522-41.7137-17.1948-17.1946-4.6689-37.8918-7.0061-62.092-7.0061zm-3046.09 10.1899c-.85177 9.7673-1.48862 19.32-1.91052 28.6576-.4259 9.3418-.63734 18.8944-.63734 28.658 0 9.7676.21144 19.32.63734 28.6577.4219 9.3419 1.05875 18.8943 1.91052 28.658h29.2937v234.994h-29.2937c-.85177 9.7675-1.48862 19.3201-1.91052 28.6579-.4259 9.3418-.63734 18.8943-.63734 28.6579 0 9.7675.21144 19.3202.63734 28.6578.4219 9.3416 1.05875 18.8944 1.91052 28.6579h404.394v-147.748c-12.7368-.8477-25.3708-1.4847-37.8926-1.9105-12.5259-.4222-25.1543-.6359-37.8911-.6359-21.2307 0-42.0325.6367-62.4114 1.9104v29.2938h-82.1526v-56.6784h151.569c.84775-9.7635 1.48465-19.6344 1.91049-29.6131.42191-9.9745.63737-20.0609.63737-30.2503 0-9.7637-.21546-19.7417-.63737-29.9313-.42584-10.1894-1.06274-20.3788-1.91049-30.5683h-151.569v-52.8574h78.9688v26.7473c11.4632.8519 22.9264 1.4888 34.3895 1.9107 11.4631.4259 22.9263.6359 34.3894.6359s22.9263-.21 34.3894-.6359c11.4632-.4219 22.9264-1.0588 34.3895-1.9107v-142.016zm849.568 0v170.674c11.0372.8518 21.6522 1.4884 31.8417 1.9105 10.1893.426 20.3788.6358 30.5682.6358 10.1895 0 20.379-.2098 30.5685-.6358 10.1894-.4221 20.8018-1.0587 31.843-1.9105v-56.0426h32.479v234.994h-36.9372c-.8519 9.7675-1.4888 19.3201-1.9107 28.6579-.4258 9.3418-.6373 18.8943-.6373 28.6579 0 9.7675.2115 19.3202.6373 28.6578.4219 9.3416 1.0588 18.8944 1.9107 28.6579h228.625c.8478-9.7635 1.4846-19.3163 1.9103-28.6579.4221-9.3376.6375-18.8903.6375-28.6578 0-9.7636-.2154-19.3161-.6375-28.6579-.4257-9.3378-1.0625-18.8904-1.9103-28.6579h-36.9358v-234.994h32.4788v56.0426c11.0373.8518 21.6521 1.4884 31.8416 1.9105 10.1894.426 20.3788.6358 30.5683.6358 10.1896 0 20.379-.2098 30.5685-.6358 10.1895-.4221 20.8003-1.0587 31.8416-1.9105v-170.674zm557.248 0l-118.452 349.626h-34.3894c-.8516 9.7675-1.4885 19.3201-1.9104 28.6579-.426 9.3418-.6374 18.8943-.6374 28.6579 0 9.7675.2114 19.3202.6374 28.6578.4219 9.3416 1.0588 18.8944 1.9104 28.6579h217.162c.8478-8.4898 1.4845-17.0872 1.9105-25.7921.422-8.7009.6374-17.2981.6374-25.792 0-8.4899-.2154-16.8759-.6374-25.1547-.426-8.2791-1.0627-16.6625-1.9105-25.1563h-26.1099l7.6421-34.3894h94.2514l7.642 34.3894h-26.11c-.8515 8.4938-1.4884 16.8772-1.9104 25.1563-.4259 8.2788-.6373 16.6648-.6373 25.1547 0 8.4939.2114 17.0911.6373 25.792.422 8.7049 1.0589 17.3023 1.9104 25.7921h221.621c.8479-9.7635 1.4847-19.3163 1.9106-28.6579.422-9.3376.6373-18.8903.6373-28.6578 0-9.7636-.2153-19.3161-.6373-28.6579-.4259-9.3378-1.0627-18.8904-1.9106-28.6579h-31.8415l-113.358-349.626zm375.113 0c-.8517 9.7673-1.4885 19.32-1.9104 28.6576-.4261 9.3418-.6374 18.8944-.6374 28.658 0 9.7676.2113 19.32.6374 28.6577.4219 9.3419 1.0587 18.8943 1.9104 28.658h29.2936v234.994h-29.2936c-.8517 9.7675-1.4885 19.3201-1.9104 28.6579-.4261 9.3418-.6374 18.8943-.6374 28.6579 0 9.7675.2113 19.3202.6374 28.6578.4219 9.3416 1.0587 18.8944 1.9104 28.6579h249.641c30.1425 0 56.0415-3.8211 77.6941-11.4633 21.6525-7.642 39.3772-18.1499 53.1767-31.5234 13.7957-13.3738 23.9852-28.9763 30.5684-46.8078 6.5793-17.8316 9.8705-36.9368 9.8705-57.3158 0-14.8582-1.592-27.9135-4.7762-39.1658-3.1843-11.2482-7.5376-21.0162-13.0543-29.295-5.5207-8.2791-11.9975-15.4943-19.4245-21.6519-7.4312-6.1533-15.1802-11.5665-23.2444-16.2393 12.3109-9.3377 21.8636-21.3346 28.6579-35.9821 6.7904-14.6472 10.1901-31.5235 10.1901-50.6288 0-15.7061-3.1845-31.0972-9.5528-46.1705-6.3685-15.0693-15.9209-28.3399-28.6577-39.803-12.7369-11.4631-28.8733-20.6975-48.4005-27.7027-19.5312-7.0053-42.246-10.5077-68.1415-10.5077zm439.431 0c-.8518 9.7673-1.4886 19.32-1.9105 28.6576-.426 9.3418-.6358 18.8944-.6358 28.658 0 9.7676.2098 19.32.6358 28.6577.4219 9.3419 1.0587 18.8943 1.9105 28.658h29.2952v234.994h-29.2952c-.8518 9.7675-1.4886 19.3201-1.9105 28.6579-.426 9.3418-.6358 18.8943-.6358 28.6579 0 9.7675.2098 19.3202.6358 28.6578.4219 9.3416 1.0587 18.8944 1.9105 28.6579h381.469v-190.415c-11.0412-.8477-21.7606-1.4846-32.1611-1.9106-10.4043-.4219-21.1236-.6373-32.161-.6373-11.0411 0-21.8674.2154-32.4788.6373-10.6154.426-21.23 1.0629-31.8416 1.9106v73.8731h-77.694v-233.084h36.2999c.8476-9.7637 1.4847-19.3161 1.9105-28.658.4219-9.3377.6358-18.8901.6358-28.6577 0-9.7636-.2139-19.3162-.6358-28.658-.4258-9.3376-1.0629-18.8903-1.9105-28.6576zm410.774 0c-.8516 9.7673-1.4884 19.32-1.9103 28.6576-.4259 9.3418-.6374 18.8944-.6374 28.658 0 9.7676.2115 19.32.6374 28.6577.4219 9.3419 1.0587 18.8943 1.9103 28.658h29.2939v234.994h-29.2939c-.8516 9.7675-1.4884 19.3201-1.9103 28.6579-.4259 9.3418-.6374 18.8943-.6374 28.6579 0 9.7675.2115 19.3202.6374 28.6578.4219 9.3416 1.0587 18.8944 1.9103 28.6579h213.342c.8477-9.7635 1.4846-19.3163 1.9104-28.6579.4219-9.3376.6375-18.8903.6375-28.6578 0-9.7636-.2156-19.3161-.6375-28.6579-.4258-9.3378-1.0627-18.8904-1.9104-28.6579h-29.2952v-234.994h29.2952c.8477-9.7637 1.4846-19.3161 1.9104-28.658.4219-9.3377.6375-18.8901.6375-28.6577 0-9.7636-.2156-19.3162-.6375-28.658-.4258-9.3376-1.0627-18.8903-1.9104-28.6576zm671.248 0c-.8518 9.7673-1.4885 19.32-1.9106 28.6576-.4259 9.3418-.6372 18.8944-.6372 28.658 0 9.7676.2113 19.32.6372 28.6577.4221 9.3419 1.0588 18.8943 1.9106 28.658h29.2952v234.994h-29.2952c-.8518 9.7675-1.4885 19.3201-1.9106 28.6579-.4259 9.3418-.6372 18.8943-.6372 28.6579 0 9.7675.2113 19.3202.6372 28.6578.4221 9.3416 1.0588 18.8944 1.9106 28.6579h206.974c.8478-9.7635 1.4847-19.3163 1.9105-28.6579.4222-9.3376.6359-18.8903.6359-28.6578 0-9.7636-.2137-19.3161-.6359-28.6579-.4258-9.3378-1.0627-18.8904-1.9105-28.6579h-31.8429v-66.8683h115.906v66.8683h-31.8431c-.8518 9.7675-1.4885 19.3201-1.9104 28.6579-.4261 9.3418-.636 18.8943-.636 28.6579 0 9.7675.2099 19.3202.636 28.6578.4219 9.3416 1.0586 18.8944 1.9104 28.6579h206.337c.8477-9.7635 1.4846-19.3163 1.9106-28.6579.422-9.3376.6373-18.8903.6373-28.6578 0-9.7636-.2153-19.3161-.6373-28.6579-.426-9.3378-1.0629-18.8904-1.9106-28.6579h-29.2937v-234.994h29.2937c.8477-9.7637 1.4846-19.3161 1.9106-28.658.422-9.3377.6373-18.8901.6373-28.6577 0-9.7636-.2153-19.3162-.6373-28.658-.426-9.3376-1.0629-18.8903-1.9106-28.6576h-206.337c-.8518 9.7673-1.4885 19.32-1.9104 28.6576-.4261 9.3418-.636 18.8944-.636 28.658 0 9.7676.2099 19.32.636 28.6577.4219 9.3419 1.0586 18.8943 1.9104 28.658h31.8431v50.3109h-115.906v-50.3109h31.8429c.8478-9.7637 1.4847-19.3161 1.9105-28.658.4222-9.3377.6359-18.8901.6359-28.6577 0-9.7636-.2137-19.3162-.6359-28.658-.4258-9.3376-1.0627-18.8903-1.9105-28.6576zm497.387 0c-.8517 9.7673-1.4885 19.32-1.9105 28.6576-.4259 9.3418-.6373 18.8944-.6373 28.658 0 9.7676.2114 19.32.6373 28.6577.422 9.3419 1.0588 18.8943 1.9105 28.658h29.2937v234.994h-29.2937c-.8517 9.7675-1.4885 19.3201-1.9105 28.6579-.4259 9.3418-.6373 18.8943-.6373 28.6579 0 9.7675.2114 19.3202.6373 28.6578.422 9.3416 1.0588 18.8944 1.9105 28.6579h404.394v-147.748c-12.7368-.8477-25.3705-1.4847-37.8925-1.9105-12.5259-.4222-25.1542-.6359-37.891-.6359-21.2308 0-42.0326.6367-62.4115 1.9104v29.2938h-82.1526v-56.6784h151.569c.8477-9.7635 1.4846-19.6344 1.9105-29.6131.4219-9.9745.6373-20.0609.6373-30.2503 0-9.7637-.2154-19.7417-.6373-29.9313-.4259-10.1894-1.0628-20.3788-1.9105-30.5683h-151.569v-52.8574h78.9688v26.7473c11.4631.8519 22.9264 1.4888 34.3895 1.9107 11.4631.4259 22.9262.6359 34.3893.6359 11.4632 0 22.9263-.21 34.3896-.6359 11.4631-.4219 22.9263-1.0588 34.3895-1.9107v-142.016zm433.699 0c-.8516 9.7673-1.4885 19.32-1.9104 28.6576-.426 9.3418-.636 18.8944-.636 28.658 0 9.7676.21 19.32.636 28.6577.4219 9.3419 1.0588 18.8943 1.9104 28.658h29.2952v234.994h-29.2952c-.8516 9.7675-1.4885 19.3201-1.9104 28.6579-.426 9.3418-.636 18.8943-.636 28.6579 0 9.7675.21 19.3202.636 28.6578.4219 9.3416 1.0588 18.8944 1.9104 28.6579h236.269c44.579 0 81.5157-7.9605 110.81-23.8815 29.2947-15.9211 52.5392-35.8744 69.7341-59.8635 17.1946-23.9851 29.1861-49.6727 35.9805-77.0569 6.7902-27.3842 10.1899-52.5395 10.1899-75.4658 0-31.4161-4.8833-61.0292-14.6468-88.8393-9.7676-27.8061-24.308-52.0061-43.6242-72.5998-19.32-20.5898-43.2016-36.8292-71.6445-48.7182-28.447-11.8854-61.1373-17.8321-98.074-17.8321zm-2279.96 112.721h51.5842c11.0374 0 18.891 3.1844 23.5636 9.5527 4.6689 6.3685 7.0048 12.9523 7.0048 19.7425 0 8.0682-2.5473 14.9649-7.6421 20.6966-5.0948 5.7314-12.7368 8.5973-22.9263 8.5973h-51.5842zm-452.808 3.821l28.0206 110.173h-57.9516zm2916.81 3.184h25.474c11.4631 0 22.711 1.489 33.7523 4.4583 11.0372 2.9733 20.8012 8.4933 29.295 16.5575 8.4901 8.0679 15.3868 19.2127 20.6965 33.4341 5.3056 14.2253 7.9615 32.7982 7.9615 55.7246 0 39.91-8.0691 68.9932-24.2009 87.2467-16.136 18.2575-38.2101 27.3847-66.2311 27.3847h-26.7473zm-2464 160.484h61.7743c12.7368 0 22.2894 3.3995 28.6578 10.1897 6.3684 6.7946 9.5526 14.8618 9.5526 24.1997 0 9.7675-3.1842 18.0463-9.5526 24.8367-6.3684 6.7944-15.921 10.1899-28.6578 10.1899h-61.7743z" fill="#fff"></path>
</svg>';
//        $ref = Yii::$app->request->post('use_ref');
//        $ref_no = Yii::$app->request->post('ref_no');

        if ($ref == "false") {
            $path = '/var/www/html/basic/web/svg_created_images/';
            $file = glob($path . '*');
            $ref_no = 32200;
            if ($file != false) {
                $count = count($file) + 1;//is_float((count($file) / 2)) ? (count($file) / 2) + .5 : (count($file) / 2) + 1;
                $ref_no += $count;
            } else {
                $ref_no += 1;
            }

            //  return json_encode($ref_no);
        }

        $sku = Yii::$app->request->post('sku');
        if ($sku !== 'null') {
            $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
            if (!empty($svg_sizes)) {
                $width = $svg_sizes->width;
                $height = $svg_sizes->height;
            } else {
                $width = 1400;
                $height = 1400;
            }
        } else {
            $width = 1400;
            $height = 1400;
        }

      //  $svg = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 198.43 198.43"><title>PT-K2</title><path d="M197.43,173.33a19.18,19.18,0,0,0-7.22-3.43,82.53,82.53,0,0,0-12.07-2.47c-3-.42-6.08-.8-9.13-1.12-2.26-.24-4.53-.41-6.8-.54-3.73-.21-7.45-.39-11.18-.53-3.15-.11-6.3-.14-9.46-.17-2.44,0-4.88,0-7.31,0a.8.8,0,0,0-.88.54,13.9,13.9,0,0,1-6,6.6,23.78,23.78,0,0,1-8.66,3,41.11,41.11,0,0,1-8.94.18,88.68,88.68,0,0,1-19.55-3.89c-3.59-1.09-7.13-2.32-10.71-3.46a44.44,44.44,0,0,0-7.28-1.69,12.26,12.26,0,0,0-4,0,5.35,5.35,0,0,0-3.7,2.36.86.86,0,0,1-.86.44l-5.1-.15c-3.31-.12-6.63-.2-9.94-.4s-6.5-.46-9.75-.74c-3-.26-6-.52-8.92-.89a133.84,133.84,0,0,1-20.26-3.76,32.45,32.45,0,0,1-6.6-2.49A5.58,5.58,0,0,1,1,159H1a9.65,9.65,0,0,0,1.1.69c1.15.57,2.29,1.19,3.48,1.65a44.49,44.49,0,0,0,8.25,2.22c3.5.63,7,1.22,10.55,1.65,3.83.46,7.69.76,11.54,1.05,3.2.23,6.41.34,9.61.5,6.22.31,12.45.32,18.67.28a1.25,1.25,0,0,0,1-.5,9,9,0,0,1,4.1-2.65,32.92,32.92,0,0,1,5.21-1.14,16.29,16.29,0,0,1,4.83.12,80.81,80.81,0,0,1,11.48,2.82c4.51,1.38,9,2.77,13.59,3.88a88.41,88.41,0,0,0,9.52,1.86,29.45,29.45,0,0,0,10.63-.27,12.38,12.38,0,0,0,6.65-3.7,13.4,13.4,0,0,0,2.27-3.7c.33-.8.32-.81,1.19-.78,3.48.1,7,.19,10.44.33q4.28.18,8.54.49c3.74.29,7.49.59,11.22,1a167.42,167.42,0,0,1,19.39,3.06,61.75,61.75,0,0,1,8.43,2.49,14.07,14.07,0,0,1,4.15,2.3,4.51,4.51,0,0,1,.53.69Z"/><path d="M68.54,162.81a3.87,3.87,0,0,1,.43-.55c.88-.78,1.74-1.59,2.67-2.31a13,13,0,0,1,3.41-1.6,27.26,27.26,0,0,1,12.46-1.53c1.5.14,3,.26,4.49.46a37.66,37.66,0,0,1,6.29,1.6c4.85,1.57,9.68,3.21,14.52,4.81a30,30,0,0,0,11.31,1.75,6.61,6.61,0,0,0,2.75-.75,3.09,3.09,0,0,0,.93-5,4.31,4.31,0,0,0-1.12-.82,16.22,16.22,0,0,0-5.57-1.65,36.48,36.48,0,0,0-10.48.47,7.49,7.49,0,0,0-2.83,1.06c-.33.22-.63.49-1,.82a2.33,2.33,0,0,1,.58-1.35,10.26,10.26,0,0,1,3.75-2.87,14.55,14.55,0,0,1,5.18-1.23,20,20,0,0,1,7.48.78,9.37,9.37,0,0,1,5.55,4.72,4,4,0,0,1-.39,4.75,11.21,11.21,0,0,1-6.43,4.17,18.16,18.16,0,0,1-6.53.26,65.53,65.53,0,0,1-13.33-3.18,110.24,110.24,0,0,0-14.18-3.92,64.08,64.08,0,0,0-8-1.09,35.78,35.78,0,0,0-5.67.06,11.85,11.85,0,0,0-4,1c-.74.34-1.41.81-2.11,1.22Z"/><path d="M99.24,158.68l0,0,0,.05Z"/><polygon points="57.91 186.06 30.06 185.58 57.91 185.1 57.91 186.06"/><polygon points="57.91 188.52 36.59 188.04 57.91 187.56 57.91 188.52"/><polygon points="57.91 190.8 43.99 190.44 57.91 190.08 57.91 190.8"/><polygon points="140.51 185.1 168.36 185.58 140.51 186.06 140.51 185.1"/><polygon points="140.51 187.56 161.84 188.04 140.51 188.52 140.51 187.56"/><polygon points="140.51 190.08 154.44 190.44 140.51 190.8 140.51 190.08"/><text transform="translate(60.72 192.14)" style="font-size:10.410264015197754px;fill:#231f20;font-family:NotoSerif-Bold, Noto Serif;font-weight:700">E<tspan x="6.8" y="0" style="letter-spacing:-0.019981031431703673em">S</tspan><tspan x="12.69" y="0" style="letter-spacing:-0.08977392995371086em">T</tspan><tspan x="18.55" y="0">. 08.04.2017</tspan></text><path d="M44.79,143.52a8.2,8.2,0,0,1-1.15-.4,4.27,4.27,0,0,1-1.6-1,3.05,3.05,0,0,0-2-1.21,4.17,4.17,0,0,1-3-3,11.07,11.07,0,0,1-.08-6.4,8.19,8.19,0,0,1,1.26-2.46Q52.3,109.89,66.49,90.75q23.82-32.19,47.62-64.39l.61-.85a2.14,2.14,0,0,0-.44-.11c-11.32,0-22.63,0-33.95.05a26.46,26.46,0,0,0-8.22,1.22,15.71,15.71,0,0,0-8.5,6.73,61.3,61.3,0,0,0-6.23,13.45,4,4,0,0,1-3.77,3,21.52,21.52,0,0,1-4.53-.28c-.69-.12-1.3-.79-1.94-1.21-.42-.27-.81-.72-1.26-.79A4.92,4.92,0,0,1,42,42q1.71-15.15,3.52-30.3c.21-1.79.63-3.62,2.46-4.48a8.17,8.17,0,0,1,3.34-.85q31.22-.06,62.44,0,23.73,0,47.48,0c2,0,3.85.58,4.91,2.49a15.73,15.73,0,0,1,.73,2.23,2.65,2.65,0,0,0,.59,1,4.62,4.62,0,0,1,1.24,3.19c0,.58,0,1.17,0,1.76a6.23,6.23,0,0,1-1.32,4.06q-16,21.68-32,43.39L92,123.52c-.16.23-.31.47-.56.83h1c11.25,0,22.51.06,33.76,0a76.87,76.87,0,0,0,10.5-.83,18.37,18.37,0,0,0,11.91-6.84,57,57,0,0,0,6-9.4c.88-1.66,1.72-3.33,2.48-5a5.21,5.21,0,0,1,4.64-3.48,27.92,27.92,0,0,1,5.33.22,4.15,4.15,0,0,1,3.55,3.53,4.29,4.29,0,0,0,1.09,2.29,7,7,0,0,1,1,2.18v.36a6.37,6.37,0,0,0-.2.75q-1.84,11-3.69,22c-.6,3.55-1.2,7.1-1.86,10.64a3.08,3.08,0,0,1-2.44,2.47,7.79,7.79,0,0,0-1,.37ZM119,22c-.28.4-.42.61-.58.82L73.15,84Q56,107.14,38.93,130.29a2.51,2.51,0,0,0-.62,1c-.15,1.71-.28,3.42-.29,5.14a3.78,3.78,0,0,0,.6,1.8c.84,1.44,2.31,1.7,3.81,1.7h74q21.54,0,43.08,0a7,7,0,0,0,2.7-.61c1.28-.58,1.59-1.85,1.8-3.13,1.79-10.71,3.61-21.42,5.36-32.14a3.34,3.34,0,0,0-2.59-3.83,28.77,28.77,0,0,0-4.36-.28,4.17,4.17,0,0,0-4.13,2.67,75.56,75.56,0,0,1-6.93,12.51c-2.82,4-6.22,7.28-11.06,8.81A44.48,44.48,0,0,1,127,125.69c-13.78.06-27.56,0-41.33,0-.24,0-.49,0-.83-.06.25-.35.41-.59.58-.82Q106.19,96.59,127,68.35q18.78-25.53,37.54-51.06a5.74,5.74,0,0,0,1-2.46,15.84,15.84,0,0,0,0-3.51A4.74,4.74,0,0,0,165,9.43c-.84-1.44-2.28-1.71-3.8-1.71H90.1c-12.92,0-25.85,0-38.78,0a6.52,6.52,0,0,0-2.67.65c-1.38.66-1.6,2.07-1.76,3.43q-1,8-1.88,16c-.55,4.8-1.13,9.6-1.64,14.41a3.46,3.46,0,0,0,2.88,4,36.4,36.4,0,0,0,3.76.18c2.32,0,3.48-.84,4.26-3a65,65,0,0,1,6.3-13.5A15.64,15.64,0,0,1,69,23.25,31.26,31.26,0,0,1,79,22h40Z"/><path d="M165.78,103.75c-1.82,10.85-3.62,21.65-5.43,32.49H41.67c.1-1.63-.32-3.18.87-4.78q33.06-44.54,66-89.16L125.79,19c.13-.18.25-.37.43-.64a5.93,5.93,0,0,0-.6,0c-16.27,0-32.54,0-48.81,0a28.91,28.91,0,0,0-10.14,1.88,19,19,0,0,0-9.3,7.86A63,63,0,0,0,51,41.81c-.26.73-.58,1-1.37.95a21.64,21.64,0,0,0-2.28,0,2.3,2.3,0,0,1-.3-.1l3.61-31.15H161.91c0,1,0,2.06,0,3.08a1.84,1.84,0,0,1-.46.82l-40.7,55.29L78.15,128.51c-.18.24-.35.5-.64.91h1q24.36,0,48.71,0a53.5,53.5,0,0,0,11.95-1.31,23.52,23.52,0,0,0,13.77-8.81,75.2,75.2,0,0,0,8.63-14.76c.3-.65.61-1,1.36-.89s1.75,0,2.63,0A1.07,1.07,0,0,1,165.78,103.75Z"/></svg>';
        $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $svg;
        
        $imagick = new \Imagick();
       $read_image =  $imagick->readImage($base_url . '/web/uploads/1590650056_GPAEST_5.svg');
       
       echo '<pre>';print_r($read_image);die('sdsa');   
       
        $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
        $imagick->setImageResolution(420, 420);
        /* bmp settings */

        $imagick->setImageFormat("jpg");
        header("Content-Type: image/jpeg");
        $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

//        if (file_put_contents("svg_created_images/$ref_no.jpg", $imagick)) {
//            $im = new \Imagick();
//            $im->readImage("$base_url" . "/web/svg_created_images/$ref_no.jpg");                                   # <--------
//            $im->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
//            $numberColors = 256 * 256 * 256;
//            $colorSpace = \Imagick::COLORSPACE_RGB;
//            $treeDepth = 1;
//            $dither = true;
//            $im->quantizeImage($numberColors, $colorSpace, $treeDepth, $dither, true);
//            //$im->resampleImage(300, 300, \imagick::FILTER_UNDEFINED, 1);
//            $im->setImageFormat("bmp");
//            header("Content-Type: image/bmp");
//            file_put_contents("svg_created_images/$ref_no.bmp", $im);
//
//            $img_name = $ref_no . '.bmp';
//            echo $img_name;
//            die;
//            //  $response = $this->Fileupload($img_name);
//            //   return json_encode($response);
//        }
    }
    
    public function actionTesting() {

//        $sku = Yii::$app->request->post('sku');
//        if ($sku !== 'null') {
//            $svg_sizes = SvgSizes::find()->where(['product_sku' => $sku])->one();
//            if (!empty($svg_sizes)) {
//                $width = $svg_sizes->width;
//                $height = $svg_sizes->height;
//            } else {
//                $width = 1400;
//                $height = 1400;
//            }
//        } else {
            $width = 1400;
            $height = 1400;
//        }

        $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 4200 4200">
              <title>M3_A</title>
              <path d="m2077.7 143.44-1145 2676.2h-771.94v44.904h3883.6v-44.904h-740.64l-1153.5-2676.2h-72.413zm-39.009 357.31 999.41 2318.9h-312.79l-842.6-1950.1 155.98-368.84zm-211.67 484.1 657.33 1533h-1298l640.63-1533zm-690.76 1648.2h1398.2l78.541 186.59h-1556.9l80.163-186.59zm-975.52 889.83v44.909h393.5c-21.563 30.912-42.961 59.38-64.189 85.335-122.55 149.84-269.3 255.55-440.09 316.97v86.435h1409.4v-86.435c-321.88-63.416-510.9-197.5-567.08-402.31h2020.4c7.8524 32.093 11.797 58.628 11.797 79.568 0 130.64-65.023 220.98-194.99 270.87-44.558 19.247-150.4 36.545-317.51 51.868v86.435h1738v-86.435c-220.39-49.847-389.67-183.94-507.84-402.31h402.17v-44.909h-3883.6zm529.08 44.909h82.314c13.861 114.93 68.377 229.79 163.55 344.67h-557.06c120.67-92.921 224.42-207.82 311.19-344.67zm2345.4 0h344.72c84.137 151.47 166.28 266.39 246.42 344.67h-718.62c92.798-95.993 139.28-184.43 139.28-265.1 0-21.641-3.9439-48.176-11.799-79.568z"/>
              <text id="Name" class="design-field" max-char="9" x="2121" y="3480" font-variant-caps="normal" font-family="Bickham Script Pro Regular" font-size="1260px" text-anchor="middle" stroke="#fff" stroke-width="24px" paint-order="stroke">
                STEPHEN
              </text>
              <defs>
                <style type="text/css">
                  @import url(//db.onlinewebfonts.com/c/1b416ef14ebdc5a742d02d5ce16a7137?family=Bickham+Script+Pro+Regular);
                  @import url(//db.onlinewebfonts.com/c/1b416ef14ebdc5a742d02d5ce16a7137?family=Bickham+Script+Pro+Regular);
                  text#Name {text-transform: uppercase};
                </style>
              </defs>
            </svg>'; // . Yii::$app->request->post('content');
        $imagick = new \Imagick();
        $imagick->readImageBlob($content);
        $imagick->setImageUnits(\imagick::RESOLUTION_PIXELSPERINCH);
        $imagick->setImageResolution(420, 420);
        /* bmp settings */

        $imagick->setImageFormat("jpg");
        header("Content-Type: image/jpeg");
        $imagick->resizeImage($width, $height, \imagick::FILTER_LANCZOS, 1);

        $imgBuff = $imagick->getimageblob();
        $imagick->clear();
        $image = base64_encode($imgBuff);


        return $image;
//        return json_encode($ref_no]);
    }

}
