imagecopyresized()压缩保存的图像是黑色的

WBOY
Libérer: 2016-08-18 09:16:28
original
2145 Les gens l'ont consulté

<code><?php move_uploaded_file($_FILES['upload']['tmp_name'],'x1.jpg');
$img='x1.jpg';
$thumbs=imagecreatetruecolor(500,500);
$imgs=getimagesize($img);
$width=500;
$height=500;
imagecopyresized($thumbs,$img,0,0,0,0,$width,$height,$img[0],$img[1]);
imagejpeg($thumbs,'xxxx.jpg');
?></code>
Copier après la connexion
Copier après la connexion

最后保存出的图像是黑色的。大小正常,就是一片漆黑,是什么原因呢?谢谢

而且,提示:Warning: imagecopyresized() expects parameter 2 to be resource, string given in F:phpstudyWWWreceive.php on line 10,哪里出问题了?

回复内容:

<code><?php move_uploaded_file($_FILES['upload']['tmp_name'],'x1.jpg');
$img='x1.jpg';
$thumbs=imagecreatetruecolor(500,500);
$imgs=getimagesize($img);
$width=500;
$height=500;
imagecopyresized($thumbs,$img,0,0,0,0,$width,$height,$img[0],$img[1]);
imagejpeg($thumbs,'xxxx.jpg');
?></code>
Copier après la connexion
Copier après la connexion

最后保存出的图像是黑色的。大小正常,就是一片漆黑,是什么原因呢?谢谢

而且,提示:Warning: imagecopyresized() expects parameter 2 to be resource, string given in F:phpstudyWWWreceive.php on line 10,哪里出问题了?

应该是要先构建一个图片,然后传给函数,然后保存为img吧?
报错信息已经说了参数不合法

Étiquettes associées:
php
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!