Home > php教程 > php手册 > php缩放图片(根据宽高的等比例缩放)实例介绍

php缩放图片(根据宽高的等比例缩放)实例介绍

WBOY
Release: 2016-06-06 20:31:40
Original
1257 people have browsed it

设定宽高,不等比例缩放;设定宽度,等比例缩放;设定高度,等比例缩放;按比例,缩放至50%;缩放后直接输出到屏幕等等,具体使用方法如下,感兴趣的额朋友可以

推荐一个简单实用的缩放图片工具 SimpleImage,网站空间,参考

使用方法:

设定宽高,免备案空间,不等比例缩放

复制代码 代码如下:


include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resize(250,400);
$image->save('picture2.jpg');?>

设定宽度,等比例缩放

include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resizeToWidth(250);
$image->save('picture2.jpg');?>

设定高度,等比例缩放

include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resizeToHeight(500);
$image->save('picture2.jpg');
$image->resizeToHeight(200);
$image->save('picture3.jpg');?>

按比例,缩放至50%

include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->scale(50);
$image->save('picture2.jpg');?>

缩放后直接输出到屏幕

header('Content-Type: image/jpeg');
include('SimpleImage.php');
$image = new SimpleImage();
$image->load('picture.jpg');
$image->resizeToWidth(150);
$image->output();?>


SimpleImage.php 源码请轻点文章开头链接,到那下载 ,服务器空间
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template