Codeigniter 4🔥 [26.- Manipulacion de imagenes]
En este tutorial vamos a aprender a manipular imagenes con las librerias de codeigniter 4.
Codigo en github.com: https://github.com/programadornovato/codeigniter4/commit/5da80f1a09daa3a31c364fd721ea63e5e7126315
//app/Controllers/Micontrolador.php <?php namespace App\Controllers; use CodeIgniter\Controller; use App\Models\UserModel; class Micontrolador extends BaseController { public function __construct(){ helper('form'); } public function guarda(){ $userModel=new UserModel($db); $request= \Config\Services::request(); $data=array( 'name'=>$request->getPostGet('name'), 'email'=>$request->getPostGet('email'), ); if($request->getPostGet('id')){ $data['id']=$request->getPostGet('id'); } if($userModel->save($data)===false){ var_dump($userModel->errors()); } if($request->getPostGet('id')){ $users=$userModel->find([$request->getPostGet('id')]); $users=array('users'=>$users); $estructura=view('estructura/header').view('estructura/formulario',$users); } else{ $users=$userModel->findAll(); $users=array('users'=>$users); $estructura=view('estructura/header').view('estructura/body',$users); } return $estructura; } public function editar(){ $userModel=new UserModel($db); $request= \Config\Services::request(); if($request->getPostGet('id')){ $id=$request->getPostGet('id'); }else{ $id=$request->uri->getSegment(3); } $users=$userModel->find([$id]); $users=array('users'=>$users); $estructura=view('estructura/header').view('estructura/formulario',$users); return $estructura; } public function borrar(){ $userModel=new UserModel($db); $request= \Config\Services::request(); if($request->getPostGet('id')){ $id=$request->getPostGet('id'); }else{ $id=$request->uri->getSegment(3); } $userModel->delete($id); $users=$userModel->findAll(); $users=array('users'=>$users); $estructura=view('estructura/header').view('estructura/body',$users); return $estructura; } public function formulario(){ $estructura=view('estructura/header').view('estructura/formulario'); return $estructura; } public function index() { $userModel=new UserModel($db); $datos=$userModel->paginate(10); $paginador=$userModel->pager; $paginador->setPath('ci4/'); $datos=array('users'=>$datos,'paginador'=>$paginador); $estructura=view('estructura/header').view('estructura/body',$datos); return $estructura; } public function imagenManipulacion(){ $info=\Config\Services::image() ->withFile('codeigniter.jpg') ->getFile() ->getProperties(true); $ancho=$info['width']; $alto=$info['height']; $imagen=\Config\Services::image() ->withFile('codeigniter.jpg') ->reorient() //->rotate(90) //->fit(250,250,'bottom-left') //->resize($ancho/2,$alto/2) ->crop(300,300,50,0) ->save('codeigniter_p.jpg'); return view('estructura/imagen'); } //-------------------------------------------------------------------- } //app/Views/estructura/imagen.php <div>Original</div> <img src="<?= base_url(); ?>codeigniter.jpg"/> <br><br><br> <div>Procesada</div> <img src="<?= base_url(); ?>codeigniter_p.jpg"/>
Guia oficial codeigniter: https://codeigniter4.github.io/userguide/libraries/images.html
#Codeigniter4 #php7 #backend #Codeigniter #php .
? Esta lista de reproducción: https://www.youtube.com/playlist?list=PLCTD_CpMeEKTFN5TDeOP-wP_hU0_9VoWg
.
Codigos en gdrive: https://drive.google.com/file/d/1awbG6jI40IO0N68fgjLUwNFpsTC3wIHj/view?usp=sharing .
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true .
? Facebook: https://facebook.com/ProgramadorNovatoOficial
? Twitter: https://twitter.com/programadornova
? Linkedin: https://www.linkedin.com/in/programadornovato/
? Instagram: https://www.instagram.com/programadornovato/