ottaviane

ottaviane

Member Since 1 Year Ago

Experience Points
830
Total
Experience

4,170 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
830 XP
Apr
23
2 months ago
Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

now I edit the first message so it can be helping anyone.

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

ok now it works fine! thank you very mutch. resolved with

 $to=$temp_path.'.jpeg';
        syslog(LOG_NOTICE,"DisposizioniController: writing image to $to");
        $temp_path=$store->put($to,$im->getImageBlob());
Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

no it doesn't work! I cannot save

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

Ok. very nice. now it goes to before saving file as jpg. this is my new output:

Apr 23 14:54:33 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: file: /tmp/phpiDIw0P  tempfile: temp/No6WvJiXl4TYWjsneQlBjbMzUY4TVtTex3K0ooKE.pdf
Apr 23 14:54:33 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: new Imagick created.
Apr 23 14:54:33 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: Blob loaded
Apr 23 14:54:33 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: Image format setted
Apr 23 14:54:33 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: resolution setted

and so it is blocked. the line

$temp_path=$store->putFile('temp',$im);

crashes

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

ops! thi is the end of policy.xml

  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="none" pattern="PS" />
  <policy domain="coder" rights="none" pattern="EPS" />
  <policy domain="coder" rights="none" pattern="PDF" />
  <policy domain="coder" rights="none" pattern="XPS" />
</policymap>

i changed to

  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="none" pattern="PS" />
  <policy domain="coder" rights="none" pattern="EPS" />
  <policy domain="coder" rights="read|write" pattern="PDF" />
  <policy domain="coder" rights="none" pattern="XPS" />
</policymap>

I need to restart apache?

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

but when it does

$im->readImageBlob(Storage::disk('dispos')->get($temp_path));

it crashes

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

Yes! it returns the pdf file content !

%PDF-1.4
%äüöß
2 0 obj
<</Length 3 0 R/Filter/FlateDecode>>
stream
x��[K�ܸ��ϯ�y������F��W�������)�M�x�ė���^�W����"Y�,���J�W%��b��a��ݿ�y��Y��C�������Ow��a���k�_�v����vk��C�>�u��5L!N�~>����;����˧�����-���)R[>��s���T_���gKZ2��%��8�=�����!.y;�+hh����?��Z���4?diA��,-�d�Y\Ne>��S��P�t�,o||>�S.�j~9�g��J��L2!��9�F��z�F��j�O�����\�t^ʹ��r:�x2��SI�>0ҵ�������c�n�C�m�|(=����Å��q,�a�ֆp�_L'
␲'տ��P���,!��
E��8 �3��$��9���j=_"=��.�\[��R⋛���Nq��t��/�EOU#�����#��>��|��3����/t�����>K?�����ᲴW�n����]iʛJ_�!%�L����=���R���w�7�`*�̞�����^Ц���ή�yh���~0X���q���e�klz��Y���m�;ߧ�L~���~���k{?�t���}=͛�k�R�]N��r��{����g�VUb�Ž^�Qm�^�����9˭��a�������S���?�P�F�$��.�jm�>�Y���W�z�х�t�7ߡ8�g�H�����6��6�HD�����9P4�ڮ����.�s��۵�y}�oS��n����!���Z݄��z΄�3c�"˥���拎��G��������������ޒ]��5f��%�>�/ڵx�^��%����3��AO���~�Ϲ
�˾��@�u ߶3��������|B{�R�󋇄ҮV��p+RX}#�r��-��u��$��ld������DH>X�&j�<�������_�}��%���;���j�����F��m3$�T��|����wf���gΑ�ĸ�6%��e����C��ߨ�v�Bis����.L18-�8��X��e�������k�fӀ3�<$R����ғ������Roh�o�}V	��`���MR�3�}V��R�&��i�X{�`���M�u�…
Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

