简体   繁体   English

创建缩略图的最佳方法?

[英]Best approach to create thumbnails?

Im working on a template for a website that has already more than 50,000 articles and images assigned to every article. 我正在为一个网站模板制作工作,该网站已经有50,000多篇文章,并且每篇文章都分配有图片。 Before now the article image was visible only inside every article, but now I would like to use thumbnails. 在此之前,文章图像仅在每篇文章中可见,但是现在我想使用缩略图。 I don't have access to modify the upload image form, so the solution should be something like virtual thumbs created from the original images... What will be the best approach in this case? 我无权修改上传图像表单,因此解决方案应该是从原始图像创建虚拟拇指之类的方法。在这种情况下,最佳方法是什么?

Using Mr. Thumb like I advised a simple script to get it working would be 像我建议的那样,使用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(); 

?>

Then save that to your web server along with the mrthumb class and call a thumbnail in your webpage like 然后将其与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