获取一下binlog image格式
343628
private void loadBinlogImage() {
        ResultSetPacket rs = null;
        try {
            rs = query("show variables like 'binlog_row_image'");
        } catch (IOException e) {
            throw new CanalParseException(e);
        }

        List<String> columnValues = rs.getFieldValues();
        if (columnValues == null || columnValues.size() != 2) {
            // 可能历时版本没有image特性
            binlogImage = BinlogImage.FULL;
        } else {
            binlogImage = BinlogImage.valuesOf(columnValues.get(1));
        }

        if (binlogFormat == null) {
            throw new IllegalStateException("unexpected binlog image query result:" + rs.getFieldValues());
        }
    }
1179341
private static void processBiGram() {
        //移除二元模型出现频率为1的情况
        Iterator<String> iter = BIGRAM.keySet().iterator();
        while(iter.hasNext()){
            String key = iter.next();
            if(BIGRAM.get(key) < 2){
                iter.remove();
            }
        }
        try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("src/main/resources/bigram.txt"),"utf-8"))){
            for(Entry<String, Integer> item : BIGRAM.entrySet()){
                writer.write(item.getKey()+" "+item.getValue()+"\n");
            }
        }catch(Exception e){
            LOGGER.info("保存bigram模型失败：", e);
        }
    }
864261
static boolean loadDat(String path)
    {
        try
        {
            ByteArray byteArray = ByteArray.createByteArray(path + Predefine.BIN_EXT);
            if (byteArray == null) return false;
            int size = byteArray.nextInt();
            CoreDictionary.Attribute[] attributes = new CoreDictionary.Attribute[size];
            final Nature[] natureIndexArray = Nature.values();
            for (int i = 0; i < size; ++i)
            {
                // 第一个是全部频次，第二个是词性个数
                int currentTotalFrequency = byteArray.nextInt();
                int length = byteArray.nextInt();
                attributes[i] = new CoreDictionary.Attribute(length);
                attributes[i].totalFrequency = currentTotalFrequency;
                for (int j = 0; j < length; ++j)
                {
                    attributes[i].nature[j] = natureIndexArray[byteArray.nextInt()];
                    attributes[i].frequency[j] = byteArray.nextInt();
                }
            }
            if (!trie.load(byteArray, attributes) || byteArray.hasMore()) return false;
        }
        catch (Exception e)
        {
            logger.warning("读取失败，问题发生在" + e);
            return false;
        }
        return true;
    }
