使用base64,SVG,PNG的优点和缺点

时间:2017-11-01 21:50:42

标签: svg base64 png

使用这些中的优点和缺点是什么?

例如,是否可以说哪一个加载速度最快?

是一种分辨率,图像质量比另一种好吗?

数据:图像/ SVG + xml的; BASE64

case class Result(id: String, descr: String)

//// This is the Starting point of my CODE:
private def addFeatureByTag(tag: String) : Map[String, Result] = {

 val uri = "URI to get the Memebers"
 val result = Source
   .single(Http().singleRequest(HttpRequest(uri = uri)) 
   .map(getMembers) 
   .map(getResult)

}



private def getMembers(response : Future[HttpResponse]): 
Future[Source[String, NotUsed]] = {

response.flatMap {
  res =>
    res.status match {
      case StatusCodes.OK =>
        Unmarshal(res.entity).to[String] map {
          jsonOut => getAllMembers(jsonOut).  //// This method return the stream of `Members` (Strings)
        }
    }
  }
}

// How can I implement following two methods correctly `getResult` and `getResponse`
private def getResult(member: Future[Source[String, NotUsed]]) : Future[Source[Future[HttpResponse], NotUsed]] = {
 // member.map(mem => getResponse(PREFIX + mem)) 

}

private def getResponse(uri: Source[String, NotUsed]) = {

 // val resp = Http().singleRequest(HttpRequest(uri))

 // resp
}

VS

SVG

<img src='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjI2IDE0ODEiPgogIDxwYXRoIGQ9Ik0wIDEzOTRWODdDMCA0Ni4zIDEzLjMgMTkuOCA0MCA3LjUgNjYuNy00LjggOTguNy4zIDEzNiAyM2wxMDM0IDYzNGMzNy4zIDIyLjcgNTYgNTAuMyA1NiA4M3MtMTguNyA2MC4zLTU2IDgzTDEzNiAxNDU4Yy0zNy4zIDIyLjctNjkuMyAyNy44LTk2IDE1LjUtMjYuNy0xMi4zLTQwLTM4LjgtNDAtNzkuNXoiIGZpbGw9IiMwMDU5ZGQiLz4KIDwvc3ZnPg==''>

VS

PNG

 <svg viewBox="0 0 1226 1481" >
  <path d="M0 1394V87C0 46.3 13.3 19.8 40 7.5 66.7-4.8 98.7.3 136 23l1034 634c37.3 22.7 56 50.3 56 83s-18.7 60.3-56 83L136 1458c-37.3 22.7-69.3 27.8-96 15.5-26.7-12.3-40-38.8-40-79.5z" fill="#0059dd"/>
 </svg>

1 个答案:

答案 0 :(得分:0)

Base64的最大问题之一是尺寸,将原始图像尺寸增加近30%。