繁体   English   中英

创建缩略图的最佳方法?

[英]Best approach to create thumbnails?

我正在为一个网站模板制作工作,该网站已经有50,000多篇文章,并且每篇文章都分配有图片。 在此之前,文章图像仅在每篇文章中可见,但是现在我想使用缩略图。 我无权修改上传图像表单,因此解决方案应该是从原始图像创建虚拟拇指之类的方法。在这种情况下,最佳方法是什么?

像我建议的那样,使用Thumb先生可以使它工作

<?php 

include './mrthumb.class.php'; 

// The image you are resizing. Can be a local path as well. 
$image = $_GET['i'];

$quality = 100; // percent 

// In this example we are resizing the image in proportionate sizes. 
// Below we are specifying the MAX width and height. 
$width = 100; // Pixels 
$height = 130; // Pixels 

// Start Mr. Thumb v1.0 
$mrthumb = new MrThumb(); 

// Render the image 
$mrthumb->render( $image ); 

// Resize the image proportionately 
// $mrthumb->constrain( $width, $height ); 
$mrthumb->proportion( $width, $height ); 

// Finally, output the image to the browser! 
// Optionally we can save the image to a destination 
// $mrthumb->saveto( $destination, $filename, $quality ); 
$mrthumb->output( $quality ); 

// Clean up after you are done! ;) 
$mrthumb->clear_cache(); 

?>

然后将其与mrthumb类一起保存到Web服务器,并在网页中调用缩略图,例如

<img src="./mrthumb.php?i=images/myimage.jpg" alt="My Image" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM