how to orient image using image intervation

Asked

Viewed 44 times

0

I need something to guide the image in the right way and then appear. I’m using Laser and image intervation

 <?php 

$img = Image::make("{{$file->caminho}}{{$file->nome}}")-orientate(); 
               ?>

<img src="{{ $img }}"/>

But I can’t

2 answers

0


for those who want to use image intervation and guide the photos, do the following

create a link to the image, in my case I am passing the ID.

a href="user/previewLarge/{$file->id }}">

create the route:

Route::get('user/preview/{fileId}', ['as' => 'files.preview', 'uses' => 'Filescontroller@preview'])->middleware('auth');

create the controller

public Function preview($fileId){

    $file = \App\Files::find($fileId);

    $finalPath = $file->caminho.'/'.$file->nome;

     $mime = mime_content_type($finalPath); //pega o tipo do arquivo e se for jpeg, fará o processo de orientação.

        if($mime == "image/jpeg")
        {

              return $image = Image::make($finalPath)
                    ->orientate()
                    ->resize(150, 200)
                    ->encode('data-url',0)->response();
        }
        else{

              return $image = Image::make($finalPath)->encode('data-url',0)->response();

        }

}

with me it worked, thank you all!

0

You’re trying to use syntax Blade within the php, and lack > to access a property or method.

<?php
     $img = Image::make($file->caminho . $file->nome)->orientate();
?>
  • what is the output of these two variables $file->caminho $file->nome ? checks if they generate a valid path to the image and if the image exists

  • if I use this = <img src="{{ $file->path}}{{$file->name}}"/>, I have access to the page. but it comes without the guidance I need

  • I would advise you to declare the variable in controller and return to the already oriented view, so it will be accessible

  • <img src="photo/{{$file->path . $file->name}}"/> (passing path) (controller) Route::get('/photo/{img}', Function() { $image = Image::make($img)->orientate(); Return $image->Response(); }); I tried this way it returns error 404

Browser other questions tagged

You are not signed in. Login or sign up in order to post.