ok. I try this on your replay:

  public function get_temp_pdf(Request $req){    
        $store=Storage::disk('dispos');    
        $req->validate(['file' => 'required|mimes:pdf|max:2048']);
        $file = $req->file('file');
              
        $temp_path=$store->putFile('temp',$file);//$req->file->store('Disposizioni/temp');
        syslog(LOG_NOTICE,"DisposizioniController: file: $file  tempfile: $temp_path");
       
        $im = new Imagick;
        syslog(LOG_NOTICE,"DisposizioniController: new Imagick created.");
        $im->readImageBlob($store->get($temp_path));
        syslog(LOG_NOTICE,"DisposizioniController: Blob loaded");
        $im->setImageFormat('jpg');
        syslog(LOG_NOTICE,"DisposizioniController: Image format setted");
        $im->setResolution(300,300);
        syslog(LOG_NOTICE,"DisposizioniController: resolution setted");
        $temp_path=$store->putFile('temp',$im);
        syslog(LOG_NOTICE,"DisposizioniController: file jpg saved");
        return response()->json(['file_info' => $file_info , 'temp_path' => $temp_path],200);
    }

and the syslog output is this:


Apr 23 14:28:05 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: file: /tmp/php3ojNzY  tempfile: temp/qcqcXK4XuC1fDNaZY2p56NMEjeLW30f5jY0o9DWo.pdf
Apr 23 14:28:05 ottaviane-CELSIUS-W550power-L apache2: DisposizioniController: new Imagick created.

and it stops! it seems the problem is loading file....

Activity icon

Replied to Converting PDF To JPG With Imagick [RESOLVED]

thank you very mutch, yes it returns a simple string: imagick but I'm thinking ... the $temp_path variable passed to Imagick constructor may be relative? How can I verify it?

Activity icon

Started a new Conversation Converting PDF To JPG With Imagick [RESOLVED]

thanks to wingly this was resolved!!! it was solved modifying my Imagick policy.xml infact in the file /etc/Imagick-6/policy.xml we edited this: <policy domain="coder" rights="read|write" pattern="PDF" />

and this is the working code of my controller function:

 public function get_temp_pdf(Request $req){    
        $store=Storage::disk('dispos');    
        $req->validate(['file' => 'required|mimes:pdf|max:2048']);
        $file = $req->file('file');
        $file_info['orig_path']=$file->getClientOriginalName();//->getClientOriginalName(); 
        $file_info['orig_ext']=$file->getClientOriginalExtension();   
        $file_info['real_path']=$file->getRealPath();
        $file_info['size']=$file->getSize();
        $file_info['mime']=$file->getMimeType();       

        $temp_path=$store->putFile('temp',$file);

        $im = new Imagick;
        syslog(LOG_NOTICE,"DisposizioniController: new Imagick created.");

        $im->readImageBlob(Storage::disk('dispos')->get($temp_path));
        syslog(LOG_NOTICE,"DisposizioniController: Blob loaded");

        $im->setImageFormat('jpg');
        syslog(LOG_NOTICE,"DisposizioniController: Image format setted");

        $im->setResolution(300,300);
        syslog(LOG_NOTICE,"DisposizioniController: resolution setted");

        $to=$temp_path.'.jpeg'; //destination jpeg file
        syslog(LOG_NOTICE,"DisposizioniController: writing image to $to");

        $temp_path=$store->put($to,$im->getImageBlob());
        syslog(LOG_NOTICE,"DisposizioniController: file jpg saved");

        return response()->json(['file_info' => $file_info , 'temp_path' => $temp_path],200);
    }

Thanks to wingly very very nice.

This is the begin of the problem: Hi all, I have this function in my controller:

 public function get_temp_pdf(Request $req){    
        $store=Storage::disk('dispos');    
        $req->validate(['file' => 'required|mimes:pdf|max:2048']);
        $file = $req->file('file');     
        
        $temp_path=$store->putFile('temp',$file);
        syslog(LOG_NOTICE,"DisposizioniController: file: $file  tempfile: $temp_path");
        $im=new Imagick( $temp_path);
        syslog(LOG_NOTICE,"DisposizioniController: imagick created");
        $im->setImageFormat('jpg');
        $im->setResolution(300,300);
        $temp_path=$store->putFile('temp',$im);
        return response()->json(['file_info' => $file_info , 'temp_path' => $temp_path],200);
    }

When it trying to instantiate new Imagick it crashes. Why? I already installed "sudo apt install imagemagick php-imagick php-dev ghostscript" and in controller I use

use Imagick;

Can you help me please?

Mar
08
4 months ago
Activity icon

Replied to Croning A Route

ok

Activity icon

Replied to Croning A Route

ok. thank you very very mutch. You were very helpfull. this is my crontab:

