Maison > php教程 > php手册 > le corps du texte

PHP实现原比例生成缩略图的方法,php比例生成缩略图

WBOY
Libérer: 2016-06-13 08:46:35
original
997 Les gens l'ont consulté

PHP实现原比例生成缩略图的方法,php比例生成缩略图

本文实例讲述了PHP实现原比例生成缩略图的方法。分享给大家供大家参考,具体如下:

<&#63;php
$image = "jiequ.jpg"; // 原图
$imgstream = file_get_contents($image);
$im = imagecreatefromstring($imgstream);
$x = imagesx($im);//获取图片的宽
$y = imagesy($im);//获取图片的高
// 缩略后的大小
$xx = 140;
$yy = 200;
if($x>$y){
//图片宽大于高
  $sx = abs(($y-$x)/2);
  $sy = 0;
  $thumbw = $y;
  $thumbh = $y;
} else {
//图片高大于等于宽
  $sy = abs(($x-$y)/2.5);
  $sx = 0;
  $thumbw = $x;
  $thumbh = $x;
 }
if(function_exists("imagecreatetruecolor")) {
 $dim = imagecreatetruecolor($yy, $xx); // 创建目标图gd2
} else {
 $dim = imagecreate($yy, $xx); // 创建目标图gd1
}
imageCopyreSampled ($dim,$im,0,0,$sx,$sy,$yy,$xx,$thumbw,$thumbh);
header ("Content-type: image/jpeg");
imagejpeg ($dim, false, 100);
&#63;>

Copier après la connexion

更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP图形与图片操作技巧汇总》、《PHP基本语法入门教程》及《php常用函数与技巧总结》

希望本文所述对大家PHP程序设计有所帮助。

您可能感兴趣的文章:

  • php使用timthumb生成缩略图的方法
  • php上传图片生成缩略图(GD库)
  • PHP简单生成缩略图相册的方法
  • php动态生成缩略图并输出显示的方法
  • Thinkphp调用Image类生成缩略图的方法
  • php可生成缩略图的文件上传类实例
  • php实现根据url自动生成缩略图的方法
  • php实现上传图片生成缩略图示例
  • php 根据url自动生成缩略图并处理高并发问题
  • php利用GD库生成缩略图示例
  • 使用gd库实现php服务端图片裁剪和生成缩略图功能分享
Étiquettes associées:
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
Recommandations populaires
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!