CodeIgniter Forums
how to custome width and height captcha - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how to custome width and height captcha (/showthread.php?tid=60621)



how to custome width and height captcha - El Forum - 05-13-2014

[eluser]Tống Kiện Phi[/eluser]
This is my function create captcha:
Code:
function captcha($config = array())
  {
      $conf = array(
        ‘width’ => 70,
        ‘height’ => 28
      );
      
      $conf = array_merge($conf, $config);
      
      $CI = & get_instance();
      $CI->load->helper(‘captcha’);
      $vals = array(
        ‘word’      => mt_rand(1000,9999),
        ‘img_path’    => ‘public/captcha/’,
        ‘img_url’    => $CI->config->item(‘base_url’) . ‘public/captcha/’,
        ‘expiration’  => 2,
        ‘img_width’    => $conf[‘width’],
        ‘img_height’  => $conf[‘height’]
      );
      $cap = create_captcha($vals);
      $CI->session->set_userdata(‘security_code’,$cap[‘word’]);
      return $cap;
  }
it’s display ok but some characters lost in image (Captcha1.PNG)
F5 many times it’s must display ok (Captcha2.PNG)


how to custome width and height captcha - El Forum - 05-16-2014

[eluser]InsiteFX[/eluser]
If the images are a different size then you would need to use the image lib and resize them.