Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

syaning/zhimg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zhimg

Image src util for zhihu images.

npm Travis

Install

$ npm install zhimg

Usage

const zhimg = require('zhimg')

zhimg('https://pic1.zhimg.com/d38dd09765d51b5d163c555b081eea53_b.jpg').l
// => 'https://pic1.zhimg.com/d38dd09765d51b5d163c555b081eea53_l.jpg'

zhimg('d38dd09765d51b5d163c555b081eea53.jpg').m
// => 'https://pic.zhimg.com/d38dd09765d51b5d163c555b081eea53_m.jpg'

zhimg('d38dd09765d51b5d163c555b081eea53_b.jpg').size('200x112')
// => 'https://pic.zhimg.com/d38dd09765d51b5d163c555b081eea53_200x112.jpg'

API

  • zhimg(src): return an Image instance

Instance properties and methods:

  • img.src: return the parameter src
  • img.host: return the host, with default value is 'https://pic.zhimg.com/'
  • img.version: the version, '' or 'v2'
  • img.hash: a string with length 32
  • img.ext: image extension
  • img.b: often appears in answers
  • img.l: large size, 100x100
  • img.m: medium size, 75x75
  • img.r: raw image
  • img.s: small size, 25x25
  • img.t: 150x150
  • img.xl: 200x200
  • img.hd: high definition, the same as raw image
  • img.size(size): custom size, e.g. 200x112

License

MIT

About

Image src util for zhihu images.

Resources

License

Stars

Watchers

Forks

Packages

No packages published