如何解决为什么在图片中添加文字时会旋转 90 度?
我想在用手机相机拍摄的照片中间添加文字。当我添加文本时,我将图片旋转了 90 度。这可能是什么原因?
<?php
$img = imagecreatefromjpeg('B.jpg');
$font = '/var/www/html/watermarkke/Signika/static/Signika-Bold.ttf';
$fontsize = 128;
// img rgb renkleri ile text rengini bel R,G,B,alpha
$color = imagecolorallocatealpha($img,255,75);
$text="Why is the picture rotating?";
$width = imagesx($img);
$height = imagesy($img);
$text_size = imagettfbbox($fontsize,$font,$text);
$text_width = max($text_size[2],$text_size[4]) - min($text_size[0],$text_size[6]);
$text_height = max($text_size[5],$text_size[7]) - min($text_size[1],$text_size[3]);
// Center
$centerX = CEIL(($width - $text_width) / 2);
$centerY = CEIL(($height - $text_height) / 2);
if($centerX < 0) {$centerX = 0; }
if($centerY < 0) {$centerY = 0; }
// IMG SIZE ROTATE X Y COLOR FONT TEXT
imagettftext($img,$fontsize,$centerX,$centerY,$color,$text);
imagepng($img,'destination/B.jpg');
imagedestroy($img);
?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。