1066228
def display(self, image):
        
        assert(image.mode == self.mode)
        assert(image.size == self.size)

        image = self.preprocess(image)

        self.command(0x20, 0x80, 0x40)

        buf = bytearray(self._w * self._h // 8)
        off = self._offsets
        mask = self._mask

        for idx, pix in enumerate(image.getdata()):
            if pix > 0:
                buf[off[idx]] |= mask[idx]

        self.data(list(buf))
977422
def bin2hex(s):
    
    padding_length = (8 - len(s) % 8) % 8
    # 从前往后解码，不足8个的，在后面补0
    encode_str = '%s%s' % (s, '0' * padding_length)
    # 解码后是 0xab1234，需要去掉前面的 0x
    return hex(int(encode_str, 2))[2:].rstrip('L')
423786
def photo(self):
        
        if isinstance(self.result, types.BotInlineResult):
            return self.result.thumb
        elif isinstance(self.result, types.BotInlineMediaResult):
            return self.result.photo
598965
private ByteArrayInputStream generateThumbImageByDefault(InputStream inputStream) throws IOException {
        LOGGER.debug("根据默认配置生成缩略图");
        // 在内存当中生成缩略图
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        //@formatter:off
        Thumbnails
                .of(inputStream)
                .size(thumbImageConfig.getWidth(), thumbImageConfig.getHeight())
                .toOutputStream(out);
        //@formatter:on
        return new ByteArrayInputStream(out.toByteArray());
    }
553211
def reveal(
    input_image: Union[str, IO[bytes]],
    generator: Iterator[int],
    shift: int = 0,
    encoding: str = "UTF-8",
):
    
    img = tools.open_image(input_image)
    img_list = list(img.getdata())
    width, height = img.size
    buff, count = 0, 0
    bitab = []
    limit = None

    while shift != 0:
        next(generator)
        shift -= 1

    while True:
        generated_number = next(generator)
        # color = [r, g, b]
        for color in img_list[generated_number]:
            buff += (color & 1) << (tools.ENCODINGS[encoding] - 1 - count)
            count += 1
            if count == tools.ENCODINGS[encoding]:
                bitab.append(chr(buff))
                buff, count = 0, 0
                if bitab[-1] == ":" and limit == None:
                    if "".join(bitab[:-1]).isdigit():
                        limit = int("".join(bitab[:-1]))
                    else:
                        raise IndexError("Impossible to detect message.")
        if len(bitab) - len(str(limit)) - 1 == limit:
            return "".join(bitab)[len(str(limit)) + 1 :]
681479
private function _writeNoise() {
        $codeSet = '2345678abcdefhijkmnpqrstuvwxyz';
        for($i = 0; $i < 10; $i++){
            //杂点颜色
            $noiseColor = imagecolorallocate($this->_image, mt_rand(150,225), mt_rand(150,225), mt_rand(150,225));
            for($j = 0; $j < 5; $j++) {
                // 绘杂点
                imagestring($this->_image, 5, mt_rand(-10, $this->imageW),  mt_rand(-10, $this->imageH), $codeSet[mt_rand(0, 29)], $noiseColor);
            }
        }
    }
1059336
public static <T extends ImageBase<T>> void log(T input , T output ) {
		if( input instanceof ImageGray ) {
			if (GrayF32.class == input.getClass()) {
				PixelMath.log((GrayF32) input, (GrayF32) output);
			} else if (GrayF64.class == input.getClass()) {
				PixelMath.log((GrayF64) input, (GrayF64) output);
			} else {
				throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName());
			}
		} else if( input instanceof Planar ) {
			Planar in = (Planar)input;
			Planar out = (Planar)output;

			for (int i = 0; i < in.getNumBands(); i++) {
				log( in.getBand(i), out.getBand(i));
			}
		}
	}
572710
function processNodeRule (nodeRule, imageReplaces, coll2x, coll3x) {
    var img, imgKey, __url
    _.each(nodeRule.declarations, function(e){
        if(e.property == 'background-image'){
            __url = __getURL(e.value)
            img = img || imageReplaces[__url]
            imgKey = img? __url: imgKey
        }
    })
    if(!img) return
    // 修改节点
    updateNodeByMerge(nodeRule, __generatorCSSObj(img))
    // 更新2x 3x 收集器
    updateCollectMX(imgKey, imageReplaces, nodeRule.selectors, coll2x, coll3x)

    function __getURL(bgURL){
        return _.trim(bgURL.split('url').join(''), '()"\'')
    }
    function __generatorCSSObj(img){
        return {
            "background-image": "url("+img.sprite+")",
            "background-position":  "-"+img.x+"px -"+img.y+"px"
        }
    }
}
245836
private String getLogoImageData() {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        BufferedInputStream reader = null;
        
        try {
            reader = new BufferedInputStream(FileUtils.getFileResource(logo).getInputStream());
            
            byte[] contents = new byte[1024];
            while( reader.read(contents) != -1) {
                os.write(contents);
            }
        } catch(IOException e) {
            log.warn("Failed to add logo image data to HTML report", e);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch(IOException ex) {
                    log.warn("Failed to close logo image resource for HTML report", ex);
                }
            }
            
            try {
                os.flush();
            } catch(IOException ex) {
                log.warn("Failed to flush logo image stream for HTML report", ex);
            }
        }
        
        return Base64.encodeBase64String(os.toByteArray());
    }
974426
function(x,y) {
      var ctxt = this.getContext();
	   var imgData = ctxt.getImageData(x,y,1,1);
	   var pixel = imgData.data;
	   return !( pixel[0] === 0 && pixel[1] === 0 && pixel[2] === 0 && pixel[3] === 0 );
   }
