Path: blob/master/node_modules/@jimp/jpeg/test/jpeg.test.js
1126 views
import { Jimp, getTestDir } from '@jimp/test-utils';1import configure from '@jimp/custom';23import jpeg from '../src';45const jimp = configure({ types: [jpeg] }, Jimp);67describe('JPEG', () => {8const imagesDir = getTestDir(__dirname) + '/images';910it('load JPG', async () => {11const image = await jimp.read(imagesDir + '/cops.jpg');1213image.getPixelColor(10, 10).should.be.equal(0x3f4a02ff);14image.getPixelColor(220, 190).should.be.equal(0x5d94b6ff);15image.getPixelColor(350, 130).should.be.equal(0xdf7944ff);16});1718it('load JPG with fill bytes', async () => {19const image = await jimp.read(imagesDir + '/fillbytes.jpg');2021image.getPixelColor(10, 10).should.be.equal(0xaeb8c3ff);22image.getPixelColor(220, 190).should.be.equal(0x262b21ff);23image.getPixelColor(350, 130).should.be.equal(0x4e5d30ff);24});2526it('export JPG', async () => {27const image = await jimp.read({28width: 3,29height: 3,30data: [310xff0000ff,320xff0080ff,330xff00ffff,340xff0080ff,350xff00ffff,360x8000ffff,370xff00ffff,380x8000ffff,390x0000ffff40]41});42image.quality(50);43const buffer = await image.getBufferAsync('image/jpeg');4445buffer.toString().should.match(/^.{3,9}JFIF\u0000/);46});47});484950