请教:php图像识别,怎么讲拍的证件照片缩放到实际大小然后打印?

平步江湖 2018-11-11 03:21:38
需要把照片中的证件照片缩放到实际大小,打印出来,A4纸打印出来的照片跟实际大小一致,这个要怎么做?
...全文
111 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Joshua Burgin 2018-12-13
  • 打赏
  • 举报
回复
<?php // 重置图片文件大小 function resize_image($filename, $tmpname, $xmax, $ymax) {     $ext = explode(".", $filename);     $ext = $ext[count($ext)-1];     if($ext == "jpg" || $ext == "jpeg")         $im = imagecreatefromjpeg($tmpname);     elseif($ext == "png")         $im = imagecreatefrompng($tmpname);     elseif($ext == "gif")         $im = imagecreatefromgif($tmpname);     $x = imagesx($im);     $y = imagesy($im);     if($x <= $xmax && $y <= $ymax)         return $im;     if($x >= $y) {         $newx = $xmax;         $newy = $newx * $y / $x;     }     else {         $newy = $ymax;         $newx = $x / $y * $newy;     }     $im2 = imagecreatetruecolor($newx, $newy);     imagecopyresized($im2, $im, 0, 0, 0, 0, floor($newx), floor($newy), $x, $y);     return $im2; } ?>

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