599536
def image(self, image, name):
        
        assert len(name.split(" ")) < 2, "Ensure that you don't have spaces in your variable name, use '_' instead."
        name = "image_" + name
        self.previous.append(name)
        if self.previous[-1] not in self.previous[:-1]:
            self.c.execute("""INSERT INTO {time_stamp_table} (
                              variable_name, variable_type
                              ) VALUES ('{variable}', '{type}')"""
                           .format(time_stamp_table=self.time_stamp, variable=name, type="image"))
        else:
            self.previous.pop()

        self.c.execute("""CREATE TABLE IF NOT EXISTS {variable_table_name} (
                          images BLOB, time VARCHAR
                          )""".format(variable_table_name=self.time_stamp + '_' + name))

        self.c.execute("""INSERT INTO {variable_table_name} (
                          images, time) VALUES ('{img}', '{time}'
                          )""".format(variable_table_name=self.time_stamp + '_' + name,
                                      img=sqlite3.Binary(np.array(image).tobytes()), time=datetime.datetime.now()))
        self.conn.commit()
1092341
protected function writeCurve() 
    {        
        $px = $py = 0;
        
        // 曲线前部分
        $A = mt_rand(1, $this->cfg['height']/2);                  // 振幅
        $b = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // Y轴方向偏移量
        $f = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // X轴方向偏移量
        $T = mt_rand($this->cfg['height'], $this->cfg['width']*2);      // 周期
        $w = (2* M_PI)/$T;
                        
        $px1 = 0;  // 曲线横坐标起始位置
        $px2 = mt_rand($this->cfg['width']/2, $this->cfg['width'] * 0.8);  // 曲线横坐标结束位置

        for ($px = $px1; $px <= $px2; $px ++) {
            if ($w == 0) {
                break;
            }
            
            $py = $A * sin($w*$px + $f)+ $b + $this->cfg['height']/2;  // y = Asin(ωx+φ) + b
            $i = (int) ($this->cfg['fontSize']/6);
            while ($i > 0) {    
                imagesetpixel($this->image, $px, $py + $i, $this->color);  // 这里(while)循环画像素点比imagettftext和imagestring用字体大小一次画出（不用这while循环）性能要好很多                    
                $i--;
            }
        }
        
        // 曲线后部分
        $A = mt_rand(1, $this->cfg['height']/2);                  // 振幅        
        $f = mt_rand(-$this->cfg['height']/4, $this->cfg['height']/4);   // X轴方向偏移量
        $T = mt_rand($this->cfg['height'], $this->cfg['width']*2);      // 周期
        $w = (2* M_PI)/$T;        
        $b = $py - $A * sin($w*$px + $f) - $this->cfg['height']/2;
        $px1 = $px2;
        $px2 = $this->cfg['width'];

        for ($px = $px1; $px <= $px2; $px ++) {
            if ($w == 0) {
                break;
            }
            
            $py = $A * sin($w*$px + $f)+ $b + $this->cfg['height']/2;  // y = Asin(ωx+φ) + b
            $i = (int) ($this->cfg['fontSize']/6);
            while ($i > 0) {            
                imagesetpixel($this->image, $px, $py + $i, $this->color);
                $i--;
            }
        }
    }
1247613
def log_binary(logger, message, **kwargs):
    """"""
    if logger.isEnabledFor(logging.DEBUG):
        output = ('{0}={1}'.format(k, binascii.hexlify(
            bytearray(v)).decode()) for k, v in sorted(kwargs.items()))
        logger.debug('%s (%s)', message, ', '.join(output))
159760
def from_image(cls, image, filename):
        

        source = Image.open(BytesIO(image))
        source = source.convert('1')
        width = int(math.ceil(source.size[0] / 8.0))

        data = []
        for line in _chunked(list(source.getdata()), source.size[0]):
            row = ''.join(['0' if p else '1' for p in line])
            row = row.ljust(width * 8, '0')
            data.append(row)
        data = GRFData(width, bin=''.join(data))

        return cls(filename, data)