0

我正在开发一个尚未创建/开发的网站

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

但是带水印的副本质量低,而且它的大小比原始图像小很多

我没有看到任何降低质量的东西,也许这就是 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;
}

水印图片

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

0 回答 0