【问题标题】:Quality of inline image on iPhone emailsiPhone 电子邮件内嵌图像的质量
【发布时间】:2019-11-26 10:38:22
【问题描述】:

我们每天使用 Python 脚本生成电子邮件并向业务用户发送每日报告。 在这些电子邮件中,我们添加了报告的 PrintScreen。在这种情况下,用户无需在手机上打开附件(PDF),就可以在电子邮件中看到结果(报告的编号)。

但问题是,对于某些 iPhone 机型,图像非常模糊,无法看到图像的内容。
安卓手机没问题。

对于 iPhone 有没有办法说像 请不要把图片的质量缩小这么多。

添加图片的函数:

def send_email(send_to, subject, html, plain, img_path, cc):
try:
    # prepare date for email subject
    scorecard_date = date.today() - timedelta(1)

    # prepare message
    msg = MIMEMultipart() 
    msg['From'] = email_user
    msg['To'] = send_to
    msg['Subject'] = subject + ' - for ' + scorecard_date.strftime('%d/%m/%Y')

    # attach cc if applicable
    if cc is not None:
        msg['Cc'] = cc
        send_to = [send_to, cc]

    # attach plain or html body
    if html is not None:
        msg.attach(MIMEText(html, 'html'))
    else:
        msg.attach(MIMEText(plain, 'plain'))

    # attach image if applicable
    if img_path is not None:    
        fp = open(img_path, 'rb')
        msg_image = MIMEImage(fp.read())
        msg_image.add_header('Content-ID', '<image1>')
        msg.attach(msg_image)
        fp.close()

    # create server instance and send email
    server = smtplib.SMTP(smtp_host, smtp_port)
    server.starttls()
    server.login(email_user, sc.get_email_pass())
    text = msg.as_string()
    server.sendmail(email_user, send_to, text)
    server.quit()

    # return ok
    return 0
except:
    # something went wrong - probably timeout
    return 1

在电子邮件正文中插入图像的 HTML 标记:

<div style="line-height:15px;font-size:1px">&#160;</div>  <img class="left  autowidth  fullwidth" align="left" border="0" src="cid:image1" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: 0;height: auto;float: none;width: 150%;max-width: 1024px" width="1024">

谢谢你, 大流士

【问题讨论】:

    标签: html css iphone html-email


    【解决方案1】:

    iPhone 正在使用我们所说的视网膜显示。简而言之,这些设备具有比其他传统 Apple 显示器更高的像素密度

    Apple 所做的是用 2 个像素代替 1 个像素。这意味着您的图像大小是它应该显示的大小的一半。

    例如,如果您的图像设置为 200 像素 x 200 像素,Apple 会将其显示为 200 像素 x 200 像素,但空间为 400 像素 x 400 像素(在他们的设备上),这意味着您的图像会调整大小以适应该空间。

    您需要截取屏幕截图并在 iOS 上以较小的尺寸显示它以绕过视网膜显示。

    有视网膜显示器的型号可以在here找到。

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 1970-01-01
      • 2013-08-23
      • 1970-01-01
      • 2015-07-29
      • 2014-10-14
      相关资源
      最近更新 更多