<commit_before><?php

namespace Crm\ImageBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;

class ImageController extends Controller
{

    /**
     * @Route("/upload-document/{type}", name="upload_document", options={"expose"=true})
     * @Template()
     */
    public function indexAction(Request $request, $type)
    {
        $session = $request->getSession();

        /**
         * Imagick
         */
        if ($request->getMethod() == 'POST'){
            $error = '';
            $time = time();
            $path='/var/www/upload/tmp/'.$time.'.jpg';
            $path2='/var/www/upload/tmp/origin-'.$time.'.jpg';
            $file = $request->files->get('file');
            if ($file->getSize() > 4194304 ){
                $error = array('error' => 'Размер файла должен быть меньше 4 Mb');
            }
            if ($error != ''){
                $error = array('data' => $error);
                $response = new JsonResponse($error);
                return $response;
            }else{
                $tmpPath = $file->getPathName();
                move_uploaded_file($tmpPath,$path);
                $image = new \Imagick($path);
                $image->setImageFormat('jpg');
                $image->stripImage();
                if ($type == 'signFile'){
                    $image->blackThresholdImage('#808080');
                    $image->whiteThresholdImage('#808080');
                }else{
                    $image->setImageColorSpace(\Imagick::COLORSPACE_GRAY);
                }

                $image->writeImage($path);
                $image->writeImage($path2);

                $session->set($type,$path);
                $session->set('origin-'.$type,$path2);

                $image->destroy();<commit_msg>update panel<commit_after><?php

namespace Crm\ImageBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;

class ImageController extends Controller
{

    /**
     * @Route("/upload-document/{type}", name="upload_document", options={"expose"=true})
     * @Template()
     */
    public function indexAction(Request $request, $type)
    {
        $session = $request->getSession();

        /**
         * Imagick
         */
        if ($request->getMethod() == 'POST'){
            $error = '';
            $time = time();
            $path='/var/www/upload/tmp/'.$time.'.jpg';
            $path2='/var/www/upload/tmp/origin-'.$time.'.jpg';
            $file = $request->files->get('file');
            if ($file->getSize() > 4194304 ){
                $error = array('error' => 'Размер файла должен быть меньше 4 Mb');
            }
            if ($error != ''){
                $error = array('data' => $error);
                $response = new JsonResponse($error);
                return $response;
            }else{
                $tmpPath = $file->getPathName();
                move_uploaded_file($tmpPath,$path);
                $image = new \Imagick($path);
                $image->setImageFormat('jpg');
                $image->stripImage();
                if ($type == 'signFile'){
                    $image->blackThresholdImage('#808080');
                    $image->whiteThresholdImage('#808080');
                    $image->setImageColorSpace(\Imagick::COLORSPACE_GRAY);
                }else{
                    $image->setImageColorSpace(\Imagick::COLORSPACE_GRAY);
                }

                $image->writeImage($path);
                $image->writeImage($path2);

                $session->set($type,$path);
                $session->set('origin-'.$type,$path2);

                $image->destroy();
{'fraction_non_alphanumeric': 0.1530373831775701, 'fraction_numerical': 0.01074766355140187, 'mean_word_length': 1.9958012596221133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2553549', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1144, 'n_words': 173}