动态backgroundimages PHP GD [英] Dynamic backgroundimages PHP GD

查看:135
本文介绍了动态backgroundimages PHP GD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题
基本上,这是不可能在一个适当的方式使用了全尺寸的照片与背景图像海事组织。
不同的分辨率,宽屏等等等等什么即时寻找对这一问题的JS / PHP GD的解决方案。

技术
从我听到,这将是如下。 JavaScript的查找可用的屏幕尺寸(浏览器窗口)或screenresolution。这解析到PHP GD。在FTP你将有一个高分辨率的图像(1600×1200为例)。 PHP的GD根据JS解析信息扩展这一点。
这也将有工作在onResize

由于IM只是一个简单的设计师,我缺乏JS / PHP的是杀害我在这个问题上。

一旦它完成了我的新网站

如果有人可以帮助我走出一个妥善的解决办法,我很想朋友建立连结。在此先感谢和爱很多来自荷兰。

菲尔


解决方案

  

基本上,这是不可能在国际海事组织适当的方式使用的背景图像。


我知道这是你的意见,但在网络的其他部分似乎跟你争论。他们使它发挥作用。但是,这可能不是主要问题在这里。

调整为每一位用户的背景下,地狱,如果你不缓存每个请求,是要用核弹攻击你的服务器在一纳秒。 GD调整大小是昂贵的,如果这是在共享主机,你会最终让你的网站拉开序幕了。如果在同一台服务器上的其他网站,他们会慢如蜗牛。

即使你能铲足够的煤到服务器,这将会使一个pretty狡猾的用户体验。而不是只能够下载文件,浏览器将不得不等待,而PHP生成图像,然后才可以下载。

如果我装这个网站的大屏幕上?我有一个可能〜3840 * 1200的分辨率在这里。即使你不称它,我将不得不下载完整版。大的屏幕尺寸并不意味着我有多余的光纤到我的电脑。

不过,所有的说,这是可能的。我建议你​​使用jQuery开始。它使挂钩到窗口-load和调整大小事件和改变CSS动态pretty简单。 PHP调整图像大小,jQuery的在onResize和jQuery的换背景

:坚韧不拔的细节可以用几个简单的谷歌完成

Problem Basicly, it's impossible to use a full-size photograph with the background-image in a proper way imo. Different resolutions, wide-screen etc etc. What im looking for is a JS/PHP GD solution for this problem.

Technique From what i hear, it would be as follows. Javascript looks up available screensize (browser window) or screenresolution. Parses this to PHP GD. On the FTP you'll have a high-res image (1600x1200 for example). The PHP GD scales this according to the information parsed by JS. This will also have to work onResize.

Since im 'just' a simple designer, my lack of JS/PHP is killing me over this issue.

If anyone can help me out with a proper solution, i would love to friend-link them on my new site once it's finished. Thanks in advance and much love from Holland.

Phil

解决方案

Basicly, it's impossible to use the background-image in a proper way imo.

I know that's your opinion but the rest of the web appears to disagree with you. They make it work. But that's probably not the major issue here.

Resizing a background for every user, hell, every request if you don't cache, is going to nuke your server in a nanosecond. GD resizes are expensive and if this is on shared hosting, you'll end up having your site kicked off it. If there are other sites on the same server, they'll slow to a crawl.

Even if you can shovel enough coal into the server, it's going to make for a pretty dodgy user experience. Rather than just being able to download the file, the browser is going to have to wait while the PHP generates the image and only then can it download.

And what if I loaded this site on a large screen? I've got a possible ~3840*1200 resolution here. Even if you don't scale it up, I'll have to download the full version. A large screen size doesn't mean I have redundant optical fibres to my computer.

But, all that said, it's certainly possible. I'd recommend you start with jQuery. It makes hooking onto window -load and -resize events and changing the CSS dynamically pretty simple. The gritty details can be accomplished with a few simple googles: "php resize image", "jquery onresize" and "jquery change background".

这篇关于动态backgroundimages PHP GD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