我需要一些方法来动态优化使用PHP的图像。示例代码或模块将非常有用。谢谢。PHP图像优化
Q
PHP图像优化
-4
A
回答
1
你是什么意思优化?如果您希望保留尺寸但缩小尺寸,请参阅imageJpeg以获取示例,特别是第三个参数(quality
)。考虑100
是完美的质量,并开始减少它,以找到质量和尺寸之间的最佳平衡。
4
可以使用thimthumb.php
去你的.htaccess
不是增加
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*\.(png|jpg))$ /timthumb.php?q=100&src=$1
</IfModule>
“Q = 100” 是质量你可以设置它介乎0-100 比在主目录中创建一个新文件“img.php”例如:www.your-website.com/timthumb.php
http://timthumb.googlecode.com/svn/trunk/timthumb.php
比找到这个
// Get original width and height
$width = imagesx ($image);
$height = imagesy ($image);
$origin_x = 0;
$origin_y = 0;
// generate new w/h if not provided
if ($new_width && !$new_height) {
$new_height = floor ($height * ($new_width/$width));
} else if ($new_height && !$new_width) {
$new_width = floor ($width * ($new_height/$height));
}
以及与此
// Get original width and height
$width = imagesx ($image);
$height = imagesy ($image);
$origin_x = 0;
$origin_y = 0;
// don't allow new width or height to be greater than the original
if($new_width > $width) {
$new_width = $width;
}
if($new_height > $height) {
$new_height = $height;
}
// generate new w/h if not provided
if ($new_width && !$new_height) {
$new_height = floor ($height * ($new_width/$width));
} else if ($new_height && !$new_width) {
$new_width = floor ($width * ($new_height/$height));
}
替换,所以当你去www.your-website.com/images/pict.png它就像你的加载 WWW。 your-website.com/img.php?q=100 & src =/images/pict.png 希望你喜欢这个! &对不起,如果我不能很好地解释,因为我的英语不好。 :D
0
相关问题
- 1. PHP图像优化器
- 2. 通过PHP优化图像
- 3. PHP:图像优化器
- 4. 图像优化
- 5. 优化图像
- 6. 如何避免优化已经使用PHP优化的图像?
- 7. php - 优化图像文件大小
- 8. 如何调用PHP psliwa图像优化
- 9. Slider:图像优化
- 10. 图像优化(iOS)
- 11. 用jQuery优化图像动画以优化iPad优化
- 12. 网页图像优化
- 13. 为Internet Explorer优化图像
- 14. 为网络优化图像
- 15. 图像的批量优化
- 16. 使用GraphicsMagick优化图像
- 17. iOS - 优化。缓存图像
- 18. Node.js - 检测图像优化
- 19. Mathematica图像平均优化
- 20. mozcjpeg - 优化原始图像
- 21. 优化缓冲图像
- 22. 自动化Magento图像优化
- 23. 画布图像像素操作优化
- 24. php图像变化
- 25. gulp图像优化器(gulp-imagemin)未完全优化
- 26. 在优化PHP
- 27. PHP优化 - json_decode
- 28. php mysql优化
- 29. 如何在使用php裁剪后优化图像?
- 30. PHP - 如何为PageSpeed Insights生成优化的jpg图像?
ps:没有人知道你的意思是“动态优化图像”。优化......怎么样?对于文件大小?为了图像清晰? “动态”是什么意思? – mpen 2010-06-22 01:59:58