12 lines
689 B
TypeScript
12 lines
689 B
TypeScript
import {it,expect} from 'vitest'
|
|
import {withPngDensity} from '../src/main/png-density'
|
|
// A small valid PNG; injecting resolution must not change its image payload.
|
|
const source=Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jvF8AAAAASUVORK5CYII=','base64')
|
|
it('PNG 带有实际 300 DPI 分辨率且可重复更新',()=>{
|
|
const png=withPngDensity(source,300),index=png.indexOf('pHYs')
|
|
expect(png.readUInt32BE(index+4)).toBe(11811);expect(png.readUInt32BE(index+8)).toBe(11811)
|
|
const second=withPngDensity(png,150)
|
|
expect(second.toString('latin1').split('pHYs')).toHaveLength(2)
|
|
expect(second.readUInt32BE(second.indexOf('pHYs')+4)).toBe(5906)
|
|
})
|