Html 怎么把图片转成html?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10750809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert image to html?
提问by CJ7
Is there a way to convert an image to an html
equivalent of the image, by having an html
table divided up into many cells each having a certain background colour which would act like pixels in an image? Much like ASCII art.
有没有办法html
通过将一个html
表格分成许多单元格,每个单元格具有特定的背景颜色,就像图像中的像素一样,将图像转换为等效的图像?很像 ASCII 艺术。
I would see this as a way to have a corporate logo in an email signature without having to worry about email clients blocking images.
我认为这是一种在电子邮件签名中包含公司徽标的方法,而不必担心电子邮件客户端会阻止图像。
回答by Rich Bradshaw
Yep, loads of people have done this: http://pgl.yoyo.org/img2html/is an example.
是的,很多人都这样做了:http: //pgl.yoyo.org/img2html/就是一个例子。
回答by You Qi
Perhaps what you need is just converting your image to URI format.
也许您需要的只是将图像转换为 URI 格式。
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">
回答by lukeA
Try the "Image to HTML Converter for Email" from STYLECampaign. If I remember it right, you'll get a download link in exchange for subscribing to their newsletter on stylecampaign.com. The tool works ok, has scaling and compression; here's a blog post http://bit.ly/Jhf1CKand a video guide explaining tips and draw backs: http://www.youtube.com/watch?v=VSi51yLQFnc
尝试使用 STYLECampaign 的“Image to HTML Converter for Email”。如果我没记错的话,您将获得一个下载链接,以换取在 stylecampaign.com 上订阅他们的时事通讯。该工具工作正常,具有缩放和压缩功能;这是一篇博客文章http://bit.ly/Jhf1CK和一个解释技巧和缺点的视频指南:http: //www.youtube.com/watch?v=VSi51yLQFnc
回答by tomwalsham
I would caution against attempting this sort of trick.
我会警告不要尝试这种技巧。
A simple rule with doing 'clever' things with email is first to ask "Do Spammers use this same technique?". If the answer is yes, you can be certain that ISPs are manning their filters to junk email containing it.
使用电子邮件做“聪明”事情的一个简单规则是首先询问“垃圾邮件发送者是否使用相同的技术?”。如果答案是肯定的,那么您可以确定 ISP 正在使用过滤器来过滤包含它的垃圾邮件。
In the case of tricking images into displaying, either with the base64 trick or pixeldivs, these techniques have been used for years by spammers and may damage your sending reputation.
在欺骗图像显示的情况下,无论是使用 base64 技巧还是 pixeldivs,这些技术已被垃圾邮件发送者使用多年,可能会损害您的发送声誉。
If the company in question has a good connection with the recipient they will be happy to display images. Many clients such as gmail will enable images once you've replied or added to contacts. Furthermore, using techniques such as DKIM to sign your headers, using a reputable third party sender, or paying for ReturnPath certification can raise your reputation sufficiently to override the image blocking at most major ISPs.
如果有问题的公司与收件人有良好的联系,他们将很乐意展示图像。一旦您回复或添加到联系人,许多客户端(例如 gmail)将启用图像。此外,使用 DKIM 等技术签署您的标头、使用信誉良好的第三方发件人或支付 ReturnPath 认证费用可以充分提高您的声誉,以覆盖大多数主要 ISP 的图像阻止。
回答by Eoin
Tom Walsh, what makes you think it is always ISPs that block images? What about email clients? 80% of emails have images blocked as default. Relying on users to have the effort, or knowledge to change these settings is a bad idea.
Tom Walsh,是什么让您认为阻止图像的总是 ISP?电子邮件客户端呢?80% 的电子邮件默认阻止图像。依靠用户的努力或知识来更改这些设置是一个坏主意。
Using some services such as Mailchimp, give you a new email address each time you send, hence, you cannot add as a safe sender. Techniques such as those mentioned are a great way to get an email list, which has already double opted in, to receive a semi-pictorial version of your email in order to entice them to download images.
使用某些服务(例如 Mailchimp),每次发送时都会为您提供一个新的电子邮件地址,因此您无法将其添加为安全发件人。上面提到的技术是获取电子邮件列表的好方法,该列表已经双重选择接收电子邮件的半图片版本,以吸引他们下载图像。
That top link works. I used a JPG, I'm not sure what format it accepts. Just so you know, this makes the file a fair bit larger than a normal JPG. Consider whether it's worth using for larger images, but for an email signature, I can see that being a decent use. I've noticed that sometimes when you reply, signatures break... sooooo.... be aware you might end up with a load of <tr><td>A</td></tr>
那个顶部链接有效。我使用了 JPG,我不确定它接受什么格式。只是你知道,这使得文件比普通的 JPG 大一点。考虑是否值得将其用于更大的图像,但对于电子邮件签名,我认为这是一个不错的用途。我注意到有时当您回复时,签名会中断……太棒了……请注意,您最终可能会收到大量<tr><td>A</td></tr>
Final warning... if your email signature did break and end up in code form.... be aware that the default for the top link is "arse" hence... some clients may find that offensive. Perhaps change it to your company name. And remember that making a link for this table-image is going to (a) take a while and (b) majorly bloat this code for the second time.
最后警告...如果您的电子邮件签名确实中断并以代码形式结束....请注意顶部链接的默认值是“arse”因此...一些客户可能会觉得这令人反感。也许将其更改为您的公司名称。请记住,为该表格图像创建链接将 (a) 花费一些时间并且 (b) 第二次主要膨胀此代码。
回答by user5701633
Try converting to html/css. It's more compact than base64 and although I haven't tried it yet, it should work. It uses css to create an image without needing anything external. Dont pay attention to the top, that is the place where the code that does all the work is. Pay attention to the bottom. https://codepen.io/blazeeboy/pen/bCaLE
尝试转换为 html/css。它比 base64 更紧凑,虽然我还没有尝试过,但它应该可以工作。它使用 css 来创建一个图像,而不需要任何外部的东西。不要注意顶部,那是完成所有工作的代码所在的地方。注意底部。https://codepen.io/blazeeboy/pen/bCaLE
no code. just something I have to do to get the post online.