I searched a lot but can't find out a solution for this problem actually I am trying to resize a image using codeigniter img_library. For resizing I am using this code. I am converting a base 64 encoded image using this code
$imgdata=base64_decode($image);
$imagename=$t.$s.'.'.$type;
$url= $target_dir.$imagename;
file_put_contents($url,$imgdata);
$this->do_resize($url,$imagename);//calling the function to resize
public function do_resize($url,$imagename){
$source_path = $url;
$target_path = base_url(). '/assets/test_images/'.$imagename;
$config_manip = array(
'image_library' => 'gd2',
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => TRUE,
'create_thumb' => TRUE,
'thumb_marker' => '_thumb',
'width' => 150,
'height' => 150
);
$this->load->library('image_lib',$config_manip);
$this->image_lib->initialize($config_manip);
echo $this->image_lib->display_errors();
if (!$this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
$this->image_lib->clear();
}
and the error I am getting is this
Severity: Warning
Message: imagecreatefrompng(): gd-png: fatal libpng error: [1E][36][BB][37]: invalid chunk type
Filename: libraries/Image_lib.php
Line Number: 1463 A PHP Error was encountered
Severity: Warning
Message: imagecreatefrompng(): gd-png error: setjmp returns error condition
Filename: libraries/Image_lib.php
Line Number: 1463 A PHP Error was encountered
Severity: Warning
Message: imagecreatefrompng(): 'C:/xampps/htdocs/yallaexab/assets/images/14747161693.jpg' is not a valid PNG file
Filename: libraries/Image_lib.php
Line Number: 1463
imagecreatefrompng()... It looks as though it is expecting a PNG file and you gave it a JPEG. Is jpeg image type allowed in the configuration? It normally works it out by looking at the file extension and the first few bytes of the image file.