动态调整图像大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了动态调整图像大小相关的知识,希望对你有一定的参考价值。
get the image size and reduces it dynamically
<?php function imageResize($width, $height, $target) { //takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the return "width="$width" height="$height""; } ?> //Then in the HTML: <?php //get the image size of the picture and load it into an array ?> <!-using a standard html image tag, where you would have the width and height, insert your new imageResize() function with the correct attributes --> <img src="images/sock001.jpg" <?php imageResize($mysock[0], $mysock[1], 150); ?>>
以上是关于动态调整图像大小的主要内容,如果未能解决你的问题,请参考以下文章