이전에 원격 주소에서 사진을 가져와 로컬에 저장할 수 있는 게시물이 있었습니다.
얼마 전에 매우 인기가 있었던 Moments 태그는 아래 세 가지 사용자 정의 기능을 사용하여 합성할 수 있습니다. 시토우. 개선이 필요한 부분이 있으면 직접 메시지를 남겨주세요!
/** * a.合成图片信息 复制一张图片的矩形区域到另外一张图片的矩形区域 * @param [type] $bg_image [目标图] * @param [type] $sub_image [被添加图] * @param [type] $add_x [目标图x坐标位置] * @param [type] $add_y [目标图y坐标位置] * @param [type] $add_w [目标图宽度区域] * @param [type] $add_h [目标图高度区域] * @param [type] $out_image [输出图路径] * @return [type] [description] */ function image_copy_image($bg_image,$sub_image,$add_x,$add_y,$add_w,$add_h,$out_image){ if($sub_image){ $bg_image_c = imagecreatefromstring(file_get_contents($bg_image)); $sub_image_c = imagecreatefromstring(file_get_contents($sub_image)); imagecopyresampled($bg_image_c, $sub_image_c, $add_x, $add_y, 0, 0, $add_w, $add_h, imagesx($sub_image_c), imagesy($sub_image_c)); //保存到out_image imagejpeg($bg_image_c, $out_image, 80); imagedestroy($sub_image_c); imagedestroy($bg_image_c); } } /** * b.生成文字图片并插入广告图中 * @param [type] $filename [背景路径] * @param [type] $text [文字内容] * @param [type] $font [文字大小] * @param [type] $size [文字画布的宽] * @param [type] $width_f [文字颜色] * @param [type] $red [红] * @param [type] $grn [绿] * @param [type] $blu [蓝] */ function create_text($filename,$text,$font,$size,$width_f,$red,$grn,$blu){ $rot = 0; // 旋转角度 $width = 0; //宽度 $height = 0; //高度 $offset_x = 0; //x偏移 $offset_y = 0; //y偏移 $bounds = array(); $text = autowrap($size, 0, $font, $text,$width_f); // 自动换行处理 /** [字体大小] [角度] [字体名称] [字符串] [预设宽度] */ // 确定边框高度. $bounds = ImageTTFBBox($size, $rot, $font, "W"); if ($rot < 0) { $font_height = abs($bounds[7]-$bounds[1]); } else if ($rot > 0) { $font_height = abs($bounds[1]-$bounds[7]); } else { $font_height = abs($bounds[7]-$bounds[1]); } // 确定边框高度. $bounds = ImageTTFBBox($size, $rot, $font, $text); if ($rot < 0) { $width = abs($bounds[4]-$bounds[0]); $height = abs($bounds[3]-$bounds[7]); $offset_y = $font_height; $offset_x = 0; } else if ($rot > 0) { $width = abs($bounds[2]-$bounds[6]); $height = abs($bounds[1]-$bounds[5]); $offset_y = abs($bounds[7]-$bounds[5])+$font_height; $offset_x = abs($bounds[0]-$bounds[6]); } else { $width = abs($bounds[4]-$bounds[6]); $height = abs($bounds[7]-$bounds[1]); $offset_y = $font_height; $offset_x = 0; } $bg = imagecreatetruecolor($width + 20,$height + 20); // 创建画布 $color=imagecolorallocatealpha($bg , 0 , 0 , 0 ,127);//拾取一个完全透明的颜色 imagealphablending($bg ,false);//关闭混合模式,以便透明颜色能覆盖原画布 imagefill($bg , 0 , 0, $color);//填充 imagesavealpha($bg ,true);//设置保存PNG时保留透明通道信息 $textImg = imagecolorallocate($bg, $red, $grn, $blu); // 创建白色 ImageTTFText($bg, $size, 0, 10, $size + 10, $textImg, $font, $text); imagepng($bg,$filename); } /** * 文字自动换行 * @param [type] $fontsize [字体大小] * @param [type] $angle [角度] * @param [type] $fontface [字体名称] * @param [type] $string [字符串] * @param [type] $width [预设宽度] */ function autowrap($fontsize, $angle, $fontface, $string, $width) { $content = ""; // 将字符串拆分成一个个单字 保存到数组 letter 中 preg_match_all("/./u", $string, $arr); $letter = $arr[0]; foreach ($letter as $l) { $teststr = $content." ".$l; $testbox = imagettfbbox($fontsize, $angle, $fontface, $teststr); // 判断拼接后的字符串是否超过预设的宽度 if (($testbox[2] > $width) && ($content !== "")) { $content .= PHP_EOL; } $content .= $l; } return $content; }

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

드림위버 CS6
시각적 웹 개발 도구

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구
