Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of unclear PHPCMS thumbnails

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to solve the problem of unclear PHPCMS thumbnails, the code is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

First, find the classes directory in the libs under phpcms and open it; then find the file "image.class.php" and open it; finally, search for the place where the "$imagefun ()" function is called and pass the third argument 90.

Search for the next function

Function thumb ($image, $filename ='', $maxwidth = 200,200, $maxheight = 200, $suffix='', $autocut = 0, $ftp = 0) {if (! $this- > thumb_enable | |! $this- > check ($image) return false; $info = image::info ($image); if ($info = false) return false; $srcwidth = $info ['width']; $srcheight = $info [' height']; $pathinfo = pathinfo ($image) $type = $pathinfo ['extension']; if (! $type) $type = $info [' type']; $type = strtolower ($type); unset ($info); $creat_arr = $this- > getpercent ($srcwidth,$srcheight,$maxwidth,$maxheight); $createwidth = $width = $creat_arr ['w'] $createheight = $height=$ creat_arr ['h']; $psrc_x = $psrc_y = 0; if ($autocut & & $maxwidth > 0 & & $maxheight > 0) {if ($maxwidth/$maxheight=$height) {$width = $maxheight/$height*$width; $height=$ maxheight } elseif ($maxwidth/$maxheight > $srcwidth/$srcheight & & $maxwidth > = $width) {$height = $maxwidth/$width*$height; $width = $maxwidth;} $createwidth = $maxwidth; $createheight = $maxheight } $createfun = 'imagecreatefrom'. ($type=='jpg'? 'jpeg': $type); $srcimg = $createfun ($image); if ($type! =' gif' & & function_exists ('imagecreatetruecolor')) $thumbimg = imagecreatetruecolor ($createwidth, $createheight); else $thumbimg = imagecreate ($width, $height) If (function_exists ('imagecopyresampled')) imagecopyresampled ($thumbimg, $srcimg, 0,0, $psrc_x, $psrc_y, $width, $height, $srcwidth, $srcheight); else imagecopyresized ($thumbimg, $srcimg, 0,0, $psrc_x, $psrc_y, $width, $height, $srcwidth, $srcheight) If ($type=='gif' | | $type=='png') {$background_color = imagecolorallocate ($thumbimg, 0,255,0); / / assign a green imagecolortransparent ($thumbimg, $background_color) / / set to transparent color. If the line is commented out, the green image} if ($type=='jpg' | | $type=='jpeg') imageinterlace ($thumbimg, $this- > interlace); $imagefun = 'image'. ($type=='jpg'? 'jpeg': $type); if (empty ($filename)) $filename = substr ($image, 0, strrpos ($image,'.')). $suffix.'.'.$type; $imagefun ($thumbimg, $filename); imagedestroy ($thumbimg); imagedestroy ($srcimg); if ($ftp) {@ unlink ($image) } return $filename;}

And find it.

If ($type=='jpg' | | $type=='jpeg') imageinterlace ($thumbimg, $this- > interlace); $imagefun = 'image'. ($type=='jpg'? 'jpeg': $type); if (empty ($filename)) $filename = substr ($image, 0, strrpos ($image,'.')). $suffix.'.'.$type;$imagefun ($thumbimg, $filename); imagedestroy ($thumbimg); imagedestroy ($srcimg)

Change to

If ($type=='jpg' | | $type=='jpeg') imageinterlace ($thumbimg, $this- > interlace); $imagefun = 'image'. ($type=='jpg'? 'jpeg': $type); if (empty ($filename)) $filename = substr ($image, 0, strrpos ($image,'.')). $suffix.'.'.$type;$imagefun ($thumbimg, $filename, 90); imagedestroy ($thumbimg); imagedestroy ($srcimg); the above is how to solve the problem of unclear PHPCMS thumbnails. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report