[英]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.