#laravel cronjob
* * * * * cd /var/www/html/scadenziario && php artisan schedule:run >> /dev/null 2>&1

bye.

Activity icon

Replied to Croning A Route

or is better this?

protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
            scadenziarioController::getInfoPrefUser();
        })->everyMinute()
          ->withoutOverlapping();        
    }
Activity icon

Replied to Croning A Route

Ok, thank you.... so I have to do simply this:

in my kernel.php 

....
use App\Http\Controllers\scadenziarioController;
....

and

protected function schedule(Schedule $schedule)
    {
        scadenziarioController::getInfoPrefUser();
    }

is it correct?

Activity icon

Started a new Conversation Croning A Route

Hi all, I need to "cronify" a route... every day my systema must execute this:

Route::post('/getInfoPrefUser', '[email protected]');
of my web.php

So I'm following the method described in "Task scheduling" section of Laravel guide but I don't find how to invoke a route. Can you help me please?

Feb
25
4 months ago
Activity icon

Replied to Session Variables Not Saving / Persisting After Redirect

I made this:

public function data(Request $req){
        print_r($req->session()->all());

and I obtain for any reload a token that is different from before:

first reload:
    Array ( [_token] => ptQzilDr0q393hBOblwwxmn6Rrxl3GflHylNCyCT ) 
second reload:
    Array ( [_token] => RmWuoQYin8UceyxyhBmTrov1g8WQGcbM64BdNMQt ) 

and so on

Activity icon

Replied to Session Variables Not Saving / Persisting After Redirect

Hello all. I have same problem. I'm struggling with Session. This is my code:

class randomermesController extends Controller
{
    public $maxInterv=10;
    public $interventi;
   
    public function data(Request $req){
        echo("costruisco<br>");
        //dd(Session::all());
        if(Session::has('interventi')){
            $this->interventi = Session::get('interventi');
            echo("sessione esistente!<br>");
        }
        else{ 
            $this->interventi=new EventiClass($this->maxInterv);
            for($i=0;$i<$this->maxInterv;$i++){
                $this->interventi->add();            
            }
            Session::put('interventi',$this->interventi);
            Session::Save();
            echo("sessione nuova<br>");
        }

        for($i=0;$i<$this->maxInterv;$i++){
            echo($i." - ");
            echo($this->interventi->items[$i]->inizio->format("d/m/Y h:i:s"));
            echo(" - ");
            echo($this->interventi->items[$i]->fine->format("d/m/Y h:i:s"));
            echo("<br>");
        }
        return("ciao");
    }
}

class EventiClass
{
    public $total,$maxInterv,$items;
    function __construct($maxInterv){
        $this->total=0;
        $this->maxInterv=$maxInterv;
        $items=array();
    }
    function add(){
        $dest=-1;
        if($this->total<$this->maxInterv){
            $dest=$this->total;
        }else{
            for($i=0;$i<$this->maxInterv && $dest!== -1;$i++)
            {
                if($this->items[$i]->concluso) $dest=$i;
            }
        }
        if($dest>-1){
            $dataMin=new DateTime('NOW');
            if($this->total>0){
                for($i=0;$i<$this->total;$i++){
                    if($this->items[$i]->inizio > $dataMin) $dataMin=$this->items[$i]->inizio;
                }
            }
            $this->items[$dest]=new EventoClass($dest,$dataMin);
            if($this->total<$this->maxInterv) $this->total++;
        }
    }
}
class EventoClass
{
    public $inizio;
    public $fine;
    public $indice;
    function __construct($i,$dataMin){
        $this->indice=$i;
        $this->inizio=$dataMin;
        $add=rand(1,5);
        $this->inizio->modify('+'.$add.' min');
        $this->fine=new DateTime('NOW');
        $add2=$add+rand(2,40);
        $this->fine->modify('+'.$add2.' min');
        return $this;
    }
    function concluso(){
        $adesso= new DateTime('NOW');
        if($adesso > $this->fine) return true;
        return false;
    }
}

but session is resetted to every page reload! I also made modify in middleware like saurabhd says:

   * @var array
     */
    protected $middleware = [
        \App\Http\Middleware\TrustProxies::class,
        \App\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \Illuminate\Session\Middleware\StartSession::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

but it doesnt work! it's incredible! plese help me. bye.