在图片上添加水印后质量下降

时间:2013-05-12 22:29:43

标签: image codeigniter codeigniter-2

我正在开发一个我没有创建/开发的网站

无论如何,用户可以上传图像,当他们这样做时,有一个功能可以创建带有水印的图像副本

但带有水印的副本质量较低,而且尺寸远小于原始图像

我没有看到任何降低质量的事情,也许这是CI水印的工作方式?!

没有水印

http://img.akstube.ir/images/2013/05/DSC_0168_69_70_tonemapped.jpg

带水印

http://img.akstube.ir/images/2013/05/irwm_DSC_0168_69_70_tonemapped.jpg

这是函数

function ir_watermark($file,$name='',$rebuild=FALSE)
{

  $ci = &get_instance();


  $pathinfo = pathinfo($file);
  $filename = $pathinfo['basename'];
  $path = $pathinfo['dirname'];
  $new_image = $path . '/irwm_'. $filename;
  $path_to_img = base_url(str_replace(base_path(),'',$new_image));


  if ($rebuild == FALSE)
  if (file_exists($new_image))
  {


  if ($ci->uri->segment(1) == 'test')
  echo "<img src='{$path_to_img}' />";

  return $path_to_img;
  }


  $config['source_image']   = $file;
  $config['new_image']  = $new_image;
  $config['wm_type'] = 'overlay';
  $config['wm_overlay_path'] = base_path('/files/transparent_bar.png');
  $config['wm_font_path'] = base_path('application/assets/view/tahomabd.ttf');
  $config['wm_font_size']   = '8';
  $config['wm_font_color'] = 'ffffff';
  $config['wm_vrt_alignment'] = 'bottom';
  $config['wm_hor_alignment'] = 'left';
  $config['wm_hor_offset'] = '0';
  $config['wm_vrt_offset'] = '0';

  $ci->image_lib->initialize($config); 
  $ci->image_lib->watermark(); 

  $config['new_image'] = $config['new_image'];
  $config['source_image']   = $config['new_image'];

  $config['wm_hor_offset'] = '10';
  $config['wm_vrt_offset'] = '2';

  $config['wm_overlay_path'] = base_path('/files/akstube_logo6.png');
  $ci->image_lib->initialize($config); 
  $ci->image_lib->watermark(); 


  $config['wm_type'] = 'text';
  $config['wm_vrt_offset'] = '-3';

  $config['wm_text'] = 'Photo : ' . $name;
  $config['wm_text'] = strtoupper($config['wm_text']);

  $config['wm_hor_alignment'] = 'right';
  $config['wm_hor_offset'] = '-50%';

  $ci->image_lib->initialize($config); 
  $ci->image_lib->watermark(); 


  if ($ci->uri->segment(1) == 'test')
  echo "<img src='{$path_to_img}' />";

  return $path_to_img;
}

WATERMARK IMAGE

http://akstube.ir/files/akstube_logo6.png
http://akstube.ir//files/transparent_bar.png

0 个答案:

没有答案